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

Commit b05ee3a0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF: Remove DisplayModeSelectionParams"

parents a76c09ad 95df6a1c
Loading
Loading
Loading
Loading
+16 −26
Original line number Diff line number Diff line
@@ -726,16 +726,14 @@ std::vector<DisplayModeConfig> Scheduler::getBestDisplayModeConfigs() const {
    std::vector<RefreshRateRankingsAndSignals> refreshRateRankingsAndSignalsPerDisplay;
    refreshRateRankingsAndSignalsPerDisplay.reserve(mDisplays.size());

    const auto displayModeSelectionParams = getDisplayModeSelectionParams();
    for (const auto& [id, display] : mDisplays) {
        const auto [rankings, signals] =
                display->holdRefreshRateConfigs()
                        ->getRankedRefreshRates(mPolicy.contentRequirements, makeGlobalSignals());

    std::for_each(mDisplays.begin(), mDisplays.end(), [&](const auto& display) {
        const auto& [refreshRateRankings, globalSignals] =
                display.second->holdRefreshRateConfigs()
                        ->getRankedRefreshRates(displayModeSelectionParams.layerRequirements,
                                                displayModeSelectionParams.globalSignals);
        refreshRateRankingsAndSignalsPerDisplay.emplace_back(
                RefreshRateRankingsAndSignals{refreshRateRankings, globalSignals});
    });
                RefreshRateRankingsAndSignals{rankings, signals});
    }

    // FPS and their Aggregated score.
    std::unordered_map<Fps, AggregatedFpsScore, FpsHash, FpsApproxEqual> aggregatedScoresPerFps =
@@ -772,34 +770,26 @@ std::vector<DisplayModeConfig> Scheduler::getDisplayModeConfigsForTheChosenFps(
    return displayModeConfigs;
}

DisplayModeSelectionParams Scheduler::getDisplayModeSelectionParams() const {
GlobalSignals Scheduler::makeGlobalSignals() const {
    const bool powerOnImminent = mDisplayPowerTimer &&
            (mPolicy.displayPowerMode != hal::PowerMode::ON ||
             mPolicy.displayPowerTimer == TimerState::Reset);

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

    return {mPolicy.contentRequirements, signals};
}

auto Scheduler::getRankedDisplayModes()
        -> std::pair<std::vector<RefreshRateRanking>, GlobalSignals> {
    ATRACE_CALL();

    const auto configs = holdRefreshRateConfigs();

    const auto displayModeSelectionParams = getDisplayModeSelectionParams();
    return configs->getRankedRefreshRates(displayModeSelectionParams.layerRequirements,
                                          displayModeSelectionParams.globalSignals);
}

DisplayModePtr Scheduler::getPreferredDisplayMode() {
    std::lock_guard<std::mutex> lock(mPolicyLock);
    // Make sure the stored mode is up to date.
    if (mPolicy.mode) {
        mPolicy.mode = getRankedDisplayModes().first.front().displayModePtr;
        const auto configs = holdRefreshRateConfigs();
        const auto rankings =
                configs->getRankedRefreshRates(mPolicy.contentRequirements, makeGlobalSignals())
                        .first;

        mPolicy.mode = rankings.front().displayModePtr;
    }
    return mPolicy.mode;
}
+1 −14
Original line number Diff line number Diff line
@@ -115,12 +115,6 @@ struct AggregatedFpsScore {
    size_t numDisplays;
};

// Represents LayerRequirements and GlobalSignals to be considered for the display mode selection.
struct DisplayModeSelectionParams {
    std::vector<RefreshRateConfigs::LayerRequirement> layerRequirements;
    GlobalSignals globalSignals;
};

// Represents the RefreshRateRankings and GlobalSignals for the selected RefreshRateRankings.
struct RefreshRateRankingsAndSignals {
    std::vector<RefreshRateRanking> refreshRateRankings;
@@ -296,11 +290,6 @@ private:
    template <typename S, typename T>
    GlobalSignals applyPolicy(S Policy::*, T&&) EXCLUDES(mPolicyLock);

    // Returns the list of display modes in descending order of their priority that fulfills the
    // policy, and the signals that were considered.
    std::pair<std::vector<RefreshRateRanking>, GlobalSignals> getRankedDisplayModes()
            REQUIRES(mPolicyLock);

    // Returns the best display mode per display.
    std::vector<DisplayModeConfig> getBestDisplayModeConfigs() const REQUIRES(mPolicyLock);

@@ -308,9 +297,7 @@ private:
    std::vector<DisplayModeConfig> getDisplayModeConfigsForTheChosenFps(
            Fps chosenFps, const std::vector<RefreshRateRankingsAndSignals>&) const;

    // Returns the DisplayModeSelectionParams to be considered for the
    // DisplayMode selection based on the current Policy and GlobalSignals.
    DisplayModeSelectionParams getDisplayModeSelectionParams() const REQUIRES(mPolicyLock);
    GlobalSignals makeGlobalSignals() const REQUIRES(mPolicyLock);

    bool updateFrameRateOverrides(GlobalSignals, Fps displayRefreshRate) REQUIRES(mPolicyLock);