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

Commit a0858db6 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Remove fallback for outdated active display

Initialize mActiveDisplayId during boot. getDefaultDisplay's fallback is
then no longer needed, since mActiveDisplayId is an internal display, so
cannot be removed and become outdated.

Bug: 255635821
Flag: EXEMPT refactor
Test: Boot
Change-Id: Ifa1a1f679957e88788b1819ba117fda3f407430b
parent 8805c3ea
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -911,9 +911,11 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
    LOG_ALWAYS_FATAL_IF(!configureLocked(),
                        "Initial display configuration failed: HWC did not hotplug");

    mActiveDisplayId = getPrimaryDisplayIdLocked();

    // Commit primary display.
    sp<const DisplayDevice> display;
    if (const auto indexOpt = mCurrentState.getDisplayIndex(getPrimaryDisplayIdLocked())) {
    if (const auto indexOpt = mCurrentState.getDisplayIndex(mActiveDisplayId)) {
        const auto& displays = mCurrentState.displays;

        const auto& token = displays.keyAt(*indexOpt);
+2 −8
Original line number Diff line number Diff line
@@ -980,18 +980,12 @@ private:
        return nullptr;
    }

    // Returns the primary display or (for foldables) the active display, assuming that the inner
    // and outer displays have mutually exclusive power states.
    // Returns the primary display or (for foldables) the active display.
    sp<const DisplayDevice> getDefaultDisplayDeviceLocked() const REQUIRES(mStateLock) {
        return const_cast<SurfaceFlinger*>(this)->getDefaultDisplayDeviceLocked();
    }

    sp<DisplayDevice> getDefaultDisplayDeviceLocked() REQUIRES(mStateLock) {
        if (const auto display = getDisplayDeviceLocked(mActiveDisplayId)) {
            return display;
        }
        // The active display is outdated, so fall back to the primary display.
        mActiveDisplayId = getPrimaryDisplayIdLocked();
        return getDisplayDeviceLocked(mActiveDisplayId);
    }

@@ -1330,7 +1324,7 @@ private:

    display::PhysicalDisplays mPhysicalDisplays GUARDED_BY(mStateLock);

    // The inner or outer display for foldables, assuming they have mutually exclusive power states.
    // The inner or outer display for foldables, while unfolded or folded, respectively.
    std::atomic<PhysicalDisplayId> mActiveDisplayId;

    display::DisplayModeController mDisplayModeController;