diff options
-rw-r--r-- | services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp | 10 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp | 33 |
2 files changed, 42 insertions, 1 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 9746076040..0234dbc3da 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -422,7 +422,15 @@ RefreshRate RefreshRateConfigs::getBestRefreshRateLocked( // actually increase the refresh rate over the normal selection. const RefreshRate& touchRefreshRate = getMaxRefreshRateByPolicyLocked(); - bool touchBoostForExplicitExact = explicitExact == 0 || mSupportsFrameRateOverride; + const bool touchBoostForExplicitExact = [&] { + if (mSupportsFrameRateOverride) { + // Enable touch boost if there are other layers besides exact + return explicitExact + noVoteLayers != layers.size(); + } else { + // Enable touch boost if there are no exact layers + return explicitExact == 0; + } + }(); if (globalSignals.touch && explicitDefaultVoteLayers == 0 && touchBoostForExplicitExact && bestRefreshRate->fps.lessThanWithMargin(touchRefreshRate.fps)) { setTouchConsidered(); diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp index d04a7d73c7..4e00e66523 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -144,6 +144,7 @@ protected: mConfig30DifferentGroup, mConfig25DifferentGroup, mConfig50}; + DisplayModes m60_120Device = {mConfig60, mConfig120}; // Expected RefreshRate objects RefreshRate mExpected60Config = {HWC_CONFIG_ID_60, mConfig60, Fps(60), @@ -1844,6 +1845,38 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_WritesCache) { ASSERT_FALSE(detaultSignals == lastInvocation->outSignalsConsidered); } +TEST_F(RefreshRateConfigsTest, getBestRefreshRate_ExplicitExactTouchBoost) { + auto refreshRateConfigs = + std::make_unique<RefreshRateConfigs>(m60_120Device, + /*currentConfigId=*/HWC_CONFIG_ID_60, + /*enableFrameRateOverride=*/true); + + auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}, + LayerRequirement{.weight = 0.5f}}; + auto& explicitExactLayer = layers[0]; + auto& explicitExactOrMultipleLayer = layers[1]; + + explicitExactOrMultipleLayer.vote = LayerVoteType::ExplicitExactOrMultiple; + explicitExactOrMultipleLayer.name = "ExplicitExactOrMultiple"; + explicitExactOrMultipleLayer.desiredRefreshRate = Fps(60); + + explicitExactLayer.vote = LayerVoteType::ExplicitExact; + explicitExactLayer.name = "ExplicitExact"; + explicitExactLayer.desiredRefreshRate = Fps(30); + + EXPECT_EQ(mExpected60Config, + refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); + EXPECT_EQ(mExpected120Config, + refreshRateConfigs->getBestRefreshRate(layers, {.touch = true, .idle = false})); + + explicitExactOrMultipleLayer.vote = LayerVoteType::NoVote; + + EXPECT_EQ(mExpected60Config, + refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false})); + EXPECT_EQ(mExpected60Config, + refreshRateConfigs->getBestRefreshRate(layers, {.touch = true, .idle = false})); +} + TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); |