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

Commit 0f103e6c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update corner radius/shadow radius/box shadow only on transition-driven callback" into main

parents c6a5b344 01a387d6
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -252,7 +252,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
        } else {
            decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                    false /* setTaskCropAndPosition */,
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion);
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                    /* inSyncWithTransition= */ true);
        }
    }

@@ -266,7 +267,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT

        decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                false /* setTaskCropAndPosition */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion);
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                /* inSyncWithTransition= */ true);
    }

    @Override
@@ -362,7 +364,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
        windowDecoration.setTaskDragResizer(taskPositioner);
        windowDecoration.relayout(taskInfo, startT, finishT,
                false /* applyStartTransactionOnDraw */, false /* setTaskCropAndPosition */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion);
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                /* inSyncWithTransition= */ true);
    }

    private class CaptionTouchEventListener implements
+8 −4
Original line number Diff line number Diff line
@@ -208,7 +208,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        // synced with the buffer transaction (that draws the View). Both will be shown on screen
        // at the same, whereas applying them independently causes flickering. See b/270202228.
        relayout(taskInfo, t, t, true /* applyStartTransactionOnDraw */,
                shouldSetTaskVisibilityPositionAndCrop, hasGlobalFocus, displayExclusionRegion);
                shouldSetTaskVisibilityPositionAndCrop, hasGlobalFocus, displayExclusionRegion,
                /* inSyncWithTransition= */ false);
    }

    @VisibleForTesting
@@ -223,7 +224,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            InsetsState displayInsetsState,
            boolean hasGlobalFocus,
            @NonNull Region globalExclusionRegion,
            boolean shouldSetBackground) {
            boolean shouldSetBackground,
            boolean inSyncWithTransition) {
        relayoutParams.reset();
        relayoutParams.mRunningTaskInfo = taskInfo;
        relayoutParams.mLayoutResId = R.layout.caption_window_decor;
@@ -244,6 +246,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        relayoutParams.mIsCaptionVisible = taskInfo.isFreeform()
                || (isStatusBarVisible && !isKeyguardVisibleAndOccluded);
        relayoutParams.mDisplayExclusionRegion.set(globalExclusionRegion);
        relayoutParams.mInSyncWithTransition = inSyncWithTransition;

        if (TaskInfoKt.isTransparentCaptionBarAppearance(taskInfo)) {
            // If the app is requesting to customize the caption bar, allow input to fall
@@ -275,7 +278,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus,
            @NonNull Region globalExclusionRegion) {
            @NonNull Region globalExclusionRegion, boolean inSyncWithTransition) {
        final boolean isFreeform =
                taskInfo.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FREEFORM;
        final boolean isDragResizeable = ENABLE_WINDOWING_SCALED_RESIZING.isTrue()
@@ -289,7 +292,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
                shouldSetTaskVisibilityPositionAndCrop, mIsStatusBarVisible,
                mIsKeyguardVisibleAndOccluded,
                mDisplayController.getInsetsState(taskInfo.displayId), hasGlobalFocus,
                globalExclusionRegion, mDesktopConfig.shouldSetBackground(taskInfo));
                globalExclusionRegion, mDesktopConfig.shouldSetBackground(taskInfo),
                inSyncWithTransition);

        relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
        // After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
+4 −3
Original line number Diff line number Diff line
@@ -644,7 +644,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        } else {
            decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                    false /* shouldSetTaskPositionAndCrop */,
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion);
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                    /* inSyncWithTransition= */ true);
        }
    }

@@ -687,7 +688,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                false /* shouldSetTaskPositionAndCrop */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo),
                mExclusionRegion);
                mExclusionRegion, /* inSyncWithTransition= */ true);
    }

    @Override
@@ -1910,7 +1911,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        windowDecoration.relayout(taskInfo, startT, finishT,
                false /* applyStartTransactionOnDraw */, false /* shouldSetTaskPositionAndCrop */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo),
                mExclusionRegion);
                mExclusionRegion, /* inSyncWithTransition= */ true);
        if (!DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) {
            incrementEventReceiverTasks(taskInfo.displayId);
        }
+7 −4
Original line number Diff line number Diff line
@@ -414,7 +414,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        // causes flickering. See b/270202228.
        final boolean applyTransactionOnDraw = taskInfo.isFreeform();
        relayout(taskInfo, t, t, applyTransactionOnDraw, shouldSetTaskVisibilityPositionAndCrop,
                hasGlobalFocus, displayExclusionRegion);
                hasGlobalFocus, displayExclusionRegion, /* inSyncWithTransition= */ false);
        if (!applyTransactionOnDraw) {
            t.apply();
        }
@@ -440,7 +440,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    void relayout(ActivityManager.RunningTaskInfo taskInfo,
            SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT,
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus, @NonNull Region displayExclusionRegion) {
            boolean hasGlobalFocus, @NonNull Region displayExclusionRegion,
            boolean inSyncWithTransition) {
        Trace.beginSection("DesktopModeWindowDecoration#relayout");

        if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue()) {
@@ -479,7 +480,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                        && DesktopModeFlags
                        .ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX.isTrue(),
                mDesktopModeCompatPolicy.shouldExcludeCaptionFromAppBounds(taskInfo),
                mDesktopConfig);
                mDesktopConfig, inSyncWithTransition);

        final WindowDecorLinearLayout oldRootView = mResult.mRootView;
        final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
