diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index b31bc3813a..ffb7012bb3 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -6169,25 +6169,47 @@ void SurfaceFlinger::traverseLayersInDisplay(const sp<const DisplayDevice>& disp } } +void SurfaceFlinger::setPreferredDisplayConfig() { + const auto& type = mScheduler->getPreferredRefreshRateType(); + const auto& config = mRefreshRateConfigs.getRefreshRate(type); + if (config && isDisplayConfigAllowed(config->configId)) { + ALOGV("switching to Scheduler preferred config %d", config->configId); + setDesiredActiveConfig({type, config->configId, Scheduler::ConfigEvent::Changed}); + } else { + // Set the highest allowed config by iterating backwards on available refresh rates + const auto& refreshRates = mRefreshRateConfigs.getRefreshRates(); + for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) { + if (iter->second && isDisplayConfigAllowed(iter->second->configId)) { + ALOGV("switching to allowed config %d", iter->second->configId); + setDesiredActiveConfig({iter->first, iter->second->configId, + Scheduler::ConfigEvent::Changed}); + } + } + } +} + void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display, const std::vector<int32_t>& allowedConfigs) { if (!display->isPrimary()) { return; } - ALOGV("Updating allowed configs"); - mAllowedDisplayConfigs = DisplayConfigs(allowedConfigs.begin(), allowedConfigs.end()); - - // Set the highest allowed config by iterating backwards on available refresh rates - const auto& refreshRates = mRefreshRateConfigs.getRefreshRates(); - for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) { - if (iter->second && isDisplayConfigAllowed(iter->second->configId)) { - ALOGV("switching to config %d", iter->second->configId); - setDesiredActiveConfig( - {iter->first, iter->second->configId, Scheduler::ConfigEvent::Changed}); - break; - } + const auto allowedDisplayConfigs = DisplayConfigs(allowedConfigs.begin(), + allowedConfigs.end()); + if (allowedDisplayConfigs == mAllowedDisplayConfigs) { + return; } + + ALOGV("Updating allowed configs"); + mAllowedDisplayConfigs = std::move(allowedDisplayConfigs); + + // TODO(b/140204874): This hack triggers a notification that something has changed, so + // that listeners that care about a change in allowed configs can get the notification. + // Giving current ActiveConfig so that most other listeners would just drop the event + mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, + display->getActiveConfig()); + + setPreferredDisplayConfig(); } status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken, |