Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -57,7 +57,7 @@ public: } } ~RefreshRateConfigs() = default; ~RefreshRateConfigs() = default; const std::unordered_map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() { const std::map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() { return mRefreshRates; return mRefreshRates; } } std::shared_ptr<RefreshRate> getRefreshRate(RefreshRateType type) { std::shared_ptr<RefreshRate> getRefreshRate(RefreshRateType type) { Loading Loading @@ -120,7 +120,7 @@ private: } } } } std::unordered_map<RefreshRateType, std::shared_ptr<RefreshRate>> mRefreshRates; std::map<RefreshRateType, std::shared_ptr<RefreshRate>> mRefreshRates; }; }; } // namespace scheduler } // namespace scheduler Loading services/surfaceflinger/SurfaceFlinger.cpp +9 −24 Original line number Original line Diff line number Diff line Loading @@ -1041,6 +1041,7 @@ bool SurfaceFlinger::performSetActiveConfig() NO_THREAD_SAFETY_ANALYSIS { // on both cases there is nothing left to do // on both cases there is nothing left to do std::lock_guard<std::mutex> lock(mActiveConfigLock); std::lock_guard<std::mutex> lock(mActiveConfigLock); mScheduler->pauseVsyncCallback(mAppConnectionHandle, false); mScheduler->pauseVsyncCallback(mAppConnectionHandle, false); mDesiredActiveConfig.event = Scheduler::ConfigEvent::None; mDesiredActiveConfigChanged = false; mDesiredActiveConfigChanged = false; ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged); ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged); return false; return false; Loading Loading @@ -5817,34 +5818,18 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal( mAllowedConfigs[*displayId] = std::move(allowedConfigs); mAllowedConfigs[*displayId] = std::move(allowedConfigs); } } // make sure that the current config is still allowed // Set the highest allowed config by iterating backwards on available refresh rates int currentConfigIndex = getHwComposer().getActiveConfigIndex(*displayId); const auto& refreshRates = mRefreshRateConfigs[*displayId]->getRefreshRates(); if (!isConfigAllowed(*displayId, currentConfigIndex)) { for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) { for (const auto& [type, config] : mRefreshRateConfigs[*displayId]->getRefreshRates()) { if (iter->second && isConfigAllowed(*displayId, iter->second->configId)) { if (config && isConfigAllowed(*displayId, config->configId)) { ALOGV("switching to config %d", iter->second->configId); // TODO: we switch to the first allowed config. In the future setDesiredActiveConfig(displayToken, iter->second->configId, // we may want to enhance this logic to pick a similar config // to the current one ALOGV("Old config is not allowed - switching to config %d", config->configId); setDesiredActiveConfig(displayToken, config->configId, Scheduler::ConfigEvent::Changed); Scheduler::ConfigEvent::Changed); break; break; } } } } } } // If idle timer and fps detection are disabled and we are in RefreshRateType::DEFAULT, // there is no trigger to move to RefreshRateType::PERFORMANCE, even if it is an allowed. if (!mScheduler->isIdleTimerEnabled() && !mUseSmart90ForVideo) { const auto& performanceRefreshRate = mRefreshRateConfigs[*displayId]->getRefreshRate(RefreshRateType::PERFORMANCE); if (performanceRefreshRate && isConfigAllowed(*displayId, performanceRefreshRate->configId)) { setRefreshRateTo(RefreshRateType::PERFORMANCE, Scheduler::ConfigEvent::Changed); } } } status_t SurfaceFlinger::setAllowedDisplayConfigs(const android::sp<android::IBinder>& displayToken, status_t SurfaceFlinger::setAllowedDisplayConfigs(const android::sp<android::IBinder>& displayToken, const std::vector<int32_t>& allowedConfigs) { const std::vector<int32_t>& allowedConfigs) { ATRACE_CALL(); ATRACE_CALL(); Loading Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -57,7 +57,7 @@ public: } } ~RefreshRateConfigs() = default; ~RefreshRateConfigs() = default; const std::unordered_map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() { const std::map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() { return mRefreshRates; return mRefreshRates; } } std::shared_ptr<RefreshRate> getRefreshRate(RefreshRateType type) { std::shared_ptr<RefreshRate> getRefreshRate(RefreshRateType type) { Loading Loading @@ -120,7 +120,7 @@ private: } } } } std::unordered_map<RefreshRateType, std::shared_ptr<RefreshRate>> mRefreshRates; std::map<RefreshRateType, std::shared_ptr<RefreshRate>> mRefreshRates; }; }; } // namespace scheduler } // namespace scheduler Loading
services/surfaceflinger/SurfaceFlinger.cpp +9 −24 Original line number Original line Diff line number Diff line Loading @@ -1041,6 +1041,7 @@ bool SurfaceFlinger::performSetActiveConfig() NO_THREAD_SAFETY_ANALYSIS { // on both cases there is nothing left to do // on both cases there is nothing left to do std::lock_guard<std::mutex> lock(mActiveConfigLock); std::lock_guard<std::mutex> lock(mActiveConfigLock); mScheduler->pauseVsyncCallback(mAppConnectionHandle, false); mScheduler->pauseVsyncCallback(mAppConnectionHandle, false); mDesiredActiveConfig.event = Scheduler::ConfigEvent::None; mDesiredActiveConfigChanged = false; mDesiredActiveConfigChanged = false; ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged); ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged); return false; return false; Loading Loading @@ -5817,34 +5818,18 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal( mAllowedConfigs[*displayId] = std::move(allowedConfigs); mAllowedConfigs[*displayId] = std::move(allowedConfigs); } } // make sure that the current config is still allowed // Set the highest allowed config by iterating backwards on available refresh rates int currentConfigIndex = getHwComposer().getActiveConfigIndex(*displayId); const auto& refreshRates = mRefreshRateConfigs[*displayId]->getRefreshRates(); if (!isConfigAllowed(*displayId, currentConfigIndex)) { for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) { for (const auto& [type, config] : mRefreshRateConfigs[*displayId]->getRefreshRates()) { if (iter->second && isConfigAllowed(*displayId, iter->second->configId)) { if (config && isConfigAllowed(*displayId, config->configId)) { ALOGV("switching to config %d", iter->second->configId); // TODO: we switch to the first allowed config. In the future setDesiredActiveConfig(displayToken, iter->second->configId, // we may want to enhance this logic to pick a similar config // to the current one ALOGV("Old config is not allowed - switching to config %d", config->configId); setDesiredActiveConfig(displayToken, config->configId, Scheduler::ConfigEvent::Changed); Scheduler::ConfigEvent::Changed); break; break; } } } } } } // If idle timer and fps detection are disabled and we are in RefreshRateType::DEFAULT, // there is no trigger to move to RefreshRateType::PERFORMANCE, even if it is an allowed. if (!mScheduler->isIdleTimerEnabled() && !mUseSmart90ForVideo) { const auto& performanceRefreshRate = mRefreshRateConfigs[*displayId]->getRefreshRate(RefreshRateType::PERFORMANCE); if (performanceRefreshRate && isConfigAllowed(*displayId, performanceRefreshRate->configId)) { setRefreshRateTo(RefreshRateType::PERFORMANCE, Scheduler::ConfigEvent::Changed); } } } status_t SurfaceFlinger::setAllowedDisplayConfigs(const android::sp<android::IBinder>& displayToken, status_t SurfaceFlinger::setAllowedDisplayConfigs(const android::sp<android::IBinder>& displayToken, const std::vector<int32_t>& allowedConfigs) { const std::vector<int32_t>& allowedConfigs) { ATRACE_CALL(); ATRACE_CALL(); Loading