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

Commit 8d8c48bd authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Make WindowContainer#mPendingTransaction optional" into main

parents c217e476 089c8193
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1994,6 +1994,12 @@ class Task extends TaskFragment {
        final boolean wasInMultiWindowMode = inMultiWindowMode();
        final boolean wasInPictureInPicture = inPinnedWindowingMode();
        super.onConfigurationChanged(newParentConfig);
        if (mDisplayContent == null) {
            // This should be initializing from Task.Builder. The onConfigurationChanged will be
            // called again when this task is attached to hierarchy. Early return here because the
            // following operations are no-op for a non-attached task.
            return;
        }
        // Only need to update surface size here since the super method will handle updating
        // surface position.
        updateSurfaceSize(getSyncTransaction());
+13 −7
Original line number Diff line number Diff line
@@ -202,8 +202,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    private int mLastLayer = 0;
    private SurfaceControl mLastRelativeToLayer = null;

    // TODO(b/132320879): Remove this from WindowContainers except DisplayContent.
    private final Transaction mPendingTransaction;
    private Transaction mPendingTransaction;

    /**
     * Windows that clients are waiting to have drawn.
@@ -358,7 +357,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    WindowContainer(WindowManagerService wms) {
        mWmService = wms;
        mTransitionController = mWmService.mAtmService.getTransitionController();
        mPendingTransaction = wms.mTransactionFactory.get();
        mSyncTransaction = wms.mTransactionFactory.get();
        mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, wms);
        mSurfaceFreezer = new SurfaceFreezer(this, wms);
@@ -580,6 +578,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    @Override
    public void onConfigurationChanged(Configuration newParentConfig) {
        super.onConfigurationChanged(newParentConfig);
        if (mParent == null) {
            // Avoid unnecessary surface operation before attaching to a parent.
            return;
        }
        updateSurfacePositionNonOrganized();
        scheduleAnimation();
        if (mOverlayHost != null) {
@@ -1074,8 +1076,9 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
            }
        }
        mDisplayContent = dc;
        if (dc != null && dc != this) {
        if (dc != null && dc != this && mPendingTransaction != null) {
            dc.getPendingTransaction().merge(mPendingTransaction);
            mPendingTransaction = null;
        }
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowContainer child = mChildren.get(i);
@@ -2922,14 +2925,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<

    @Override
    public Transaction getPendingTransaction() {
        final DisplayContent displayContent = getDisplayContent();
        if (displayContent != null && displayContent != this) {
            return displayContent.getPendingTransaction();
        final WindowContainer<?> dc = mDisplayContent;
        if (dc != null && dc.mPendingTransaction != null) {
            return dc.mPendingTransaction;
        }
        // This WindowContainer has not attached to a display yet or this is a DisplayContent, so we
        // let the caller to save the surface operations within the local mPendingTransaction.
        // If this is not a DisplayContent, we will merge it to the pending transaction of its
        // display once it attaches to it.
        if (mPendingTransaction == null) {
            mPendingTransaction = mWmService.mTransactionFactory.get();
        }
        return mPendingTransaction;
    }

+5 −4
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class WindowContainerTests extends WindowTestsBase {
    @Test
    public void testAddChildSetsSurfacePosition() {
        reset(mTransaction);
        try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) {
        try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) {
            WindowContainer child = new WindowContainer(mWm);
            child.setBounds(1, 1, 10, 10);

@@ -266,7 +266,7 @@ public class WindowContainerTests extends WindowTestsBase {
    @Test
    public void testRemoveImmediatelyClearsLastSurfacePosition() {
        reset(mTransaction);
        try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mWm)) {
        try (MockSurfaceBuildingContainer top = new MockSurfaceBuildingContainer(mDisplayContent)) {
            final WindowContainer<WindowContainer> child1 = new WindowContainer(mWm);
            child1.setBounds(1, 1, 10, 10);

@@ -1827,8 +1827,9 @@ public class WindowContainerTests extends WindowTestsBase {
            implements AutoCloseable {
        private final SurfaceSession mSession = new SurfaceSession();

        MockSurfaceBuildingContainer(WindowManagerService wm) {
            super(wm);
        MockSurfaceBuildingContainer(DisplayContent dc) {
            super(dc.mWmService);
            onDisplayChanged(dc);
        }

        static class MockSurfaceBuilder extends SurfaceControl.Builder {