From 95df6a1ceb72675c6cbf03a1a4e86aeda4a4b59c Mon Sep 17 00:00:00 2001 From: Dominik Laskowski Date: Fri, 7 Oct 2022 18:11:07 -0400 Subject: SF: Remove DisplayModeSelectionParams Extract makeGlobalSignals instead. Inline getRankedDisplayModes. Bug: 241285191 Test: libsurfaceflinger_unittest Change-Id: Ic48ac3ad1bd9df6820c9c9e5f6384b8d15b38809 --- services/surfaceflinger/Scheduler/Scheduler.cpp | 42 ++++++++++--------------- services/surfaceflinger/Scheduler/Scheduler.h | 15 +-------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp index 7f04a4de85..8e710569c8 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.cpp +++ b/services/surfaceflinger/Scheduler/Scheduler.cpp @@ -766,16 +766,14 @@ std::vector Scheduler::getBestDisplayModeConfigs() const { std::vector 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 aggregatedScoresPerFps = @@ -812,34 +810,26 @@ std::vector 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, - .idle = mPolicy.idleTimer == TimerState::Expired, - .powerOnImminent = powerOnImminent}; - - return {mPolicy.contentRequirements, signals}; -} - -auto Scheduler::getRankedDisplayModes() - -> std::pair, GlobalSignals> { - ATRACE_CALL(); - - const auto configs = holdRefreshRateConfigs(); - - const auto displayModeSelectionParams = getDisplayModeSelectionParams(); - return configs->getRankedRefreshRates(displayModeSelectionParams.layerRequirements, - displayModeSelectionParams.globalSignals); + return {.touch = mTouchTimer && mPolicy.touch == TouchState::Active, + .idle = mPolicy.idleTimer == TimerState::Expired, + .powerOnImminent = powerOnImminent}; } DisplayModePtr Scheduler::getPreferredDisplayMode() { std::lock_guard 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; } diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h index d6f62ca898..f104e4581d 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.h +++ b/services/surfaceflinger/Scheduler/Scheduler.h @@ -116,12 +116,6 @@ struct AggregatedFpsScore { size_t numDisplays; }; -// Represents LayerRequirements and GlobalSignals to be considered for the display mode selection. -struct DisplayModeSelectionParams { - std::vector layerRequirements; - GlobalSignals globalSignals; -}; - // Represents the RefreshRateRankings and GlobalSignals for the selected RefreshRateRankings. struct RefreshRateRankingsAndSignals { std::vector refreshRateRankings; @@ -303,11 +297,6 @@ private: template 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, GlobalSignals> getRankedDisplayModes() - REQUIRES(mPolicyLock); - // Returns the best display mode per display. std::vector getBestDisplayModeConfigs() const REQUIRES(mPolicyLock); @@ -315,9 +304,7 @@ private: std::vector getDisplayModeConfigsForTheChosenFps( Fps chosenFps, const std::vector&) 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); -- cgit v1.2.3-59-g8ed1b