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

Commit 966600fb authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "WindowDecor1: Re-parent decor SurfaceControl to task's if detached." into main

parents 824af791 f56dfd6c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                globalExclusionRegion, mDesktopConfig.shouldSetBackground(taskInfo),
                inSyncWithTransition, forceReinflation);

        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, getLeash(), mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo

        mBgExecutor.execute(() -> mTaskOrganizer.applyTransaction(wct));
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class CarWindowDecoration extends WindowDecoration<WindowDecorLinearLayou

        updateRelayoutParams(mRelayoutParams, taskInfo, isCaptionVisible);

        relayout(mRelayoutParams, startT, finishT, wct, mRootView, mResult);
        relayout(mRelayoutParams, startT, finishT, wct, mRootView, getLeash(), mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
        mBgExecutor.execute(() -> mTaskOrganizer.applyTransaction(wct));

+8 −8
Original line number Diff line number Diff line
@@ -429,7 +429,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final boolean applyTransactionOnDraw = taskInfo.isFreeform();
        relayout(taskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                hasGlobalFocus, displayExclusionRegion, /* inSyncWithTransition= */ false,
                /* forceReinflation= */ false);
                /* forceReinflation= */ false, getLeash());
        if (!applyTransactionOnDraw) {
            t.apply();
        }
@@ -444,7 +444,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final boolean applyTransactionOnDraw = mTaskInfo.isFreeform();
        relayout(mTaskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                mHasGlobalFocus, mExclusionRegion, /* inSyncWithTransition= */ false,
                /* forceReinflation= */ true);
                /* forceReinflation= */ true, getLeash());
        if (!applyTransactionOnDraw) {
            t.apply();
        }
@@ -472,7 +472,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus, @NonNull Region displayExclusionRegion,
            boolean inSyncWithTransition, boolean forceReinflation) {
            boolean inSyncWithTransition, boolean forceReinflation, SurfaceControl taskSurface) {
        Trace.beginSection("DesktopModeWindowDecoration#relayout");

        if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue()) {
@@ -527,7 +527,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
        final WindowContainerTransaction wct = new WindowContainerTransaction();

        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, taskSurface, mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo

        if (!wct.isEmpty()) {
@@ -1309,7 +1309,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                mUserContext,
                mTransitions,
                mTaskInfo,
                mTaskSurface,
                getLeash(),
                mDisplayController,
                mTaskResourceLoader,
                mSurfaceControlTransactionSupplier,
@@ -1352,7 +1352,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    private void createResizeVeilIfNeeded() {
        if (mResizeVeil != null) return;
        mResizeVeil = new ResizeVeil(mContext, mDisplayController, mTaskResourceLoader,
                mMainDispatcher, mMainScope, mTaskSurface,
                mMainDispatcher, mMainScope, getLeash(),
                mSurfaceControlTransactionSupplier, mTaskInfo);
    }

@@ -1361,7 +1361,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    public void showResizeVeil(Rect taskBounds) {
        createResizeVeilIfNeeded();
        mResizeVeil.showVeil(mTaskSurface, taskBounds, mTaskInfo);
        mResizeVeil.showVeil(getLeash(), taskBounds, mTaskInfo);
    }

    /**
@@ -1369,7 +1369,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    public void showResizeVeil(SurfaceControl.Transaction tx, Rect taskBounds) {
        createResizeVeilIfNeeded();
        mResizeVeil.showVeil(tx, mTaskSurface, taskBounds, mTaskInfo, false /* fadeIn */);
        mResizeVeil.showVeil(tx, getLeash(), taskBounds, mTaskInfo, false /* fadeIn */);
    }

    /**
+12 −2
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    final @NonNull DisplayController mDisplayController;
    final @NonNull DesktopModeEventLogger mDesktopModeEventLogger;
    final ShellTaskOrganizer mTaskOrganizer;

    final Supplier<SurfaceControl> mSurfaceControlSupplier;
    final Supplier<SurfaceControl.Builder> mSurfaceControlBuilderSupplier;
    final Supplier<SurfaceControl.Transaction> mSurfaceControlTransactionSupplier;
    final Supplier<WindowContainerTransaction> mWindowContainerTransactionSupplier;
@@ -156,7 +158,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    public Context mDecorWindowContext;
    int mLayoutResId;
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public final SurfaceControl mTaskSurface;
    private SurfaceControl mTaskSurface;

    Display mDisplay;
    SurfaceControl mDecorationContainerSurface;
@@ -219,6 +221,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        mTaskInfo = taskInfo;
        mTaskSurface = cloneSurfaceControl(taskSurface, surfaceControlSupplier);
        mDesktopModeEventLogger = desktopModeEventLogger;
        mSurfaceControlSupplier = surfaceControlSupplier;
        mSurfaceControlBuilderSupplier = surfaceControlBuilderSupplier;
        mSurfaceControlTransactionSupplier = surfaceControlTransactionSupplier;
        mWindowContainerTransactionSupplier = windowContainerTransactionSupplier;
@@ -258,7 +261,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>

    void relayout(RelayoutParams params, SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT, WindowContainerTransaction wct, T rootView,
            RelayoutResult<T> outResult) {
            SurfaceControl newTaskSurface, RelayoutResult<T> outResult) {
        Trace.beginSection("WindowDecoration#relayout");
        outResult.reset();
        if (params.mRunningTaskInfo != null) {
@@ -269,6 +272,13 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        final int oldLayoutResId = mLayoutResId;
        mLayoutResId = params.mLayoutResId;

        if (mDecorationContainerSurface != null && newTaskSurface != null
                && !newTaskSurface.isSameSurface(mTaskSurface)) {
            mTaskSurface.release();
            mTaskSurface = cloneSurfaceControl(newTaskSurface, mSurfaceControlSupplier);
            startT.reparent(mDecorationContainerSurface, mTaskSurface);
        }

        if (!mTaskInfo.isVisible) {
            releaseViews(wct);
            if (params.mSetTaskVisibilityPositionAndCrop) {
+3 −2
Original line number Diff line number Diff line
@@ -75,8 +75,8 @@ private constructor(
        get() =
            when {
                defaultWindowDecor != null -> requireDefaultWindowDecor().taskSurface
                desktopWindowDecor != null -> requireDesktopWindowDecor().mTaskSurface
                captionWindowDecoration != null -> requireCaptionWindowDecor().mTaskSurface
                desktopWindowDecor != null -> requireDesktopWindowDecor().leash
                captionWindowDecoration != null -> requireCaptionWindowDecor().leash
                else -> error("Expected Non-null window decoration")
            }

@@ -264,6 +264,7 @@ private constructor(
                        displayExclusionRegion,
                        inSyncWithTransition,
                        /* forceReinflation= */ false,
                        taskSurface,
                    )
            }

Loading