diff options
| -rw-r--r-- | services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 71d563130e..3331185caa 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -225,7 +225,7 @@ float RefreshRateConfigs::calculateLayerScoreLocked(const LayerRequirement& laye // The layer frame rate is not a divider of the refresh rate, // there is a small penalty attached to the score to favor the frame rates // the exactly matches the display refresh rate or a multiple. - constexpr float kNonExactMatchingPenalty = 0.99f; + constexpr float kNonExactMatchingPenalty = 0.95f; return calculateNonExactMatchingLayerScoreLocked(layer, refreshRate) * seamlessness * kNonExactMatchingPenalty; } diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp index 98746bcd21..2bafabddf3 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -1986,6 +1986,38 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_deviceWithCloseRefreshRates) { } } +// b/190578904 +TEST_F(RefreshRateConfigsTest, getBestRefreshRate_conflictingVotes) { + const DisplayModes displayModes = { + createDisplayMode(DisplayModeId(0), 0, (43_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(1), 0, (53_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(2), 0, (55_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(3), 0, (60_Hz).getPeriodNsecs()), + }; + + const RefreshRateConfigs::GlobalSignals globalSignals = {.touch = false, .idle = false}; + auto refreshRateConfigs = + std::make_unique<RefreshRateConfigs>(displayModes, + /*currentConfigId=*/displayModes[0]->getId()); + + const auto layers = std::vector<LayerRequirement>{ + LayerRequirement{ + .vote = LayerVoteType::ExplicitDefault, + .desiredRefreshRate = 43_Hz, + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + LayerRequirement{ + .vote = LayerVoteType::ExplicitExactOrMultiple, + .desiredRefreshRate = 53_Hz, + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + }; + + EXPECT_EQ(53_Hz, refreshRateConfigs->getBestRefreshRate(layers, globalSignals).getFps()); +} + TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); |