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

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

Merge "[PiP2] Use PipSurfaceTransactionHelper instead of Transaction API directly" into main

parents e4de0e23 4129f808
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public abstract class Pip2Module {
    @WMSingleton
    @Provides
    static PipTransition providePipTransition(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            @NonNull ShellInit shellInit,
            @NonNull ShellTaskOrganizer shellTaskOrganizer,
            @NonNull Transitions transitions,
@@ -99,7 +100,8 @@ public abstract class Pip2Module {
            PipDesktopState pipDesktopState,
            Optional<DesktopPipTransitionController> desktopPipTransitionController,
            PipInteractionHandler pipInteractionHandler) {
        return new PipTransition(context, shellInit, shellTaskOrganizer, transitions,
        return new PipTransition(context, pipSurfaceTransactionHelper, shellInit,
                shellTaskOrganizer, transitions,
                pipBoundsState, null, pipBoundsAlgorithm, pipTaskListener,
                pipScheduler, pipStackListenerController, pipDisplayLayoutState,
                pipUiStateChangeController, displayController, splitScreenControllerOptional,
@@ -154,6 +156,7 @@ public abstract class Pip2Module {
    @WMSingleton
    @Provides
    static PipScheduler providePipScheduler(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            PipBoundsState pipBoundsState,
            @ShellMainThread ShellExecutor mainExecutor,
            PipTransitionState pipTransitionState,
@@ -161,7 +164,8 @@ public abstract class Pip2Module {
            Optional<DesktopPipTransitionController> desktopPipTransitionController,
            PipDesktopState pipDesktopState,
            DisplayController displayController) {
        return new PipScheduler(context, pipBoundsState, mainExecutor, pipTransitionState,
        return new PipScheduler(context, pipSurfaceTransactionHelper, pipBoundsState, mainExecutor,
                pipTransitionState,
                splitScreenControllerOptional, desktopPipTransitionController, pipDesktopState,
                displayController);
    }
@@ -186,6 +190,7 @@ public abstract class Pip2Module {
    @WMSingleton
    @Provides
    static PipTouchHandler providePipTouchHandler(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            ShellInit shellInit,
            ShellCommandHandler shellCommandHandler,
            PhonePipMenuController menuPhoneController,
@@ -203,7 +208,8 @@ public abstract class Pip2Module {
            @ShellMainThread ShellExecutor mainExecutor,
            Optional<PipPerfHintController> pipPerfHintControllerOptional,
            PipDisplayTransferHandler pipDisplayTransferHandler) {
        return new PipTouchHandler(context, shellInit, shellCommandHandler, menuPhoneController,
        return new PipTouchHandler(context, pipSurfaceTransactionHelper, shellInit,
                shellCommandHandler, menuPhoneController,
                pipBoundsAlgorithm, pipBoundsState, pipTransitionState, pipScheduler,
                sizeSpecSource, pipDisplayLayoutState, pipDesktopState, displayController,
                pipMotionHelper, floatingContentCoordinator, pipUiEventLogger, mainExecutor,
+8 −0
Original line number Diff line number Diff line
@@ -40,6 +40,14 @@ public class PipSurfaceTransactionHelper {
        mShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_shadow_radius);
    }

    /**
     * Gets corner radius which is loaded from resources.
     * @return the corner radius.
     */
    public int getCornerRadius() {
        return mCornerRadius;
    }

    /**
     * Operates the scale (setMatrix) on a given transaction and leash
     * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
+6 −8
Original line number Diff line number Diff line
@@ -53,9 +53,6 @@ public class PipAlphaAnimator extends ValueAnimator {
    private final SurfaceControl.Transaction mFinishTransaction;

    private final int mDirection;
    private final int mCornerRadius;
    private final int mShadowRadius;

    private final Animator.AnimatorListener mAnimatorListener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
@@ -99,8 +96,10 @@ public class PipAlphaAnimator extends ValueAnimator {

    @NonNull private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
            mSurfaceControlTransactionFactory;
    @NonNull private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;

    public PipAlphaAnimator(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            SurfaceControl leash,
            SurfaceControl.Transaction startTransaction,
            SurfaceControl.Transaction finishTransaction,
@@ -108,6 +107,7 @@ public class PipAlphaAnimator extends ValueAnimator {
        mLeash = leash;
        mStartTransaction = startTransaction;
        mFinishTransaction = finishTransaction;
        mSurfaceTransactionHelper = pipSurfaceTransactionHelper;

        mDirection = direction;
        setFloatValues(getStartAlphaValue(), getEndAlphaValue());
@@ -115,8 +115,6 @@ public class PipAlphaAnimator extends ValueAnimator {
                new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory();
        final int enterAnimationDuration = context.getResources()
                .getInteger(R.integer.config_pipEnterAnimationDuration);
        mCornerRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
        mShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_shadow_radius);
        setDuration(enterAnimationDuration);
        addListener(mAnimatorListener);
        addUpdateListener(mAnimatorUpdateListener);
@@ -132,9 +130,9 @@ public class PipAlphaAnimator extends ValueAnimator {

    private void onAlphaAnimationUpdate(float alpha, SurfaceControl.Transaction tx) {
        // only set shadow radius on fade in
        tx.setAlpha(mLeash, alpha)
                .setCornerRadius(mLeash, mCornerRadius)
                .setShadowRadius(mLeash, mDirection == FADE_IN ? mShadowRadius : 0f);
        tx.setAlpha(mLeash, alpha);
        mSurfaceTransactionHelper.round(tx, mLeash, true /* applyCornerRadius */);
        mSurfaceTransactionHelper.shadow(tx, mLeash, mDirection == FADE_IN /* applyCornerRadius */);
        tx.apply();
    }

+6 −6
Original line number Diff line number Diff line
@@ -52,9 +52,6 @@ public class PipEnterAnimator extends ValueAnimator {
    private final SurfaceControl.Transaction mStartTransaction;
    private final SurfaceControl.Transaction mFinishTransaction;

    private final int mCornerRadius;
    private final int mShadowRadius;

    // Bounds updated by the evaluator as animator is running.
    private final Rect mAnimatedRect = new Rect();

@@ -113,7 +110,10 @@ public class PipEnterAnimator extends ValueAnimator {
        }
    };

    private final @NonNull PipSurfaceTransactionHelper mSurfaceTransactionHelper;

    public PipEnterAnimator(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            @NonNull SurfaceControl leash,
            SurfaceControl.Transaction startTransaction,
            SurfaceControl.Transaction finishTransaction,
@@ -128,11 +128,10 @@ public class PipEnterAnimator extends ValueAnimator {
        mSurfaceControlTransactionFactory =
                new PipSurfaceTransactionHelper.VsyncSurfaceControlTransactionFactory();
        mPipAppIconOverlaySupplier = this::getAppIconOverlay;
        mSurfaceTransactionHelper = pipSurfaceTransactionHelper;

        final int enterAnimationDuration = context.getResources()
                .getInteger(R.integer.config_pipEnterAnimationDuration);
        mCornerRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
        mShadowRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_shadow_radius);
        setDuration(enterAnimationDuration);
        setFloatValues(0f, 1f);
        setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
@@ -182,7 +181,8 @@ public class PipEnterAnimator extends ValueAnimator {
        mTransformTensor.postRotate(degrees);
        tx.setMatrix(mLeash, mTransformTensor, mMatrixTmp);

        tx.setCornerRadius(mLeash, mCornerRadius).setShadowRadius(mLeash, mShadowRadius);
        mSurfaceTransactionHelper.round(tx, mLeash, true /* applyCornerRadius */);
        mSurfaceTransactionHelper.shadow(tx, mLeash, true /* applyShadow */);

        if (mContentOverlay != null) {
            mContentOverlay.onAnimationUpdate(tx, 1f / scaleX, fraction, mEndBounds);
+3 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class PipExpandAnimator extends ValueAnimator {
            mSurfaceControlTransactionFactory;
    private final RectEvaluator mRectEvaluator;
    private final RectEvaluator mInsetEvaluator;
    private final PipSurfaceTransactionHelper mPipSurfaceTransactionHelper;
    private @NonNull final PipSurfaceTransactionHelper mPipSurfaceTransactionHelper;

    private final Animator.AnimatorListener mAnimatorListener = new AnimatorListenerAdapter() {
        @Override
@@ -106,6 +106,7 @@ public class PipExpandAnimator extends ValueAnimator {
            };

    public PipExpandAnimator(Context context,
            @NonNull PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
            @NonNull SurfaceControl leash,
            SurfaceControl.Transaction startTransaction,
            SurfaceControl.Transaction finishTransaction,
@@ -124,7 +125,7 @@ public class PipExpandAnimator extends ValueAnimator {
        mEndBounds.set(endBounds);
        mRectEvaluator = new RectEvaluator(mAnimatedRect);
        mInsetEvaluator = new RectEvaluator(new Rect());
        mPipSurfaceTransactionHelper = new PipSurfaceTransactionHelper(context);
        mPipSurfaceTransactionHelper = pipSurfaceTransactionHelper;
        mRotation = rotation;
        mIsPipInDesktopMode = isPipInDesktopMode;

Loading