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

Commit 8662d356 authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge "SF Adds powerOnImminent to the GlobalSignals"

parents 185b900a 38c84988
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -280,6 +280,15 @@ auto RefreshRateConfigs::getBestRefreshRateLocked(const std::vector<LayerRequire
    ATRACE_CALL();
    ATRACE_CALL();
    ALOGV("%s: %zu layers", __func__, layers.size());
    ALOGV("%s: %zu layers", __func__, layers.size());


    const auto& activeMode = *getActiveModeItLocked()->second;

    // Keep the display at max refresh rate for the duration of powering on the display.
    if (signals.powerOnImminent) {
        ALOGV("Power On Imminent");
        const auto& max = getMaxRefreshRateByPolicyLocked(activeMode.getGroup());
        return {max, GlobalSignals{.powerOnImminent = true}};
    }

    int noVoteLayers = 0;
    int noVoteLayers = 0;
    int minVoteLayers = 0;
    int minVoteLayers = 0;
    int maxVoteLayers = 0;
    int maxVoteLayers = 0;
@@ -326,7 +335,6 @@ auto RefreshRateConfigs::getBestRefreshRateLocked(const std::vector<LayerRequire


    const Policy* policy = getCurrentPolicyLocked();
    const Policy* policy = getCurrentPolicyLocked();
    const auto& defaultMode = mDisplayModes.get(policy->defaultMode)->get();
    const auto& defaultMode = mDisplayModes.get(policy->defaultMode)->get();
    const auto& activeMode = *getActiveModeItLocked()->second;


    // If the default mode group is different from the group of current mode,
    // If the default mode group is different from the group of current mode,
    // this means a layer requesting a seamed mode switch just disappeared and
    // this means a layer requesting a seamed mode switch just disappeared and
+5 −1
Original line number Original line Diff line number Diff line
@@ -185,9 +185,13 @@ public:
        bool touch = false;
        bool touch = false;
        // True if the system hasn't seen any buffers posted to layers recently.
        // True if the system hasn't seen any buffers posted to layers recently.
        bool idle = false;
        bool idle = false;
        // Whether the display is about to be powered on, or has been in PowerMode::ON
        // within the timeout of DisplayPowerTimer.
        bool powerOnImminent = false;


        bool operator==(GlobalSignals other) const {
        bool operator==(GlobalSignals other) const {
            return touch == other.touch && idle == other.idle;
            return touch == other.touch && idle == other.idle &&
                    powerOnImminent == other.powerOnImminent;
        }
        }
    };
    };


+5 −9
Original line number Original line Diff line number Diff line
@@ -704,17 +704,13 @@ auto Scheduler::chooseDisplayMode() -> std::pair<DisplayModePtr, GlobalSignals>


    const auto configs = holdRefreshRateConfigs();
    const auto configs = holdRefreshRateConfigs();


    // If Display Power is not in normal operation we want to be in performance mode. When coming
    const bool powerOnImminent = mDisplayPowerTimer &&
    // back to normal mode, a grace period is given with DisplayPowerTimer.
    if (mDisplayPowerTimer &&
            (mPolicy.displayPowerMode != hal::PowerMode::ON ||
            (mPolicy.displayPowerMode != hal::PowerMode::ON ||
         mPolicy.displayPowerTimer == TimerState::Reset)) {
             mPolicy.displayPowerTimer == TimerState::Reset);
        constexpr GlobalSignals kNoSignals;
        return {configs->getMaxRefreshRateByPolicy(), kNoSignals};
    }


    const GlobalSignals signals{.touch = mTouchTimer && mPolicy.touch == TouchState::Active,
    const GlobalSignals signals{.touch = mTouchTimer && mPolicy.touch == TouchState::Active,
                                .idle = mPolicy.idleTimer == TimerState::Expired};
                                .idle = mPolicy.idleTimer == TimerState::Expired,
                                .powerOnImminent = powerOnImminent};


    return configs->getBestRefreshRate(mPolicy.contentRequirements, signals);
    return configs->getBestRefreshRate(mPolicy.contentRequirements, signals);
}
}
+26 −0
Original line number Original line Diff line number Diff line
@@ -977,6 +977,32 @@ TEST_F(RefreshRateConfigsTest, scrollWhileWatching60fps_60_90) {
    EXPECT_EQ(kMode90, configs.getBestRefreshRate(layers));
    EXPECT_EQ(kMode90, configs.getBestRefreshRate(layers));
}
}


TEST_F(RefreshRateConfigsTest, powerOnImminentConsidered) {
    RefreshRateConfigs configs(kModes_60_90, kModeId60);

    auto [refreshRate, signals] = configs.getBestRefreshRate({}, {});
    EXPECT_FALSE(signals.powerOnImminent);
    EXPECT_EQ(kMode90, refreshRate);

    std::tie(refreshRate, signals) = configs.getBestRefreshRate({}, {.powerOnImminent = true});
    EXPECT_TRUE(signals.powerOnImminent);
    EXPECT_EQ(kMode90, refreshRate);

    std::vector<LayerRequirement> layers = {{.weight = 1.f}};
    auto& lr1 = layers[0];
    lr1.vote = LayerVoteType::ExplicitExactOrMultiple;
    lr1.desiredRefreshRate = 60_Hz;
    lr1.name = "60Hz ExplicitExactOrMultiple";

    std::tie(refreshRate, signals) = configs.getBestRefreshRate(layers, {.powerOnImminent = false});
    EXPECT_FALSE(signals.powerOnImminent);
    EXPECT_EQ(kMode60, refreshRate);

    std::tie(refreshRate, signals) = configs.getBestRefreshRate(layers, {.powerOnImminent = true});
    EXPECT_TRUE(signals.powerOnImminent);
    EXPECT_EQ(kMode90, refreshRate);
}

TEST_F(RefreshRateConfigsTest, touchConsidered) {
TEST_F(RefreshRateConfigsTest, touchConsidered) {
    RefreshRateConfigs configs(kModes_60_90, kModeId60);
    RefreshRateConfigs configs(kModes_60_90, kModeId60);