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

Commit a7049a3b authored by Su Hong Koo's avatar Su Hong Koo
Browse files

SF: Avoid redundant pacesetter setting in SF::setPhysicalDisplayPowerMode

SurfaceFlinger::setPhysicalDisplayPowerMode() currently sets the front
internal display as pacesetter and invokes
SF::applyRefreshRateSelectorPolicy() every time. This is wasteful if the
pacesetter designation won't change.

This CL adds a check to the call to applyRefreshRateSelectorPolicy() and
Scheduler::setPacesetterDisplay() so that they are only invoked when
there's actual change to be made.

Flag: com.android.graphics.surfaceflinger.flags.pacesetter_selection
Bug: 389983418
Test: SetPhysicalDisplayPowerModeTest
Change-Id: Iac4b00fec08c5ae9b7aa97200d04194edd793348
parent c1c79a5d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5896,7 +5896,8 @@ void SurfaceFlinger::setPhysicalDisplayPowerMode(const sp<DisplayDevice>& displa
    }

    mScheduler->setDisplayPowerMode(displayId, mode);
    if (FlagManager::getInstance().pacesetter_selection()) {
    if (FlagManager::getInstance().pacesetter_selection() &&
        mScheduler->getPacesetterDisplayId() != mFrontInternalDisplayId) {
        // TODO: b/389983418 - Update pacesetter designation inside
        // Scheduler::setDisplayPowerMode().
        mScheduler->setPacesetterDisplay(mFrontInternalDisplayId);
+11 −0
Original line number Diff line number Diff line
@@ -334,6 +334,9 @@ using ExternalDisplayPowerCase =

class SetPhysicalDisplayPowerModeTest : public DisplayTransactionTest {
public:
    static constexpr bool kWithMockScheduler = false;
    SetPhysicalDisplayPowerModeTest() : DisplayTransactionTest(kWithMockScheduler) {}

    template <typename Case>
    void transitionDisplayCommon();
};
@@ -355,6 +358,14 @@ void SetPhysicalDisplayPowerModeTest::transitionDisplayCommon() {
    SET_FLAG_FOR_TEST(android::companion::virtualdevice::flags::correct_virtual_display_power_state,
                      true);
    SET_FLAG_FOR_TEST(flags::disable_synthetic_vsync_for_performance, true);
    SET_FLAG_FOR_TEST(flags::pacesetter_selection, true);

    const auto displayIdOpt = asPhysicalDisplayId(Case::Display::DISPLAY_ID::get());
    ASSERT_TRUE(displayIdOpt);
    injectMockScheduler(*displayIdOpt);
    // TODO: b/389983418 - Remove once the Scheduler is no longer dependent on front internal
    // display.
    mFlinger.mutableFrontInternalDisplayId() = *displayIdOpt;

    Case::Doze::setupComposerCallExpectations(this);
    auto display =