Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +26 −5 Original line number Diff line number Diff line Loading @@ -324,6 +324,8 @@ public class PipAnimationController { private final @AnimationType int mAnimationType; private final Rect mDestinationBounds = new Rect(); private final Point mLeashOffset = new Point(); private T mBaseValue; protected T mCurrentValue; protected T mStartValue; Loading @@ -338,13 +340,22 @@ public class PipAnimationController { // Flag to avoid double-end private boolean mHasRequestedEnd; private PipTransitionAnimator(TaskInfo taskInfo, SurfaceControl leash, @AnimationType int animationType, Rect destinationBounds, T baseValue, T startValue, T endValue) { private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash, @AnimationType int animationType, @NonNull Rect destinationBounds, @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) { this(taskInfo, leash, animationType, destinationBounds, new Point(), baseValue, startValue, endValue); } private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash, @AnimationType int animationType, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) { mTaskInfo = taskInfo; mLeash = leash; mAnimationType = animationType; mDestinationBounds.set(destinationBounds); mLeashOffset.set(leashOffset); mBaseValue = baseValue; mStartValue = startValue; mEndValue = endValue; Loading Loading @@ -496,6 +507,15 @@ public class PipAnimationController { } } /** * Returns the offset of the {@link #mLeash}. */ @NonNull Point getLeashOffset() { // Use copy to prevent the leash to be modified unexpectedly. return new Point(mLeashOffset); } void setCurrentValue(T value) { mCurrentValue = value; } Loading Loading @@ -692,8 +712,8 @@ public class PipAnimationController { final Rect zeroInsets = new Rect(0, 0, 0, 0); // construct new Rect instances in case they are recycled return new PipTransitionAnimator<Rect>(taskInfo, leash, ANIM_TYPE_BOUNDS, endBounds, new Rect(baseBounds), new Rect(startBounds), new Rect(endBounds)) { return new PipTransitionAnimator<Rect>(taskInfo, leash, ANIM_TYPE_BOUNDS, endBounds, leashOffset, new Rect(baseBounds), new Rect(startBounds), new Rect(endBounds)) { private final RectEvaluator mRectEvaluator = new RectEvaluator(new Rect()); private final RectEvaluator mInsetsEvaluator = new RectEvaluator(new Rect()); Loading @@ -720,6 +740,7 @@ public class PipAnimationController { // Use the bounds relative to the task leash in case the leash does not // start from (0, 0). final Rect relativeEndBounds = new Rect(end); final Point leashOffset = getLeashOffset(); relativeEndBounds.offset(-leashOffset.x, -leashOffset.y); getSurfaceTransactionHelper() .crop(tx, leash, relativeEndBounds) Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +13 −8 Original line number Diff line number Diff line Loading @@ -507,8 +507,8 @@ public class PipTransition extends PipTransitionController { } @Override public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, public void onFinishResize(@NonNull TaskInfo taskInfo, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction, @NonNull SurfaceControl.Transaction tx) { final boolean enteringPip = isInPipDirection(direction); if (enteringPip) { Loading @@ -531,12 +531,16 @@ public class PipTransition extends PipTransitionController { if (mFixedRotationState != FIXED_ROTATION_TRANSITION && mFinishTransaction != null) { mFinishTransaction.merge(tx); // Set window crop and position to destination bounds to avoid flickering. // Set crop and position to destination bounds to avoid flickering. if (hasValidLeash) { mFinishTransaction.setWindowCrop(leash, destinationBounds.width(), destinationBounds.height()); mFinishTransaction.setPosition(leash, destinationBounds.left, destinationBounds.top); final Rect relativeDestinationBounds = new Rect(destinationBounds); relativeDestinationBounds.offset(-leashOffset.x, -leashOffset.y); mFinishTransaction .setCrop(leash, relativeDestinationBounds) // Note that we should set the position to the start position of // leash then the visible region will be at the same place even if // the crop region doesn't start at (0, 0). .setPosition(leash, leashOffset.x, leashOffset.y); } } } else { Loading Loading @@ -1267,7 +1271,8 @@ public class PipTransition extends PipTransitionController { mPipBoundsState.setBounds(destinationBounds); final SurfaceControl.Transaction tx = new SurfaceControl.Transaction(); onFinishResize(pipTaskInfo, destinationBounds, TRANSITION_DIRECTION_TO_PIP, tx); onFinishResize(pipTaskInfo, destinationBounds, animator.getLeashOffset(), TRANSITION_DIRECTION_TO_PIP, tx); sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP); if (swipePipToHomeOverlay != null) { mPipOrganizer.fadeOutAndRemoveOverlay(swipePipToHomeOverlay, Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +6 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.PictureInPictureUiState; import android.app.TaskInfo; import android.content.ComponentName; import android.content.pm.ActivityInfo; import android.graphics.Point; import android.graphics.Rect; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -92,7 +93,8 @@ public abstract class PipTransitionController implements Transitions.TransitionH mPipOrganizer.fadeOutAndRemoveOverlay(mPipOrganizer.mPipOverlay, null /* callback */, true /* withStartDelay*/); } onFinishResize(taskInfo, animator.getDestinationBounds(), direction, tx); onFinishResize(taskInfo, animator.getDestinationBounds(), animator.getLeashOffset(), direction, tx); sendOnPipTransitionFinished(direction); } Loading @@ -112,9 +114,9 @@ public abstract class PipTransitionController implements Transitions.TransitionH * Called when transition is about to finish. This is usually for performing tasks such as * applying WindowContainerTransaction to finalize the PiP bounds and send to the framework. */ public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, SurfaceControl.Transaction tx) { public void onFinishResize(@NonNull TaskInfo taskInfo, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction, @NonNull SurfaceControl.Transaction tx) { } /** Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +26 −5 Original line number Diff line number Diff line Loading @@ -324,6 +324,8 @@ public class PipAnimationController { private final @AnimationType int mAnimationType; private final Rect mDestinationBounds = new Rect(); private final Point mLeashOffset = new Point(); private T mBaseValue; protected T mCurrentValue; protected T mStartValue; Loading @@ -338,13 +340,22 @@ public class PipAnimationController { // Flag to avoid double-end private boolean mHasRequestedEnd; private PipTransitionAnimator(TaskInfo taskInfo, SurfaceControl leash, @AnimationType int animationType, Rect destinationBounds, T baseValue, T startValue, T endValue) { private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash, @AnimationType int animationType, @NonNull Rect destinationBounds, @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) { this(taskInfo, leash, animationType, destinationBounds, new Point(), baseValue, startValue, endValue); } private PipTransitionAnimator(@NonNull TaskInfo taskInfo, @NonNull SurfaceControl leash, @AnimationType int animationType, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @NonNull T baseValue, @NonNull T startValue, @NonNull T endValue) { mTaskInfo = taskInfo; mLeash = leash; mAnimationType = animationType; mDestinationBounds.set(destinationBounds); mLeashOffset.set(leashOffset); mBaseValue = baseValue; mStartValue = startValue; mEndValue = endValue; Loading Loading @@ -496,6 +507,15 @@ public class PipAnimationController { } } /** * Returns the offset of the {@link #mLeash}. */ @NonNull Point getLeashOffset() { // Use copy to prevent the leash to be modified unexpectedly. return new Point(mLeashOffset); } void setCurrentValue(T value) { mCurrentValue = value; } Loading Loading @@ -692,8 +712,8 @@ public class PipAnimationController { final Rect zeroInsets = new Rect(0, 0, 0, 0); // construct new Rect instances in case they are recycled return new PipTransitionAnimator<Rect>(taskInfo, leash, ANIM_TYPE_BOUNDS, endBounds, new Rect(baseBounds), new Rect(startBounds), new Rect(endBounds)) { return new PipTransitionAnimator<Rect>(taskInfo, leash, ANIM_TYPE_BOUNDS, endBounds, leashOffset, new Rect(baseBounds), new Rect(startBounds), new Rect(endBounds)) { private final RectEvaluator mRectEvaluator = new RectEvaluator(new Rect()); private final RectEvaluator mInsetsEvaluator = new RectEvaluator(new Rect()); Loading @@ -720,6 +740,7 @@ public class PipAnimationController { // Use the bounds relative to the task leash in case the leash does not // start from (0, 0). final Rect relativeEndBounds = new Rect(end); final Point leashOffset = getLeashOffset(); relativeEndBounds.offset(-leashOffset.x, -leashOffset.y); getSurfaceTransactionHelper() .crop(tx, leash, relativeEndBounds) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +13 −8 Original line number Diff line number Diff line Loading @@ -507,8 +507,8 @@ public class PipTransition extends PipTransitionController { } @Override public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, public void onFinishResize(@NonNull TaskInfo taskInfo, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction, @NonNull SurfaceControl.Transaction tx) { final boolean enteringPip = isInPipDirection(direction); if (enteringPip) { Loading @@ -531,12 +531,16 @@ public class PipTransition extends PipTransitionController { if (mFixedRotationState != FIXED_ROTATION_TRANSITION && mFinishTransaction != null) { mFinishTransaction.merge(tx); // Set window crop and position to destination bounds to avoid flickering. // Set crop and position to destination bounds to avoid flickering. if (hasValidLeash) { mFinishTransaction.setWindowCrop(leash, destinationBounds.width(), destinationBounds.height()); mFinishTransaction.setPosition(leash, destinationBounds.left, destinationBounds.top); final Rect relativeDestinationBounds = new Rect(destinationBounds); relativeDestinationBounds.offset(-leashOffset.x, -leashOffset.y); mFinishTransaction .setCrop(leash, relativeDestinationBounds) // Note that we should set the position to the start position of // leash then the visible region will be at the same place even if // the crop region doesn't start at (0, 0). .setPosition(leash, leashOffset.x, leashOffset.y); } } } else { Loading Loading @@ -1267,7 +1271,8 @@ public class PipTransition extends PipTransitionController { mPipBoundsState.setBounds(destinationBounds); final SurfaceControl.Transaction tx = new SurfaceControl.Transaction(); onFinishResize(pipTaskInfo, destinationBounds, TRANSITION_DIRECTION_TO_PIP, tx); onFinishResize(pipTaskInfo, destinationBounds, animator.getLeashOffset(), TRANSITION_DIRECTION_TO_PIP, tx); sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP); if (swipePipToHomeOverlay != null) { mPipOrganizer.fadeOutAndRemoveOverlay(swipePipToHomeOverlay, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +6 −4 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.app.PictureInPictureUiState; import android.app.TaskInfo; import android.content.ComponentName; import android.content.pm.ActivityInfo; import android.graphics.Point; import android.graphics.Rect; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -92,7 +93,8 @@ public abstract class PipTransitionController implements Transitions.TransitionH mPipOrganizer.fadeOutAndRemoveOverlay(mPipOrganizer.mPipOverlay, null /* callback */, true /* withStartDelay*/); } onFinishResize(taskInfo, animator.getDestinationBounds(), direction, tx); onFinishResize(taskInfo, animator.getDestinationBounds(), animator.getLeashOffset(), direction, tx); sendOnPipTransitionFinished(direction); } Loading @@ -112,9 +114,9 @@ public abstract class PipTransitionController implements Transitions.TransitionH * Called when transition is about to finish. This is usually for performing tasks such as * applying WindowContainerTransaction to finalize the PiP bounds and send to the framework. */ public void onFinishResize(TaskInfo taskInfo, Rect destinationBounds, @PipAnimationController.TransitionDirection int direction, SurfaceControl.Transaction tx) { public void onFinishResize(@NonNull TaskInfo taskInfo, @NonNull Rect destinationBounds, @NonNull Point leashOffset, @PipAnimationController.TransitionDirection int direction, @NonNull SurfaceControl.Transaction tx) { } /** Loading