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

Commit 427778b0 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Show pip until drawn with entering bounds if rotation changes

The request transition may be a CHANGE type for display rotation,
So augmentRequest is unable to set the entering bounds at the
request stage. And when the CHANGE transition is ready, it includes
the entering pip info. Then the entering bounds will be applied at
the end of enter animation, which could cause to flicker because
the redraw of app configuration. The case only happens with type
ANIM_TYPE_ALPHA (i.e. swipe enter non-auto pip) because there
won't have pip overlay. Note that pip overlay is not a good option
for ANIM_TYPE_ALPHA because the non-opaque alpha is applied on task,
it will be ugly that both overlay and app content are visible.

So just simply keep the pip task invisible until it is redraw with
the entering bounds, and then play fade-in animation when the
drawn transaction is committed.

Bug: 342071665
Test: Swipe entering a non-auto pip activity.
      The pip activity should not flicker during the
      fade-in animation.

Change-Id: Idd6a7f8b70c0e28cc570af77c72f3b9e1a997f72
parent b0f4faad
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -464,6 +464,14 @@ public class PipTransition extends PipTransitionController {
                    // activity windowing mode, and set the task bounds to the final bounds
                    wct.setActivityWindowingMode(taskInfo.token, WINDOWING_MODE_UNDEFINED);
                    wct.setBounds(taskInfo.token, destinationBounds);
                    // If the animation is only used to apply destination bounds immediately and
                    // invisibly, then reshow it until the pip is drawn with the bounds.
                    final PipAnimationController.PipTransitionAnimator<?> animator =
                            mPipAnimationController.getCurrentAnimator();
                    if (animator != null && animator.getEndValue().equals(0f)) {
                        tx.addTransactionCommittedListener(mTransitions.getMainExecutor(),
                                () -> fadeExistingPip(true /* show */));
                    }
                } else {
                    wct.setBounds(taskInfo.token, null /* bounds */);
                }
@@ -995,6 +1003,7 @@ public class PipTransition extends PipTransitionController {
        }
        startTransaction.apply();

        int animationDuration = mEnterExitAnimationDuration;
        PipAnimationController.PipTransitionAnimator animator;
        if (enterAnimationType == ANIM_TYPE_BOUNDS) {
            animator = mPipAnimationController.getAnimator(taskInfo, leash, currentBounds,
@@ -1026,8 +1035,17 @@ public class PipTransition extends PipTransitionController {
                }
            }
        } else if (enterAnimationType == ANIM_TYPE_ALPHA) {
            // In case augmentRequest() is unable to apply the entering bounds (e.g. the request
            // info only contains display change), keep the animation invisible (alpha 0) and
            // duration 0 to apply the destination bounds. The actual fade-in animation will be
            // done in onFinishResize() after the bounds are applied.
            final boolean fadeInAfterOnFinishResize = rotationDelta != Surface.ROTATION_0
                    && mFixedRotationState == FIXED_ROTATION_CALLBACK;
            animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds,
                    0f, 1f);
                    0f, fadeInAfterOnFinishResize ? 0f : 1f);
            if (fadeInAfterOnFinishResize) {
                animationDuration = 0;
            }
            mSurfaceTransactionHelper
                    .crop(finishTransaction, leash, destinationBounds)
                    .round(finishTransaction, leash, true /* applyCornerRadius */);
@@ -1037,7 +1055,7 @@ public class PipTransition extends PipTransitionController {
        mPipOrganizer.setContentOverlay(animator.getContentOverlayLeash(), currentBounds);
        animator.setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
                .setPipAnimationCallback(mPipAnimationCallback)
                .setDuration(mEnterExitAnimationDuration);
                .setDuration(animationDuration);
        if (rotationDelta != Surface.ROTATION_0
                && mFixedRotationState == FIXED_ROTATION_TRANSITION) {
            // For fixed rotation, the animation destination bounds is in old rotation coordinates.