Loading services/surfaceflinger/Scheduler/Scheduler.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,7 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() { } // Content detection is on, find the appropriate refresh rate with minimal error // TODO(b/139751853): Scan allowed refresh rates only (SurfaceFlinger::mAllowedDisplayConfigs) const float rate = static_cast<float>(mFeatures.contentRefreshRate); auto iter = min_element(mRefreshRateConfigs.getRefreshRates().cbegin(), mRefreshRateConfigs.getRefreshRates().cend(), Loading Loading @@ -541,6 +542,11 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() { return currRefreshRateType; } Scheduler::RefreshRateType Scheduler::getPreferredRefreshRateType() { std::lock_guard<std::mutex> lock(mFeatureStateLock); return mFeatures.refreshRateType; } void Scheduler::changeRefreshRate(RefreshRateType refreshRateType, ConfigEvent configEvent) { std::lock_guard<std::mutex> lock(mCallbackLock); if (mChangeRefreshRateCallback) { Loading services/surfaceflinger/Scheduler/Scheduler.h +3 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,9 @@ public: void dump(std::string&) const; void dump(ConnectionHandle, std::string&) const; // Get the appropriate refresh type for current conditions. RefreshRateType getPreferredRefreshRateType(); private: friend class TestableScheduler; Loading services/surfaceflinger/SurfaceFlinger.cpp +20 −10 Original line number Diff line number Diff line Loading @@ -5578,6 +5578,25 @@ 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()) { Loading @@ -5599,16 +5618,7 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& d mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, display->getActiveConfig()); // 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; } } setPreferredDisplayConfig(); } status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken, Loading services/surfaceflinger/SurfaceFlinger.h +3 −0 Original line number Diff line number Diff line Loading @@ -528,6 +528,9 @@ private: // called on the main thread in response to setPowerMode() void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock); // Query the Scheduler or allowed display configs list for a matching config, and set it void setPreferredDisplayConfig() REQUIRES(mStateLock); // called on the main thread in response to setAllowedDisplayConfigs() void setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display, const std::vector<int32_t>& allowedConfigs) Loading Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,7 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() { } // Content detection is on, find the appropriate refresh rate with minimal error // TODO(b/139751853): Scan allowed refresh rates only (SurfaceFlinger::mAllowedDisplayConfigs) const float rate = static_cast<float>(mFeatures.contentRefreshRate); auto iter = min_element(mRefreshRateConfigs.getRefreshRates().cbegin(), mRefreshRateConfigs.getRefreshRates().cend(), Loading Loading @@ -541,6 +542,11 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() { return currRefreshRateType; } Scheduler::RefreshRateType Scheduler::getPreferredRefreshRateType() { std::lock_guard<std::mutex> lock(mFeatureStateLock); return mFeatures.refreshRateType; } void Scheduler::changeRefreshRate(RefreshRateType refreshRateType, ConfigEvent configEvent) { std::lock_guard<std::mutex> lock(mCallbackLock); if (mChangeRefreshRateCallback) { Loading
services/surfaceflinger/Scheduler/Scheduler.h +3 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,9 @@ public: void dump(std::string&) const; void dump(ConnectionHandle, std::string&) const; // Get the appropriate refresh type for current conditions. RefreshRateType getPreferredRefreshRateType(); private: friend class TestableScheduler; Loading
services/surfaceflinger/SurfaceFlinger.cpp +20 −10 Original line number Diff line number Diff line Loading @@ -5578,6 +5578,25 @@ 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()) { Loading @@ -5599,16 +5618,7 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& d mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, display->getActiveConfig()); // 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; } } setPreferredDisplayConfig(); } status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken, Loading
services/surfaceflinger/SurfaceFlinger.h +3 −0 Original line number Diff line number Diff line Loading @@ -528,6 +528,9 @@ private: // called on the main thread in response to setPowerMode() void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock); // Query the Scheduler or allowed display configs list for a matching config, and set it void setPreferredDisplayConfig() REQUIRES(mStateLock); // called on the main thread in response to setAllowedDisplayConfigs() void setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display, const std::vector<int32_t>& allowedConfigs) Loading