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

Commit 20c029ce authored by Ady Abraham's avatar Ady Abraham
Browse files

SurfaceFlinger: only ExplicitDefault can use appRequestRange

This change is limiting layers that are ExplicitExactOrMultiple from
using a refresh rate outside of the primary range. When these layers
are visible and there is an interaction with the device, we usually
change the refresh rate due to other layers that are animating. Letting
layers that are ExplicitExactOrMultiple to pick a refresh rate from the
extended appRequestRange results in refresh rate changes which are not
desired.

Bug: 159940172
Test: YouTube when the device the primary range is restricted
Change-Id: I6aa60c359d690a92342963cb14bdeece4e6d5c5f
parent f4beceb1
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -212,10 +212,8 @@ const RefreshRate& RefreshRateConfigs::getBestRefreshRate(
            bool inPrimaryRange =
            bool inPrimaryRange =
                    scores[i].first->inPolicy(policy->primaryRange.min, policy->primaryRange.max);
                    scores[i].first->inPolicy(policy->primaryRange.min, policy->primaryRange.max);
            if ((primaryRangeIsSingleRate || !inPrimaryRange) &&
            if ((primaryRangeIsSingleRate || !inPrimaryRange) &&
                !(layer.focused &&
                !(layer.focused && layer.vote == LayerVoteType::ExplicitDefault)) {
                  (layer.vote == LayerVoteType::ExplicitDefault ||
                // Only focused layers with ExplicitDefault frame rate settings are allowed to score
                   layer.vote == LayerVoteType::ExplicitExactOrMultiple))) {
                // Only focused layers with explicit frame rate settings are allowed to score
                // refresh rates outside the primary range.
                // refresh rates outside the primary range.
                continue;
                continue;
            }
            }
+3 −19
Original line number Original line Diff line number Diff line
@@ -1130,15 +1130,6 @@ TEST_F(RefreshRateConfigsTest,
    auto& lr = layers[0];
    auto& lr = layers[0];


    RefreshRateConfigs::GlobalSignals consideredSignals;
    RefreshRateConfigs::GlobalSignals consideredSignals;
    lr.vote = LayerVoteType::ExplicitExactOrMultiple;
    lr.desiredRefreshRate = 60.0f;
    lr.name = "60Hz ExplicitExactOrMultiple";
    lr.focused = true;
    EXPECT_EQ(mExpected60Config,
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = true, .idle = true},
                                                     &consideredSignals));
    EXPECT_EQ(false, consideredSignals.touch);

    lr.vote = LayerVoteType::ExplicitDefault;
    lr.vote = LayerVoteType::ExplicitDefault;
    lr.desiredRefreshRate = 60.0f;
    lr.desiredRefreshRate = 60.0f;
    lr.name = "60Hz ExplicitDefault";
    lr.name = "60Hz ExplicitDefault";
@@ -1162,13 +1153,6 @@ TEST_F(RefreshRateConfigsTest,
    auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
    auto layers = std::vector<LayerRequirement>{LayerRequirement{.weight = 1.0f}};
    auto& lr = layers[0];
    auto& lr = layers[0];


    lr.vote = LayerVoteType::ExplicitExactOrMultiple;
    lr.desiredRefreshRate = 90.0f;
    lr.name = "90Hz ExplicitExactOrMultiple";
    lr.focused = true;
    EXPECT_EQ(mExpected90Config,
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = true}));

    lr.vote = LayerVoteType::ExplicitDefault;
    lr.vote = LayerVoteType::ExplicitDefault;
    lr.desiredRefreshRate = 90.0f;
    lr.desiredRefreshRate = 90.0f;
    lr.name = "90Hz ExplicitDefault";
    lr.name = "90Hz ExplicitDefault";
@@ -1204,7 +1188,7 @@ TEST_F(RefreshRateConfigsTest,
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}));
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}));


    lr.focused = true;
    lr.focused = true;
    EXPECT_EQ(mExpected60Config,
    EXPECT_EQ(mExpected90Config,
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}));
              refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}));


    lr.vote = LayerVoteType::ExplicitDefault;
    lr.vote = LayerVoteType::ExplicitDefault;
@@ -1306,7 +1290,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) {
    EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Max, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Max, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Heuristic, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Heuristic, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f));
    EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f));


    // Layers not focused are not allowed to override primary config
    // Layers not focused are not allowed to override primary config
    EXPECT_EQ(HWC_CONFIG_ID_60,
    EXPECT_EQ(HWC_CONFIG_ID_60,
@@ -1321,7 +1305,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) {
    // When we're higher than the primary range max due to a layer frame rate setting, touch boost
    // When we're higher than the primary range max due to a layer frame rate setting, touch boost
    // shouldn't drag us back down to the primary range max.
    // shouldn't drag us back down to the primary range max.
    EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f, /*touch=*/true));
    EXPECT_EQ(HWC_CONFIG_ID_90, getFrameRate(LayerVoteType::ExplicitDefault, 90.f, /*touch=*/true));
    EXPECT_EQ(HWC_CONFIG_ID_90,
    EXPECT_EQ(HWC_CONFIG_ID_60,
              getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f, /*touch=*/true));
              getFrameRate(LayerVoteType::ExplicitExactOrMultiple, 90.f, /*touch=*/true));


    ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(
    ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(