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

Commit fc48edc7 authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: do not clear contentRequirement when render rate changes

There is no need to clear the contentRequirement when only the render
rate changes.

Bug: 377240935
Flag: EXEMPT bugfix
Test: Running TouchLatency and expanding notification shade
Change-Id: I0ce9222958358a4eb87b244ed70430b3105e0396
parent 968c9ccb
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -436,7 +436,8 @@ void Scheduler::onHdcpLevelsChanged(Cycle cycle, PhysicalDisplayId displayId,

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-value" // b/369277774
bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRateMode& mode) {
bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRateMode& mode,
                                     bool clearContentRequirements) {
    const bool isPacesetter =
            FTL_FAKE_GUARD(kMainThreadContext,
                           (std::scoped_lock(mDisplayLock), displayId == mPacesetterDisplayId));
@@ -445,10 +446,12 @@ bool Scheduler::onDisplayModeChanged(PhysicalDisplayId displayId, const FrameRat
        std::lock_guard<std::mutex> lock(mPolicyLock);
        mPolicy.emittedModeOpt = mode;

        if (clearContentRequirements) {
            // Invalidate content based refresh rate selection so it could be calculated
            // again for the new refresh rate.
            mPolicy.contentRequirements.clear();
        }
    }

    if (hasEventThreads()) {
        eventThreadFor(Cycle::Render).onModeChanged(mode);
+2 −1
Original line number Diff line number Diff line
@@ -151,7 +151,8 @@ public:
    void dispatchHotplugError(int32_t errorCode);

    // Returns true if the PhysicalDisplayId is the pacesetter.
    bool onDisplayModeChanged(PhysicalDisplayId, const FrameRateMode&) EXCLUDES(mPolicyLock);
    bool onDisplayModeChanged(PhysicalDisplayId, const FrameRateMode&,
                              bool clearContentRequirements) EXCLUDES(mPolicyLock);

    void enableSyntheticVsync(bool = true) REQUIRES(kMainThreadContext);
    void omitVsyncDispatching(bool) REQUIRES(kMainThreadContext);
+5 −3
Original line number Diff line number Diff line
@@ -1354,7 +1354,8 @@ void SurfaceFlinger::setDesiredMode(display::DisplayModeRequest&& desiredMode) {
            mScheduler->updatePhaseConfiguration(displayId, mode.fps);

            if (emitEvent) {
                mScheduler->onDisplayModeChanged(displayId, mode);
                mScheduler->onDisplayModeChanged(displayId, mode,
                                                 /*clearContentRequirements*/ false);
            }
            break;
        case DesiredModeAction::None:
@@ -1449,7 +1450,7 @@ void SurfaceFlinger::finalizeDisplayModeChange(PhysicalDisplayId displayId) {
    mScheduler->updatePhaseConfiguration(displayId, activeMode.fps);

    if (pendingModeOpt->emitEvent) {
        mScheduler->onDisplayModeChanged(displayId, activeMode);
        mScheduler->onDisplayModeChanged(displayId, activeMode, /*clearContentRequirements*/ true);
    }
}

@@ -7649,7 +7650,8 @@ status_t SurfaceFlinger::applyRefreshRateSelectorPolicy(
    ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str());

    if (const bool isPacesetter =
                mScheduler->onDisplayModeChanged(displayId, selector.getActiveMode())) {
                mScheduler->onDisplayModeChanged(displayId, selector.getActiveMode(),
                                                 /*clearContentRequirements*/ true)) {
        mDisplayModeController.updateKernelIdleTimer(displayId);
    }

+2 −2
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ TEST_F(SchedulerTest, emitModeChangeEvent) {
    const auto selectorPtr =
            std::make_shared<RefreshRateSelector>(kDisplay1Modes, kDisplay1Mode120->getId());
    mScheduler->registerDisplay(kDisplayId1, selectorPtr);
    mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120);
    mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120, true);

    mScheduler->setContentRequirements({kLayer});

@@ -250,7 +250,7 @@ TEST_F(SchedulerTest, emitModeChangeEvent) {
    EXPECT_CALL(*mEventThread, onModeChanged(kDisplay1Mode120_120)).Times(1);

    mScheduler->touchTimerCallback(TimerState::Reset);
    mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120);
    mScheduler->onDisplayModeChanged(kDisplayId1, kDisplay1Mode120_120, true);
}

TEST_F(SchedulerTest, calculateMaxAcquiredBufferCount) {