Merge "Fix the animation position when launch into PiP" into tm-dev am: 83979ad7b7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18637060

Change-Id: I8f5078e5e3607ba2c4a2abf605eb187c4e3de8f6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hongwei Wang
2022-05-28 06:39:33 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 5 deletions

View File

@@ -132,7 +132,11 @@ public abstract class PipContentOverlay {
tx.show(mLeash); tx.show(mLeash);
tx.setLayer(mLeash, Integer.MAX_VALUE); tx.setLayer(mLeash, Integer.MAX_VALUE);
tx.setBuffer(mLeash, mSnapshot.getHardwareBuffer()); tx.setBuffer(mLeash, mSnapshot.getHardwareBuffer());
tx.setCrop(mLeash, mSourceRectHint); // Relocate the content to parentLeash's coordinates.
tx.setPosition(mLeash, -mSourceRectHint.left, -mSourceRectHint.top);
tx.setWindowCrop(mLeash,
(int) (mSourceRectHint.width() * mTaskSnapshotScaleX),
(int) (mSourceRectHint.height() * mTaskSnapshotScaleY));
tx.setScale(mLeash, mTaskSnapshotScaleX, mTaskSnapshotScaleY); tx.setScale(mLeash, mTaskSnapshotScaleX, mTaskSnapshotScaleY);
tx.reparent(mLeash, parentLeash); tx.reparent(mLeash, parentLeash);
tx.apply(); tx.apply();
@@ -149,10 +153,11 @@ public abstract class PipContentOverlay {
// the atomicTx is committed along with the final WindowContainerTransaction. // the atomicTx is committed along with the final WindowContainerTransaction.
final SurfaceControl.Transaction nonAtomicTx = new SurfaceControl.Transaction(); final SurfaceControl.Transaction nonAtomicTx = new SurfaceControl.Transaction();
final float scaleX = (float) destinationBounds.width() final float scaleX = (float) destinationBounds.width()
/ mSnapshot.getHardwareBuffer().getWidth(); / mSourceRectHint.width();
final float scaleY = (float) destinationBounds.height() final float scaleY = (float) destinationBounds.height()
/ mSnapshot.getHardwareBuffer().getHeight(); / mSourceRectHint.height();
final float scale = Math.max(scaleX, scaleY); final float scale = Math.max(
scaleX * mTaskSnapshotScaleX, scaleY * mTaskSnapshotScaleY);
nonAtomicTx.setScale(mLeash, scale, scale); nonAtomicTx.setScale(mLeash, scale, scale);
nonAtomicTx.setPosition(mLeash, nonAtomicTx.setPosition(mLeash,
-scale * mSourceRectHint.left / mTaskSnapshotScaleX, -scale * mSourceRectHint.left / mTaskSnapshotScaleX,

View File

@@ -105,8 +105,10 @@ public class PipSurfaceTransactionHelper {
SurfaceControl leash, Rect sourceRectHint, SurfaceControl leash, Rect sourceRectHint,
Rect sourceBounds, Rect destinationBounds, Rect insets, Rect sourceBounds, Rect destinationBounds, Rect insets,
boolean isInPipDirection) { boolean isInPipDirection) {
mTmpSourceRectF.set(sourceBounds);
mTmpDestinationRect.set(sourceBounds); mTmpDestinationRect.set(sourceBounds);
// Similar to {@link #scale}, we want to position the surface relative to the screen
// coordinates so offset the bounds to 0,0
mTmpDestinationRect.offsetTo(0, 0);
mTmpDestinationRect.inset(insets); mTmpDestinationRect.inset(insets);
// Scale by the shortest edge and offset such that the top/left of the scaled inset source // Scale by the shortest edge and offset such that the top/left of the scaled inset source
// rect aligns with the top/left of the destination bounds // rect aligns with the top/left of the destination bounds