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

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

Merge changes Id6800c30,I6c84b89d

* changes:
  SF: Activate boot display earlier
  SF: Avoid a few nullable sp<DisplayDevice> params
parents 1c7fec63 a39e32fd
Loading
Loading
Loading
Loading
+24 −30
Original line number Diff line number Diff line
@@ -871,7 +871,7 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
    // initialize our drawing state
    mDrawingState = mCurrentState;

    // set initial conditions (e.g. unblank default device)
    onActiveDisplayChangedLocked(nullptr, *display);
    initializeDisplays();

    mPowerAdvisor->init();
@@ -3394,7 +3394,7 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken,

            // TODO(b/175678251) Call a listener instead.
            if (currentState.physical->hwcDisplayId == getHwComposer().getPrimaryHwcDisplayId()) {
                updateInternalDisplayVsyncLocked(display);
                updateActiveDisplayVsyncLocked(*display);
            }
        }
        return;
@@ -3422,15 +3422,15 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken,
            display->setDisplaySize(currentState.width, currentState.height);

            if (display->getId() == mActiveDisplayId) {
                onActiveDisplaySizeChanged(display);
                onActiveDisplaySizeChanged(*display);
            }
        }
    }
}

void SurfaceFlinger::updateInternalDisplayVsyncLocked(const sp<DisplayDevice>& activeDisplay) {
void SurfaceFlinger::updateActiveDisplayVsyncLocked(const DisplayDevice& activeDisplay) {
    mVsyncConfiguration->reset();
    const Fps refreshRate = activeDisplay->getActiveMode().fps;
    const Fps refreshRate = activeDisplay.getActiveMode().fps;
    updatePhaseConfiguration(refreshRate);
    mRefreshRateStats->setRefreshRate(refreshRate);
}
@@ -5222,21 +5222,15 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
    if (!currentModeOpt || *currentModeOpt == hal::PowerMode::OFF) {
        // Turn on the display

        // Activate the display (which involves a modeset to the active mode):
        //     1) When the first (a.k.a. primary) display is powered on during boot.
        //     2) When the inner or outer display of a foldable is powered on. This condition relies
        //        on the above DisplayDevice::setPowerMode. If `display` and `activeDisplay` are the
        //        same display, then the `activeDisplay->isPoweredOn()` below is true, such that the
        //        display is not activated every time it is powered on.
        // Activate the display (which involves a modeset to the active mode) when the inner or
        // outer display of a foldable is powered on. This condition relies on the above
        // DisplayDevice::setPowerMode. If `display` and `activeDisplay` are the same display,
        // then the `activeDisplay->isPoweredOn()` below is true, such that the display is not
        // activated every time it is powered on.
        //
        // TODO(b/255635821): Remove the concept of active display.
        const bool activeDisplayChanged =
                isInternalDisplay && (!activeDisplay || !activeDisplay->isPoweredOn());

        static bool sPrimaryDisplay = true;
        if (sPrimaryDisplay || activeDisplayChanged) {
            onActiveDisplayChangedLocked(activeDisplay, display);
            sPrimaryDisplay = false;
        if (isInternalDisplay && (!activeDisplay || !activeDisplay->isPoweredOn())) {
            onActiveDisplayChangedLocked(activeDisplay.get(), *display);
        }

        // Keep uclamp in a separate syscall and set it before changing to RT due to b/190237315.
@@ -7535,35 +7529,35 @@ void SurfaceFlinger::sample() {
    mRegionSamplingThread->onCompositionComplete(mScheduler->getScheduledFrameTime());
}

void SurfaceFlinger::onActiveDisplaySizeChanged(const sp<const DisplayDevice>& activeDisplay) {
    mScheduler->onActiveDisplayAreaChanged(activeDisplay->getWidth() * activeDisplay->getHeight());
    getRenderEngine().onActiveDisplaySizeChanged(activeDisplay->getSize());
void SurfaceFlinger::onActiveDisplaySizeChanged(const DisplayDevice& activeDisplay) {
    mScheduler->onActiveDisplayAreaChanged(activeDisplay.getWidth() * activeDisplay.getHeight());
    getRenderEngine().onActiveDisplaySizeChanged(activeDisplay.getSize());
}

void SurfaceFlinger::onActiveDisplayChangedLocked(const sp<DisplayDevice>& inactiveDisplay,
                                                  const sp<DisplayDevice>& activeDisplay) {
void SurfaceFlinger::onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
                                                  const DisplayDevice& activeDisplay) {
    ATRACE_CALL();

    if (inactiveDisplay) {
        inactiveDisplay->getCompositionDisplay()->setLayerCachingTexturePoolEnabled(false);
    if (inactiveDisplayPtr) {
        inactiveDisplayPtr->getCompositionDisplay()->setLayerCachingTexturePoolEnabled(false);
    }

    mActiveDisplayId = activeDisplay->getPhysicalId();
    activeDisplay->getCompositionDisplay()->setLayerCachingTexturePoolEnabled(true);
    mActiveDisplayId = activeDisplay.getPhysicalId();
    activeDisplay.getCompositionDisplay()->setLayerCachingTexturePoolEnabled(true);

    updateInternalDisplayVsyncLocked(activeDisplay);
    updateActiveDisplayVsyncLocked(activeDisplay);
    mScheduler->setModeChangePending(false);
    mScheduler->setLeaderDisplay(mActiveDisplayId);

    onActiveDisplaySizeChanged(activeDisplay);
    mActiveDisplayTransformHint = activeDisplay->getTransformHint();
    mActiveDisplayTransformHint = activeDisplay.getTransformHint();

    // The policy of the new active/leader display may have changed while it was inactive. In that
    // case, its preferred mode has not been propagated to HWC (via setDesiredActiveMode). In either
    // case, the Scheduler's cachedModeChangedParams must be initialized to the newly active mode,
    // and the kernel idle timer of the newly active display must be toggled.
    constexpr bool kForce = true;
    applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay->refreshRateSelector(), kForce);
    applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay.refreshRateSelector(), kForce);
}

status_t SurfaceFlinger::addWindowInfosListener(
+4 −6
Original line number Diff line number Diff line
@@ -1049,13 +1049,11 @@ private:
    VirtualDisplayId acquireVirtualDisplay(ui::Size, ui::PixelFormat) REQUIRES(mStateLock);
    void releaseVirtualDisplay(VirtualDisplayId);

    // TODO(b/255635821): Replace pointers with references. `inactiveDisplay` is only ever `nullptr`
    // in tests, and `activeDisplay` must not be `nullptr` as a precondition.
    void onActiveDisplayChangedLocked(const sp<DisplayDevice>& inactiveDisplay,
                                      const sp<DisplayDevice>& activeDisplay)
    void onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
                                      const DisplayDevice& activeDisplay)
            REQUIRES(mStateLock, kMainThreadContext);

    void onActiveDisplaySizeChanged(const sp<const DisplayDevice>&);
    void onActiveDisplaySizeChanged(const DisplayDevice&);

    /*
     * Debugging & dumpsys
@@ -1121,7 +1119,7 @@ private:
                                               std::chrono::nanoseconds presentLatency);
    int getMaxAcquiredBufferCountForRefreshRate(Fps refreshRate) const;

    void updateInternalDisplayVsyncLocked(const sp<DisplayDevice>& activeDisplay)
    void updateActiveDisplayVsyncLocked(const DisplayDevice& activeDisplay)
            REQUIRES(mStateLock, kMainThreadContext);

    bool isHdrLayer(const frontend::LayerSnapshot& snapshot) const;
+6 −6
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ TEST_F(DisplayModeSwitchingTest, changeRefreshRate_OnActiveDisplay_WithRefreshRe
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(mDisplay);
    mFlinger.onActiveDisplayChanged(*mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), false, 0,
@@ -159,7 +159,7 @@ TEST_F(DisplayModeSwitchingTest, changeRefreshRate_OnActiveDisplay_WithoutRefres

    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());

    mFlinger.onActiveDisplayChanged(mDisplay);
    mFlinger.onActiveDisplayChanged(*mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), true, 0,
@@ -195,7 +195,7 @@ TEST_F(DisplayModeSwitchingTest, twoConsecutiveSetDesiredDisplayModeSpecs) {
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(mDisplay);
    mFlinger.onActiveDisplayChanged(*mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), false, 0,
@@ -238,7 +238,7 @@ TEST_F(DisplayModeSwitchingTest, changeResolution_OnActiveDisplay_WithoutRefresh
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(mDisplay);
    mFlinger.onActiveDisplayChanged(*mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90_4K.value(), false, 0,
@@ -315,7 +315,7 @@ TEST_F(DisplayModeSwitchingTest, multiDisplay) {
    EXPECT_EQ(innerDisplay->getActiveMode().modePtr->getId(), kModeId60);
    EXPECT_EQ(outerDisplay->getActiveMode().modePtr->getId(), kModeId120);

    mFlinger.onActiveDisplayChanged(innerDisplay);
    mFlinger.onActiveDisplayChanged(*innerDisplay);

    EXPECT_EQ(NO_ERROR,
              mFlinger.setDesiredDisplayModeSpecs(innerDisplay->getDisplayToken().promote(),
@@ -359,7 +359,7 @@ TEST_F(DisplayModeSwitchingTest, multiDisplay) {
    EXPECT_FALSE(outerDisplay->getDesiredActiveMode());
    EXPECT_EQ(outerDisplay->getActiveMode().modePtr->getId(), kModeId120);

    mFlinger.onActiveDisplayChanged(outerDisplay);
    mFlinger.onActiveDisplayChanged(*outerDisplay);

    // No transition on the inner display.
    EXPECT_FALSE(innerDisplay->getDesiredActiveMode());
+4 −8
Original line number Diff line number Diff line
@@ -404,13 +404,11 @@ TEST_F(SetPowerModeInternalTest, setPowerModeInternalDoesNothingIfVirtualDisplay
    EXPECT_EQ(PowerMode::ON, display.mutableDisplayDevice()->getPowerMode());
}

// TODO(b/262417075)
TEST_F(SetPowerModeInternalTest, DISABLED_transitionsDisplayFromOffToOnPrimaryDisplay) {
TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOffToOnPrimaryDisplay) {
    transitionDisplayCommon<PrimaryDisplayPowerCase<TransitionOffToOnVariant>>();
}

// TODO(b/262417075)
TEST_F(SetPowerModeInternalTest, DISABLED_transitionsDisplayFromOffToDozeSuspendPrimaryDisplay) {
TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOffToDozeSuspendPrimaryDisplay) {
    transitionDisplayCommon<PrimaryDisplayPowerCase<TransitionOffToDozeSuspendVariant>>();
}

@@ -446,13 +444,11 @@ TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOnToUnknownPrimaryDisplay
    transitionDisplayCommon<PrimaryDisplayPowerCase<TransitionOnToUnknownVariant>>();
}

// TODO(b/262417075)
TEST_F(SetPowerModeInternalTest, DISABLED_transitionsDisplayFromOffToOnExternalDisplay) {
TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOffToOnExternalDisplay) {
    transitionDisplayCommon<ExternalDisplayPowerCase<TransitionOffToOnVariant>>();
}

// TODO(b/262417075)
TEST_F(SetPowerModeInternalTest, DISABLED_transitionsDisplayFromOffToDozeSuspendExternalDisplay) {
TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOffToDozeSuspendExternalDisplay) {
    transitionDisplayCommon<ExternalDisplayPowerCase<TransitionOffToDozeSuspendVariant>>();
}

+1 −1
Original line number Diff line number Diff line
@@ -474,7 +474,7 @@ public:
        return mFlinger->setDesiredDisplayModeSpecs(displayToken, specs);
    }

    void onActiveDisplayChanged(const sp<DisplayDevice>& activeDisplay) {
    void onActiveDisplayChanged(const DisplayDevice& activeDisplay) {
        Mutex::Autolock lock(mFlinger->mStateLock);
        ftl::FakeGuard guard(kMainThreadContext);
        mFlinger->onActiveDisplayChangedLocked(nullptr, activeDisplay);