Merge "Draw PipContentOverlay when enter PIP with Shell transition"

This commit is contained in:
Chris Li
2022-01-05 03:38:35 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 1 deletions

View File

@@ -1435,7 +1435,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
/**
* Fades out and removes an overlay surface.
*/
private void fadeOutAndRemoveOverlay(SurfaceControl surface, Runnable callback,
void fadeOutAndRemoveOverlay(SurfaceControl surface, Runnable callback,
boolean withStartDelay) {
if (surface == null) {
return;

View File

@@ -65,6 +65,7 @@ public class PipTransition extends PipTransitionController {
private static final String TAG = PipTransition.class.getSimpleName();
private final Context mContext;
private final PipTransitionState mPipTransitionState;
private final int mEnterExitAnimationDuration;
private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
@@ -86,6 +87,7 @@ public class PipTransition extends PipTransitionController {
Optional<SplitScreenController> splitScreenOptional) {
super(pipBoundsState, pipMenuController, pipBoundsAlgorithm,
pipAnimationController, transitions, shellTaskOrganizer);
mContext = context;
mPipTransitionState = pipTransitionState;
mEnterExitAnimationDuration = context.getResources()
.getInteger(R.integer.config_pipResizeAnimationDuration);
@@ -359,6 +361,11 @@ public class PipTransition extends PipTransitionController {
animator = mPipAnimationController.getAnimator(taskInfo, leash, currentBounds,
currentBounds, destinationBounds, sourceHintRect, TRANSITION_DIRECTION_TO_PIP,
0 /* startingAngle */, rotationDelta);
if (sourceHintRect == null) {
// We use content overlay when there is no source rect hint to enter PiP use bounds
// animation.
animator.setUseContentOverlay(mContext);
}
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
startTransaction.setAlpha(leash, 0f);
// PiP menu is attached late in the process here to avoid any artifacts on the leash

View File

@@ -19,6 +19,7 @@ package com.android.wm.shell.pip;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
import android.annotation.Nullable;
import android.app.PictureInPictureParams;
@@ -69,6 +70,10 @@ public abstract class PipTransitionController implements Transitions.TransitionH
if (direction == TRANSITION_DIRECTION_REMOVE_STACK) {
return;
}
if (isInPipDirection(direction) && animator.getContentOverlay() != null) {
mPipOrganizer.fadeOutAndRemoveOverlay(animator.getContentOverlay(),
animator::clearContentOverlay, true /* withStartDelay*/);
}
onFinishResize(taskInfo, animator.getDestinationBounds(), direction, tx);
sendOnPipTransitionFinished(direction);
}
@@ -76,6 +81,11 @@ public abstract class PipTransitionController implements Transitions.TransitionH
@Override
public void onPipAnimationCancel(TaskInfo taskInfo,
PipAnimationController.PipTransitionAnimator animator) {
final int direction = animator.getTransitionDirection();
if (isInPipDirection(direction) && animator.getContentOverlay() != null) {
mPipOrganizer.fadeOutAndRemoveOverlay(animator.getContentOverlay(),
animator::clearContentOverlay, true /* withStartDelay */);
}
sendOnPipTransitionCancelled(animator.getTransitionDirection());
}
};