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

Commit 12b90231 authored by Rachel Lee's avatar Rachel Lee
Browse files

DO_NOT_MERGE Fix primaryRangeIsSingleRate + touch on dVRR

Disable a primaryRangeIsSingleRate section on dVRR and allow late touch
boost to trigger when no layer score. On dVRR display, the primary
physical range may be a single rate,
but late touch boost should still be able to trigger.

Bug: 353142444
Bug: 362379874
Flag: EXEMPT_bugfix
Test: atest libsurfaceflinger_unittest
Test: Twitter scrolling with and without video, with policy backdoor
Test: notification shade scrolling with policy backdoor
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:7bedfbf0d7b106702a241a64a79c36205606496c)
Merged-In: Ic5b2b298fe0df357f77ef8f06b1fc0fc248e0498
Change-Id: Ic5b2b298fe0df357f77ef8f06b1fc0fc248e0498
parent 7027deaa
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -841,7 +841,8 @@ auto RefreshRateSelector::getRankedFrameRatesLocked(const std::vector<LayerRequi
        return score.overallScore == 0;
    });

    if (policy->primaryRangeIsSingleRate()) {
    // TODO(b/364651864): Evaluate correctness of primaryRangeIsSingleRate.
    if (!mIsVrrDevice.load() && policy->primaryRangeIsSingleRate()) {
        // If we never scored any layers, then choose the rate from the primary
        // range instead of picking a random score from the app range.
        if (noLayerScore) {
@@ -887,8 +888,8 @@ auto RefreshRateSelector::getRankedFrameRatesLocked(const std::vector<LayerRequi
        const auto touchRefreshRates = rankFrameRates(anchorGroup, RefreshRateOrder::Descending);
        using fps_approx_ops::operator<;

        if (scores.front().frameRateMode.fps < touchRefreshRates.front().frameRateMode.fps) {
            ALOGV("Touch Boost");
        if (scores.front().frameRateMode.fps <= touchRefreshRates.front().frameRateMode.fps) {
            ALOGV("Touch Boost [late]");
            ATRACE_FORMAT_INSTANT("%s (Touch Boost [late])",
                                  to_string(touchRefreshRates.front().frameRateMode.fps).c_str());
            return {touchRefreshRates, GlobalSignals{.touch = true}};
+39 −2
Original line number Diff line number Diff line
@@ -1766,6 +1766,43 @@ TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_withFrameRateCategory_60_12
    }
}

TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_vrrHighHintTouch_primaryRangeIsSingleRate) {
    if (GetParam() != Config::FrameRateOverride::Enabled) {
        return;
    }

    SET_FLAG_FOR_TEST(flags::vrr_config, true);

    auto selector = createSelector(kVrrMode_120, kModeId120);
    selector.setActiveMode(kModeId120, 60_Hz);

    // Change primary physical range to be single rate, which on VRR device should not affect
    // fps scoring.
    EXPECT_EQ(SetPolicyResult::Changed,
              selector.setDisplayManagerPolicy({kModeId120, {120_Hz, 120_Hz}}));

    std::vector<LayerRequirement> layers = {{.weight = 1.f}, {.weight = 1.f}};
    layers[0].vote = LayerVoteType::ExplicitCategory;
    layers[0].frameRateCategory = FrameRateCategory::HighHint;
    layers[0].name = "ExplicitCategory HighHint";

    auto actualRankedFrameRates = selector.getRankedFrameRates(layers);
    // Expect late touch boost from HighHint.
    EXPECT_EQ(120_Hz, actualRankedFrameRates.ranking.front().frameRateMode.fps);
    EXPECT_EQ(kModeId120, actualRankedFrameRates.ranking.front().frameRateMode.modePtr->getId());
    EXPECT_TRUE(actualRankedFrameRates.consideredSignals.touch);

    layers[1].vote = LayerVoteType::ExplicitExactOrMultiple;
    layers[1].desiredRefreshRate = 30_Hz;
    layers[1].name = "ExplicitExactOrMultiple 30Hz";

    actualRankedFrameRates = selector.getRankedFrameRates(layers);
    // Expect late touch boost from HighHint.
    EXPECT_EQ(120_Hz, actualRankedFrameRates.ranking.front().frameRateMode.fps);
    EXPECT_EQ(kModeId120, actualRankedFrameRates.ranking.front().frameRateMode.modePtr->getId());
    EXPECT_TRUE(actualRankedFrameRates.consideredSignals.touch);
}

TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_withFrameRateCategory_HighHint) {
    auto selector = createSelector(makeModes(kMode24, kMode30, kMode60, kMode120), kModeId60);

@@ -1884,7 +1921,7 @@ TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_withFrameRateCategory_HighH
    // Gets touch boost
    EXPECT_EQ(120_Hz, actualRankedFrameRates.ranking.front().frameRateMode.fps);
    EXPECT_EQ(kModeId120, actualRankedFrameRates.ranking.front().frameRateMode.modePtr->getId());
    EXPECT_FALSE(actualRankedFrameRates.consideredSignals.touch);
    EXPECT_TRUE(actualRankedFrameRates.consideredSignals.touch);
}

TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_withFrameRateCategory_TouchBoost) {
@@ -1978,7 +2015,7 @@ TEST_P(RefreshRateSelectorTest, getBestFrameRateMode_withFrameRateCategory_Touch
    lr2.name = "Max";
    actualRankedFrameRates = selector.getRankedFrameRates(layers, {.touch = true});
    EXPECT_FRAME_RATE_MODE(kMode120, 120_Hz, actualRankedFrameRates.ranking.front().frameRateMode);
    EXPECT_FALSE(actualRankedFrameRates.consideredSignals.touch);
    EXPECT_TRUE(actualRankedFrameRates.consideredSignals.touch);

    lr1.vote = LayerVoteType::ExplicitCategory;
    lr1.frameRateCategory = FrameRateCategory::Normal;