Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -225,7 +225,7 @@ float RefreshRateConfigs::calculateLayerScoreLocked(const LayerRequirement& laye // The layer frame rate is not a divider of the refresh rate, // 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 // there is a small penalty attached to the score to favor the frame rates // the exactly matches the display refresh rate or a multiple. // 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 * return calculateNonExactMatchingLayerScoreLocked(layer, refreshRate) * seamlessness * kNonExactMatchingPenalty; kNonExactMatchingPenalty; } } Loading services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +32 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); Loading Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -225,7 +225,7 @@ float RefreshRateConfigs::calculateLayerScoreLocked(const LayerRequirement& laye // The layer frame rate is not a divider of the refresh rate, // 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 // there is a small penalty attached to the score to favor the frame rates // the exactly matches the display refresh rate or a multiple. // 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 * return calculateNonExactMatchingLayerScoreLocked(layer, refreshRate) * seamlessness * kNonExactMatchingPenalty; kNonExactMatchingPenalty; } } Loading
services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +32 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); Loading