Merge "Reduce flickering when exiting PiP to fullscreen" into udc-dev

This commit is contained in:
Riddle Hsu
2023-06-19 18:27:49 +00:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 13 deletions

View File

@@ -534,8 +534,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
return; return;
} }
final Rect displayBounds = mPipBoundsState.getDisplayBounds(); final Rect destinationBounds = new Rect(getExitDestinationBounds());
final Rect destinationBounds = new Rect(displayBounds);
final int direction = syncWithSplitScreenBounds(destinationBounds, requestEnterSplit) final int direction = syncWithSplitScreenBounds(destinationBounds, requestEnterSplit)
? TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN ? TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN
: TRANSITION_DIRECTION_LEAVE_PIP; : TRANSITION_DIRECTION_LEAVE_PIP;

View File

@@ -351,7 +351,7 @@ public class PipTransition extends PipTransitionController {
if (taskInfo != null) { if (taskInfo != null) {
startExpandAnimation(taskInfo, mPipOrganizer.getSurfaceControl(), startExpandAnimation(taskInfo, mPipOrganizer.getSurfaceControl(),
mPipBoundsState.getBounds(), mPipBoundsState.getBounds(), mPipBoundsState.getBounds(), mPipBoundsState.getBounds(),
new Rect(mExitDestinationBounds), Surface.ROTATION_0); new Rect(mExitDestinationBounds), Surface.ROTATION_0, null /* startT */);
} }
mExitDestinationBounds.setEmpty(); mExitDestinationBounds.setEmpty();
mCurrentPipTaskToken = null; mCurrentPipTaskToken = null;
@@ -604,14 +604,8 @@ public class PipTransition extends PipTransitionController {
} }
} }
// Set the initial frame as scaling the end to the start.
final Rect destinationBounds = new Rect(pipChange.getEndAbsBounds()); final Rect destinationBounds = new Rect(pipChange.getEndAbsBounds());
destinationBounds.offset(-offset.x, -offset.y); destinationBounds.offset(-offset.x, -offset.y);
startTransaction.setWindowCrop(pipLeash, destinationBounds.width(),
destinationBounds.height());
mSurfaceTransactionHelper.scale(startTransaction, pipLeash, destinationBounds,
currentBounds);
startTransaction.apply();
// Check if it is fixed rotation. // Check if it is fixed rotation.
final int rotationDelta; final int rotationDelta;
@@ -641,7 +635,7 @@ public class PipTransition extends PipTransitionController {
rotationDelta = Surface.ROTATION_0; rotationDelta = Surface.ROTATION_0;
} }
startExpandAnimation(taskInfo, pipLeash, currentBounds, currentBounds, destinationBounds, startExpandAnimation(taskInfo, pipLeash, currentBounds, currentBounds, destinationBounds,
rotationDelta); rotationDelta, startTransaction);
} }
private void startExpandAndRotationAnimation(@NonNull TransitionInfo info, private void startExpandAndRotationAnimation(@NonNull TransitionInfo info,
@@ -697,7 +691,7 @@ public class PipTransition extends PipTransitionController {
private void startExpandAnimation(final TaskInfo taskInfo, final SurfaceControl leash, private void startExpandAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
final Rect baseBounds, final Rect startBounds, final Rect endBounds, final Rect baseBounds, final Rect startBounds, final Rect endBounds,
final int rotationDelta) { final int rotationDelta, @Nullable SurfaceControl.Transaction startTransaction) {
final Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect( final Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect(
taskInfo.pictureInPictureParams, endBounds); taskInfo.pictureInPictureParams, endBounds);
final PipAnimationController.PipTransitionAnimator animator = final PipAnimationController.PipTransitionAnimator animator =
@@ -705,9 +699,14 @@ public class PipTransition extends PipTransitionController {
endBounds, sourceHintRect, TRANSITION_DIRECTION_LEAVE_PIP, endBounds, sourceHintRect, TRANSITION_DIRECTION_LEAVE_PIP,
0 /* startingAngle */, rotationDelta); 0 /* startingAngle */, rotationDelta);
animator.setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP) animator.setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP)
.setPipAnimationCallback(mPipAnimationCallback) .setDuration(mEnterExitAnimationDuration);
if (startTransaction != null) {
animator.setPipTransactionHandler(mTransactionConsumer).applySurfaceControlTransaction(
leash, startTransaction, PipAnimationController.FRACTION_START);
startTransaction.apply();
}
animator.setPipAnimationCallback(mPipAnimationCallback)
.setPipTransactionHandler(mPipOrganizer.getPipTransactionHandler()) .setPipTransactionHandler(mPipOrganizer.getPipTransactionHandler())
.setDuration(mEnterExitAnimationDuration)
.start(); .start();
} }