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

Commit cac4879c authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix flickering of screen resolution change with deferred updater

Before this change, the execution order from
DeferredDisplayUpdater#requestDisplayChangeTransition is:
1. startCollectOrQueue
2. onStartCollect.run()
3. reconfigureDisplayLocked
4. requestChangeTransitionIfNeeded(collect display)
5. setDisplaySyncMethod

WindowState#prepareSync with check the sync method in step 4,
so it still uses non-blast sync, which causes the display cutout
to not sync with display resize.

This change reorders 4 and 5, so the behavior will be the same
as ImmediateDisplayUpdater, i.e. the previous original behavior.

Also removed setAllReady to let setReady() be called for individual
display from WindowOrganizerController#startTransition ->
applyDisplayChangeIfNeeded. That avoids potential too-early-ready.
This is also to restore to previous original behavior.

Bug: 318679910
Test: DisplayContentDeferredUpdateTests
Test: Toggle screen resolution rapidly without flickering cutout.

Change-Id: I68385ec62c72e0b3afbefd808cc95cd6995ea542
parent 2376ab52
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -183,9 +183,6 @@ public class DeferredDisplayUpdater implements DisplayUpdater {
                        getCurrentDisplayChange(fromRotation, startBounds);
                mDisplayContent.mTransitionController.requestStartTransition(transition,
                        /* startTask= */ null, /* remoteTransition= */ null, displayChange);
                mDisplayContent.mTransitionController.setDisplaySyncMethod(displayChange,
                        mDisplayContent);
                transition.setAllReady();
            }
        });
    }
+11 −4
Original line number Diff line number Diff line
@@ -1636,12 +1636,19 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (configChanged) {
            mWaitingForConfig = true;
            if (mTransitionController.isShellTransitionsEnabled()) {
                final TransitionRequestInfo.DisplayChange change =
                        mTransitionController.isCollecting()
                final Rect startBounds = currentDisplayConfig.windowConfiguration.getBounds();
                final Rect endBounds = mTmpConfiguration.windowConfiguration.getBounds();
                final Transition transition = mTransitionController.getCollectingTransition();
                final TransitionRequestInfo.DisplayChange change = transition != null
                                ? null : new TransitionRequestInfo.DisplayChange(mDisplayId);
                if (change != null) {
                    change.setStartAbsBounds(currentDisplayConfig.windowConfiguration.getBounds());
                    change.setEndAbsBounds(mTmpConfiguration.windowConfiguration.getBounds());
                    change.setStartAbsBounds(startBounds);
                    change.setEndAbsBounds(endBounds);
                } else {
                    transition.setKnownConfigChanges(this, changes);
                    // A collecting transition is existed. The sync method must be set before
                    // collecting this display, so WindowState#prepareSync can use the sync method.
                    mTransitionController.setDisplaySyncMethod(startBounds, endBounds, this);
                }
                requestChangeTransitionIfNeeded(changes, change);
            } else if (mLastHasContent) {
+6 −1
Original line number Diff line number Diff line
@@ -634,11 +634,16 @@ class TransitionController {
    }

    /** Sets the sync method for the display change. */
    void setDisplaySyncMethod(@NonNull TransitionRequestInfo.DisplayChange displayChange,
    private void setDisplaySyncMethod(@NonNull TransitionRequestInfo.DisplayChange displayChange,
            @NonNull DisplayContent displayContent) {
        final Rect startBounds = displayChange.getStartAbsBounds();
        final Rect endBounds = displayChange.getEndAbsBounds();
        if (startBounds == null || endBounds == null) return;
        setDisplaySyncMethod(startBounds, endBounds, displayContent);
    }

    void setDisplaySyncMethod(@NonNull Rect startBounds, @NonNull Rect endBounds,
            @NonNull DisplayContent displayContent) {
        final int startWidth = startBounds.width();
        final int startHeight = startBounds.height();
        final int endWidth = endBounds.width();