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

Commit c2cf5526 authored by Su Hong Koo's avatar Su Hong Koo Committed by Android (Google) Code Review
Browse files

Merge "SF: Move pacesetter setting out of SF::onNewFrontInternalDisplay()" into main

parents 0dc11df1 99e76ce9
Loading
Loading
Loading
Loading
+36 −8
Original line number Diff line number Diff line
@@ -1008,6 +1008,14 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
    // initialize our drawing state
    mDrawingState = mCurrentState;

    if (FlagManager::getInstance().pacesetter_selection()) {
        // No need to trigger update for pacesetter via Scheduler::setPacesetterDisplay() as it is
        // done as part of adding the `display` in initScheduler().

        const auto pacesetter = getPacesetterDisplayLocked();
        applyRefreshRateSelectorPolicy(pacesetter->getPhysicalId(),
                                       pacesetter->refreshRateSelector());
    }
    onNewFrontInternalDisplay(nullptr, *display);

    static_cast<void>(mScheduler->schedule(
@@ -4157,6 +4165,13 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken,
            }

            if (display->getPhysicalId() == mFrontInternalDisplayId) {
                if (FlagManager::getInstance().pacesetter_selection()) {
                    mScheduler->setPacesetterDisplay(mFrontInternalDisplayId);

                    const auto pacesetter = getPacesetterDisplayLocked();
                    applyRefreshRateSelectorPolicy(pacesetter->getPhysicalId(),
                                                   pacesetter->refreshRateSelector());
                }
                onNewFrontInternalDisplay(nullptr, *display);
            }
        }
@@ -5809,6 +5824,19 @@ void SurfaceFlinger::setPhysicalDisplayPowerMode(const sp<DisplayDevice>& displa
    }

    mScheduler->setDisplayPowerMode(displayId, mode);
    if (FlagManager::getInstance().pacesetter_selection()) {
        // TODO: b/389983418 - Update pacesetter designation inside
        // Scheduler::setDisplayPowerMode().
        mScheduler->setPacesetterDisplay(mFrontInternalDisplayId);

        // Whether or not the policy of the new pacesetter display changed while it was powered off
        // (in which case its preferred mode has already been propagated to HWC via setDesiredMode),
        // the Scheduler's emittedModeOpt must be initialized to the newly active mode, and the
        // kernel idle timer of the pacesetter display must be toggled.
        const auto pacesetter = getPacesetterDisplayLocked();
        applyRefreshRateSelectorPolicy(pacesetter->getPhysicalId(),
                                       pacesetter->refreshRateSelector());
    }

    ALOGD("Finished setting power mode %d on physical display %s", mode,
          to_string(displayId).c_str());
@@ -8447,17 +8475,17 @@ void SurfaceFlinger::onNewFrontInternalDisplay(const DisplayDevice* oldFrontInte
        }

        newFrontInternalDisplay.getCompositionDisplay()->setLayerCachingTexturePoolEnabled(true);
    }

        mScheduler->setPacesetterDisplay(mFrontInternalDisplayId);

    // Whether or not the policy of the new front internal display changed while it was powered off
    // (in which case its preferred mode has already been propagated to HWC via setDesiredMode), the
    // Scheduler's cachedModeChangedParams must be initialized to the newly active mode, and
    // the kernel idle timer of the front internal display must be toggled.
        // Whether or not the policy of the new front internal display changed while it was powered
        // off (in which case its preferred mode has already been propagated to HWC via
        // setDesiredMode), the Scheduler's emittedModeOpt must be initialized to the newly
        // active mode, and the kernel idle timer of the front internal display must be toggled.
        applyRefreshRateSelectorPolicy(mFrontInternalDisplayId,
                                       newFrontInternalDisplay.refreshRateSelector());
    }
}

status_t SurfaceFlinger::addWindowInfosListener(const sp<IWindowInfosListener>& windowInfosListener,
                                                gui::WindowInfosListenerInfo* outInfo) {