Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76ec9fad authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: adjust kNonExactMatchingPenalty

Give a higher score to frame rates which exact matches by lowering
the scores for other refresh rates, to favor exact (or multiple)
matches when there are multiple refresh rate with a close value.

Bug: b/190578904
Test: SF unit tests
Change-Id: Ia14551e000ee1651a04ab580c4df2afcb2f8edeb
Merged-In: Ia14551e000ee1651a04ab580c4df2afcb2f8edeb
parent 03c02087
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,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;
}
+33 −0
Original line number Diff line number Diff line
@@ -2214,6 +2214,39 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_deviceWithCloseRefreshRates) {
    }
}

// b/190578904
TEST_F(RefreshRateConfigsTest, getBestRefreshRate_conflictingVotes) {
    const DisplayModes displayModes = {
            createDisplayMode(DisplayModeId(0), 0, Fps(43.0f).getPeriodNsecs()),
            createDisplayMode(DisplayModeId(1), 0, Fps(53.0f).getPeriodNsecs()),
            createDisplayMode(DisplayModeId(2), 0, Fps(55.0f).getPeriodNsecs()),
            createDisplayMode(DisplayModeId(3), 0, Fps(60.0f).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 = Fps(43.0f),
                    .seamlessness = Seamlessness::SeamedAndSeamless,
                    .weight = 0.41f,
            },
            LayerRequirement{
                    .vote = LayerVoteType::ExplicitExactOrMultiple,
                    .desiredRefreshRate = Fps(53.0f),
                    .seamlessness = Seamlessness::SeamedAndSeamless,
                    .weight = 0.41f,
            },
    };

    EXPECT_EQ(53,
              refreshRateConfigs->getBestRefreshRate(layers, globalSignals).getFps().getIntValue());
}

TEST_F(RefreshRateConfigsTest, testComparisonOperator) {
    EXPECT_TRUE(mExpected60Config < mExpected90Config);
    EXPECT_FALSE(mExpected60Config < mExpected60Config);