@@ -925,7 +926,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            @NonNull Region displayExclusionRegion,
            boolean shouldIgnoreCornerRadius,
            boolean shouldExcludeCaptionFromAppBounds,
            DesktopConfig desktopConfig) {
            DesktopConfig desktopConfig,
            boolean inSyncWithTransition) {
        final int captionLayoutId = getDesktopModeWindowDecorLayoutId(taskInfo.getWindowingMode());
        final boolean isAppHeader =
                captionLayoutId == R.layout.desktop_mode_app_header;
@@ -1086,6 +1088,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        }
        relayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw;
        relayoutParams.mSetTaskVisibilityPositionAndCrop = shouldSetTaskVisibilityPositionAndCrop;
        relayoutParams.mInSyncWithTransition = inSyncWithTransition;

        // The configuration used to layout the window decoration. A copy is made instead of using
        // the original reference so that the configuration isn't mutated on config changes and
+38 −23
Original line number Diff line number Diff line
@@ -529,6 +529,37 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
                    .setPosition(mTaskSurface, taskPosition.x, taskPosition.y);
        }

        if (params.mSetTaskVisibilityPositionAndCrop) {
            startT.show(mTaskSurface);
        }

        if (params.mShouldSetBackground) {
            final int backgroundColorInt = mTaskInfo.taskDescription != null
                    ? mTaskInfo.taskDescription.getBackgroundColor() : Color.BLACK;
            mTmpColor[0] = (float) Color.red(backgroundColorInt) / 255.f;
            mTmpColor[1] = (float) Color.green(backgroundColorInt) / 255.f;
            mTmpColor[2] = (float) Color.blue(backgroundColorInt) / 255.f;
            startT.setColor(mTaskSurface, mTmpColor);
        } else {
            startT.unsetColor(mTaskSurface);
        }

        updateTaskSurfaceOutline(params, startT, finishT, outResult);
    }

    private void updateTaskSurfaceOutline(
            RelayoutParams params, SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT, RelayoutResult<T> outResult) {
        if ((DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()
                || DesktopExperienceFlags.ENABLE_FREEFORM_BOX_SHADOWS.isTrue())
                && !params.mInSyncWithTransition) {
            // Update these outline properties only when the relayout is driven by Transition
            // callbacks because they must be updated together with some of other properties (e.g.,
            // position) which is set by transition handler although the outline properties are
            // expected to be set by WindowDecoration instead of the transition handler.
            return;
        }

        if (outResult.mBorderSettings != null
                && outResult.mBorderSettings.strokeWidth > 0) {
            startT.setBorderSettings(mTaskSurface, outResult.mBorderSettings);
@@ -546,34 +577,15 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
                startT.setShadowRadius(mTaskSurface, outResult.mShadowRadius);
                finishT.setShadowRadius(mTaskSurface, outResult.mShadowRadius);
            }
        } else {
            if (params.mShadowRadius != INVALID_SHADOW_RADIUS) {
                startT.setShadowRadius(mTaskSurface, params.mShadowRadius);
                finishT.setShadowRadius(mTaskSurface, params.mShadowRadius);
            }
        }

        if (params.mSetTaskVisibilityPositionAndCrop) {
            startT.show(mTaskSurface);
        }

        if (params.mShouldSetBackground) {
            final int backgroundColorInt = mTaskInfo.taskDescription != null
                    ? mTaskInfo.taskDescription.getBackgroundColor() : Color.BLACK;
            mTmpColor[0] = (float) Color.red(backgroundColorInt) / 255.f;
            mTmpColor[1] = (float) Color.green(backgroundColorInt) / 255.f;
            mTmpColor[2] = (float) Color.blue(backgroundColorInt) / 255.f;
            startT.setColor(mTaskSurface, mTmpColor);
        } else {
            startT.unsetColor(mTaskSurface);
        }

        if (DesktopExperienceFlags.ENABLE_DYNAMIC_RADIUS_COMPUTATION_BUGFIX.isTrue()) {
            if (outResult.mCornerRadius != INVALID_CORNER_RADIUS) {
                startT.setCornerRadius(mTaskSurface, outResult.mCornerRadius);
                finishT.setCornerRadius(mTaskSurface, outResult.mCornerRadius);
            }
        } else {
            if (params.mShadowRadius != INVALID_SHADOW_RADIUS) {
                startT.setShadowRadius(mTaskSurface, params.mShadowRadius);
                finishT.setShadowRadius(mTaskSurface, params.mShadowRadius);
            }
            if (params.mCornerRadius != INVALID_CORNER_RADIUS) {
                startT.setCornerRadius(mTaskSurface, params.mCornerRadius);
                finishT.setCornerRadius(mTaskSurface, params.mCornerRadius);
@@ -910,6 +922,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        boolean mShouldSetAppBounds;
        boolean mShouldSetBackground;

        boolean mInSyncWithTransition;

        void reset() {
            mLayoutResId = Resources.ID_NULL;
            mCaptionHeightCalculator = (ctx, display) -> 0;
@@ -941,6 +955,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            mHasGlobalFocus = false;
            mShouldSetAppBounds = false;
            mShouldSetBackground = false;
            mInSyncWithTransition = false;
        }

        boolean hasInputFeatureSpy() {
Loading