Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -97,8 +97,8 @@ std::pair<nsecs_t, nsecs_t> RefreshRateConfigs::getDisplayFrames(nsecs_t layerPe return {displayFramesQuot, displayFramesRem}; } const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( const std::vector<LayerRequirement>& layers, bool touchActive, const RefreshRate& RefreshRateConfigs::getBestRefreshRate( const std::vector<LayerRequirement>& layers, bool touchActive, bool idle, bool* touchConsidered) const { ATRACE_CALL(); ALOGV("getRefreshRateForContent %zu layers", layers.size()); Loading @@ -106,14 +106,6 @@ const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( *touchConsidered = false; std::lock_guard lock(mLock); // If there are not layers, there is not content detection, so return the current // refresh rate. if (layers.empty()) { *touchConsidered = touchActive; return touchActive ? getMaxRefreshRateByPolicyLocked() : getCurrentRefreshRateByPolicyLocked(); } int noVoteLayers = 0; int minVoteLayers = 0; int maxVoteLayers = 0; Loading Loading @@ -143,6 +135,14 @@ const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( return getMaxRefreshRateByPolicyLocked(); } if (!touchActive && idle) { return getMinRefreshRateByPolicyLocked(); } if (layers.empty()) { return getCurrentRefreshRateByPolicyLocked(); } // Only if all layers want Min we should return Min if (noVoteLayers + minVoteLayers == layers.size()) { return getMinRefreshRateByPolicyLocked(); Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +8 −6 Original line number Diff line number Diff line Loading @@ -212,12 +212,14 @@ public: const RefreshRate& getRefreshRateForContent(const std::vector<LayerRequirement>& layers) const EXCLUDES(mLock); // Returns the refresh rate that fits best to the given layers. This function also gets a // boolean flag that indicates whether user touched the screen recently to be factored in when // choosing the refresh rate and returns whether the refresh rate was chosen as a result of // a touch event. const RefreshRate& getRefreshRateForContentV2(const std::vector<LayerRequirement>& layers, bool touchActive, bool* touchConsidered) const // Returns the refresh rate that fits best to the given layers. // layers - The layer requirements to consider. // touchActive - Whether the user touched the screen recently. Used to apply touch boost. // idle - True if the system hasn't seen any buffers posted to layers recently. // touchConsidered - An output param that tells the caller whether the refresh rate was chosen // based on touch boost. const RefreshRate& getBestRefreshRate(const std::vector<LayerRequirement>& layers, bool touchActive, bool idle, bool* touchConsidered) const EXCLUDES(mLock); // Returns all the refresh rates supported by the device. This won't change at runtime. Loading services/surfaceflinger/Scheduler/Scheduler.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -469,7 +469,7 @@ void Scheduler::notifyTouchEvent() { // that is currently on top. b/142507166 will give us this capability. std::lock_guard<std::mutex> lock(mFeatureStateLock); if (mLayerHistory) { // Layer History will be cleared based on RefreshRateConfigs::getRefreshRateForContentV2 // Layer History will be cleared based on RefreshRateConfigs::getBestRefreshRate mTouchTimer->reset(); Loading Loading @@ -582,19 +582,20 @@ HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType() { return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); } const bool touchActive = mTouchTimer && mFeatures.touch == TouchState::Active; const bool idle = mIdleTimer && mFeatures.idleTimer == TimerState::Expired; if (!mUseContentDetectionV2) { // As long as touch is active we want to be in performance mode. if (mTouchTimer && mFeatures.touch == TouchState::Active) { if (touchActive) { return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); } } // If timer has expired as it means there is no new content on the screen. if (mIdleTimer && mFeatures.idleTimer == TimerState::Expired) { if (idle) { return mRefreshRateConfigs.getMinRefreshRateByPolicy().getConfigId(); } if (!mUseContentDetectionV2) { // If content detection is off we choose performance as we don't know the content fps. if (mFeatures.contentDetectionV1 == ContentDetectionState::Off) { // NOTE: V1 always calls this, but this is not a default behavior for V2. Loading @@ -607,11 +608,8 @@ HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType() { } bool touchConsidered; const auto& ret = mRefreshRateConfigs .getRefreshRateForContentV2(mFeatures.contentRequirements, mTouchTimer && mFeatures.touch == TouchState::Active, const auto& ret = mRefreshRateConfigs .getBestRefreshRate(mFeatures.contentRequirements, touchActive, idle, &touchConsidered) .getConfigId(); if (touchConsidered) { Loading services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +260 −202 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -97,8 +97,8 @@ std::pair<nsecs_t, nsecs_t> RefreshRateConfigs::getDisplayFrames(nsecs_t layerPe return {displayFramesQuot, displayFramesRem}; } const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( const std::vector<LayerRequirement>& layers, bool touchActive, const RefreshRate& RefreshRateConfigs::getBestRefreshRate( const std::vector<LayerRequirement>& layers, bool touchActive, bool idle, bool* touchConsidered) const { ATRACE_CALL(); ALOGV("getRefreshRateForContent %zu layers", layers.size()); Loading @@ -106,14 +106,6 @@ const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( *touchConsidered = false; std::lock_guard lock(mLock); // If there are not layers, there is not content detection, so return the current // refresh rate. if (layers.empty()) { *touchConsidered = touchActive; return touchActive ? getMaxRefreshRateByPolicyLocked() : getCurrentRefreshRateByPolicyLocked(); } int noVoteLayers = 0; int minVoteLayers = 0; int maxVoteLayers = 0; Loading Loading @@ -143,6 +135,14 @@ const RefreshRate& RefreshRateConfigs::getRefreshRateForContentV2( return getMaxRefreshRateByPolicyLocked(); } if (!touchActive && idle) { return getMinRefreshRateByPolicyLocked(); } if (layers.empty()) { return getCurrentRefreshRateByPolicyLocked(); } // Only if all layers want Min we should return Min if (noVoteLayers + minVoteLayers == layers.size()) { return getMinRefreshRateByPolicyLocked(); Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +8 −6 Original line number Diff line number Diff line Loading @@ -212,12 +212,14 @@ public: const RefreshRate& getRefreshRateForContent(const std::vector<LayerRequirement>& layers) const EXCLUDES(mLock); // Returns the refresh rate that fits best to the given layers. This function also gets a // boolean flag that indicates whether user touched the screen recently to be factored in when // choosing the refresh rate and returns whether the refresh rate was chosen as a result of // a touch event. const RefreshRate& getRefreshRateForContentV2(const std::vector<LayerRequirement>& layers, bool touchActive, bool* touchConsidered) const // Returns the refresh rate that fits best to the given layers. // layers - The layer requirements to consider. // touchActive - Whether the user touched the screen recently. Used to apply touch boost. // idle - True if the system hasn't seen any buffers posted to layers recently. // touchConsidered - An output param that tells the caller whether the refresh rate was chosen // based on touch boost. const RefreshRate& getBestRefreshRate(const std::vector<LayerRequirement>& layers, bool touchActive, bool idle, bool* touchConsidered) const EXCLUDES(mLock); // Returns all the refresh rates supported by the device. This won't change at runtime. Loading
services/surfaceflinger/Scheduler/Scheduler.cpp +13 −15 Original line number Diff line number Diff line Loading @@ -469,7 +469,7 @@ void Scheduler::notifyTouchEvent() { // that is currently on top. b/142507166 will give us this capability. std::lock_guard<std::mutex> lock(mFeatureStateLock); if (mLayerHistory) { // Layer History will be cleared based on RefreshRateConfigs::getRefreshRateForContentV2 // Layer History will be cleared based on RefreshRateConfigs::getBestRefreshRate mTouchTimer->reset(); Loading Loading @@ -582,19 +582,20 @@ HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType() { return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); } const bool touchActive = mTouchTimer && mFeatures.touch == TouchState::Active; const bool idle = mIdleTimer && mFeatures.idleTimer == TimerState::Expired; if (!mUseContentDetectionV2) { // As long as touch is active we want to be in performance mode. if (mTouchTimer && mFeatures.touch == TouchState::Active) { if (touchActive) { return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); } } // If timer has expired as it means there is no new content on the screen. if (mIdleTimer && mFeatures.idleTimer == TimerState::Expired) { if (idle) { return mRefreshRateConfigs.getMinRefreshRateByPolicy().getConfigId(); } if (!mUseContentDetectionV2) { // If content detection is off we choose performance as we don't know the content fps. if (mFeatures.contentDetectionV1 == ContentDetectionState::Off) { // NOTE: V1 always calls this, but this is not a default behavior for V2. Loading @@ -607,11 +608,8 @@ HwcConfigIndexType Scheduler::calculateRefreshRateConfigIndexType() { } bool touchConsidered; const auto& ret = mRefreshRateConfigs .getRefreshRateForContentV2(mFeatures.contentRequirements, mTouchTimer && mFeatures.touch == TouchState::Active, const auto& ret = mRefreshRateConfigs .getBestRefreshRate(mFeatures.contentRequirements, touchActive, idle, &touchConsidered) .getConfigId(); if (touchConsidered) { Loading
services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +260 −202 File changed.Preview size limit exceeded, changes collapsed. Show changes