Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipEnterAnimator.java +13 −5 Original line number Diff line number Diff line Loading @@ -110,8 +110,7 @@ public class PipEnterAnimator extends ValueAnimator mAnimationStartCallback.run(); } if (mStartTransaction != null) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, 0f /* fraction */, mStartTransaction); onEnterAnimationUpdate(0f /* fraction */, mStartTransaction); mStartTransaction.apply(); } } Loading @@ -119,8 +118,7 @@ public class PipEnterAnimator extends ValueAnimator @Override public void onAnimationEnd(@NonNull Animator animation) { if (mFinishTransaction != null) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, 1f /* fraction */, mFinishTransaction); onEnterAnimationUpdate(1f /* fraction */, mFinishTransaction); } if (mAnimationEndCallback != null) { mAnimationEndCallback.run(); Loading @@ -131,10 +129,20 @@ public class PipEnterAnimator extends ValueAnimator public void onAnimationUpdate(@NonNull ValueAnimator animation) { final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); final float fraction = getAnimatedFraction(); onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, fraction, tx); onEnterAnimationUpdate(fraction, tx); tx.apply(); } /** * Updates the transaction to reflect the state of PiP leash at a certain fraction during enter. * * @param fraction the fraction of the animator going from 0f to 1f. * @param tx the transaction to modify the transform of. */ public void onEnterAnimationUpdate(float fraction, SurfaceControl.Transaction tx) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, fraction, tx); } private void onEnterAnimationUpdate(PointF initScale, PointF initPos, Rect initCrop, float fraction, SurfaceControl.Transaction tx) { float scaleX = 1 + (initScale.x - 1) * (1 - fraction); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +28 −23 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import android.annotation.NonNull; import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.Context; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Rect; import android.os.Bundle; Loading Loading @@ -316,6 +315,14 @@ public class PipTransition extends PipTransitionController implements if (pipChange == null) { return false; } // We expect the PiP activity as a separate change in a config-at-end transition. TransitionInfo.Change pipActivityChange = getDeferConfigActivityChange(info, pipChange.getTaskInfo().getToken()); if (pipActivityChange == null) { return false; } SurfaceControl pipLeash = pipChange.getLeash(); Preconditions.checkNotNull(pipLeash, "Leash is null for swipe-up transition."); Loading @@ -333,27 +340,27 @@ public class PipTransition extends PipTransitionController implements (destinationBounds.width() - overlaySize) / 2f, (destinationBounds.height() - overlaySize) / 2f); } startTransaction.merge(finishTransaction); final int startRotation = pipChange.getStartRotation(); final int endRotation = mPipDisplayLayoutState.getRotation(); if (endRotation != startRotation) { boolean isClockwise = (endRotation - startRotation) == -ROTATION_270; // Display bounds were already updated to represent the final orientation, // so we just need to readjust the origin, and perform rotation about (0, 0). Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds(); int originTranslateX = isClockwise ? 0 : -displayBounds.width(); int originTranslateY = isClockwise ? -displayBounds.height() : 0; final int delta = endRotation == ROTATION_UNDEFINED ? ROTATION_0 : startRotation - endRotation; if (delta != ROTATION_0) { mPipTransitionState.setInFixedRotation(true); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, endRotation); } Matrix transformTensor = new Matrix(); final float[] matrixTmp = new float[9]; transformTensor.setTranslate(originTranslateX + destinationBounds.left, originTranslateY + destinationBounds.top); final float degrees = (endRotation - startRotation) * 90f; transformTensor.postRotate(degrees); startTransaction.setMatrix(pipLeash, transformTensor, matrixTmp); Rect sourceRectHint = null; if (pipChange.getTaskInfo() != null && pipChange.getTaskInfo().pictureInPictureParams != null) { sourceRectHint = pipChange.getTaskInfo().pictureInPictureParams.getSourceRectHint(); } startTransaction.merge(finishTransaction); PipEnterAnimator animator = new PipEnterAnimator(mContext, pipLeash, startTransaction, finishTransaction, destinationBounds, sourceRectHint, delta); animator.setEnterStartState(pipChange, pipActivityChange); animator.onEnterAnimationUpdate(1.0f /* fraction */, startTransaction); startTransaction.apply(); finishInner(); return true; Loading Loading @@ -399,7 +406,6 @@ public class PipTransition extends PipTransitionController implements } Rect endBounds = pipChange.getEndAbsBounds(); Rect activityEndBounds = pipActivityChange.getEndAbsBounds(); SurfaceControl pipLeash = mPipTransitionState.mPinnedTaskLeash; Preconditions.checkNotNull(pipLeash, "Leash is null for bounds transition."); Loading Loading @@ -430,7 +436,8 @@ public class PipTransition extends PipTransitionController implements if (delta != ROTATION_0) { mPipTransitionState.setInFixedRotation(true); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, fixedRotationChange); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, fixedRotationChange.getEndFixedRotation()); } PipEnterAnimator animator = new PipEnterAnimator(mContext, pipLeash, Loading @@ -443,12 +450,10 @@ public class PipTransition extends PipTransitionController implements } private void handleBoundsTypeFixedRotation(TransitionInfo.Change pipTaskChange, TransitionInfo.Change pipActivityChange, TransitionInfo.Change fixedRotationChange) { TransitionInfo.Change pipActivityChange, int endRotation) { final Rect endBounds = pipTaskChange.getEndAbsBounds(); final Rect endActivityBounds = pipActivityChange.getEndAbsBounds(); int startRotation = pipTaskChange.getStartRotation(); int endRotation = fixedRotationChange.getEndFixedRotation(); // Cache the task to activity offset to potentially restore later. Point activityEndOffset = new Point(endActivityBounds.left - endBounds.left, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/animation/PipEnterAnimator.java +13 −5 Original line number Diff line number Diff line Loading @@ -110,8 +110,7 @@ public class PipEnterAnimator extends ValueAnimator mAnimationStartCallback.run(); } if (mStartTransaction != null) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, 0f /* fraction */, mStartTransaction); onEnterAnimationUpdate(0f /* fraction */, mStartTransaction); mStartTransaction.apply(); } } Loading @@ -119,8 +118,7 @@ public class PipEnterAnimator extends ValueAnimator @Override public void onAnimationEnd(@NonNull Animator animation) { if (mFinishTransaction != null) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, 1f /* fraction */, mFinishTransaction); onEnterAnimationUpdate(1f /* fraction */, mFinishTransaction); } if (mAnimationEndCallback != null) { mAnimationEndCallback.run(); Loading @@ -131,10 +129,20 @@ public class PipEnterAnimator extends ValueAnimator public void onAnimationUpdate(@NonNull ValueAnimator animation) { final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); final float fraction = getAnimatedFraction(); onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, fraction, tx); onEnterAnimationUpdate(fraction, tx); tx.apply(); } /** * Updates the transaction to reflect the state of PiP leash at a certain fraction during enter. * * @param fraction the fraction of the animator going from 0f to 1f. * @param tx the transaction to modify the transform of. */ public void onEnterAnimationUpdate(float fraction, SurfaceControl.Transaction tx) { onEnterAnimationUpdate(mInitScale, mInitPos, mInitCrop, fraction, tx); } private void onEnterAnimationUpdate(PointF initScale, PointF initPos, Rect initCrop, float fraction, SurfaceControl.Transaction tx) { float scaleX = 1 + (initScale.x - 1) * (1 - fraction); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +28 −23 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ import android.annotation.NonNull; import android.app.ActivityManager; import android.app.PictureInPictureParams; import android.content.Context; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.Rect; import android.os.Bundle; Loading Loading @@ -316,6 +315,14 @@ public class PipTransition extends PipTransitionController implements if (pipChange == null) { return false; } // We expect the PiP activity as a separate change in a config-at-end transition. TransitionInfo.Change pipActivityChange = getDeferConfigActivityChange(info, pipChange.getTaskInfo().getToken()); if (pipActivityChange == null) { return false; } SurfaceControl pipLeash = pipChange.getLeash(); Preconditions.checkNotNull(pipLeash, "Leash is null for swipe-up transition."); Loading @@ -333,27 +340,27 @@ public class PipTransition extends PipTransitionController implements (destinationBounds.width() - overlaySize) / 2f, (destinationBounds.height() - overlaySize) / 2f); } startTransaction.merge(finishTransaction); final int startRotation = pipChange.getStartRotation(); final int endRotation = mPipDisplayLayoutState.getRotation(); if (endRotation != startRotation) { boolean isClockwise = (endRotation - startRotation) == -ROTATION_270; // Display bounds were already updated to represent the final orientation, // so we just need to readjust the origin, and perform rotation about (0, 0). Rect displayBounds = mPipDisplayLayoutState.getDisplayBounds(); int originTranslateX = isClockwise ? 0 : -displayBounds.width(); int originTranslateY = isClockwise ? -displayBounds.height() : 0; final int delta = endRotation == ROTATION_UNDEFINED ? ROTATION_0 : startRotation - endRotation; if (delta != ROTATION_0) { mPipTransitionState.setInFixedRotation(true); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, endRotation); } Matrix transformTensor = new Matrix(); final float[] matrixTmp = new float[9]; transformTensor.setTranslate(originTranslateX + destinationBounds.left, originTranslateY + destinationBounds.top); final float degrees = (endRotation - startRotation) * 90f; transformTensor.postRotate(degrees); startTransaction.setMatrix(pipLeash, transformTensor, matrixTmp); Rect sourceRectHint = null; if (pipChange.getTaskInfo() != null && pipChange.getTaskInfo().pictureInPictureParams != null) { sourceRectHint = pipChange.getTaskInfo().pictureInPictureParams.getSourceRectHint(); } startTransaction.merge(finishTransaction); PipEnterAnimator animator = new PipEnterAnimator(mContext, pipLeash, startTransaction, finishTransaction, destinationBounds, sourceRectHint, delta); animator.setEnterStartState(pipChange, pipActivityChange); animator.onEnterAnimationUpdate(1.0f /* fraction */, startTransaction); startTransaction.apply(); finishInner(); return true; Loading Loading @@ -399,7 +406,6 @@ public class PipTransition extends PipTransitionController implements } Rect endBounds = pipChange.getEndAbsBounds(); Rect activityEndBounds = pipActivityChange.getEndAbsBounds(); SurfaceControl pipLeash = mPipTransitionState.mPinnedTaskLeash; Preconditions.checkNotNull(pipLeash, "Leash is null for bounds transition."); Loading Loading @@ -430,7 +436,8 @@ public class PipTransition extends PipTransitionController implements if (delta != ROTATION_0) { mPipTransitionState.setInFixedRotation(true); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, fixedRotationChange); handleBoundsTypeFixedRotation(pipChange, pipActivityChange, fixedRotationChange.getEndFixedRotation()); } PipEnterAnimator animator = new PipEnterAnimator(mContext, pipLeash, Loading @@ -443,12 +450,10 @@ public class PipTransition extends PipTransitionController implements } private void handleBoundsTypeFixedRotation(TransitionInfo.Change pipTaskChange, TransitionInfo.Change pipActivityChange, TransitionInfo.Change fixedRotationChange) { TransitionInfo.Change pipActivityChange, int endRotation) { final Rect endBounds = pipTaskChange.getEndAbsBounds(); final Rect endActivityBounds = pipActivityChange.getEndAbsBounds(); int startRotation = pipTaskChange.getStartRotation(); int endRotation = fixedRotationChange.getEndFixedRotation(); // Cache the task to activity offset to potentially restore later. Point activityEndOffset = new Point(endActivityBounds.left - endBounds.left, Loading