summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hongwei Wang <hwwang@google.com> 2022-05-28 07:19:32 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-05-28 07:19:32 +0000
commite00e1d6465822bee22a17261fc2432921d8ee47e (patch)
treeedb887346e448f2bdf8a9aee31e84805958d51bd
parent2a80311b49e11761ab4703b37849f25ffb7ebe2f (diff)
parent7f48b2a9826da32955d5c7b726a079532b294e4d (diff)
Merge "Fix the animation position when launch into PiP" into tm-dev am: 83979ad7b7 am: 21482ebd2c am: 7f48b2a982
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18637060 Change-Id: I47940c8bd942421d32a3a3fb1cb9983c3d38479c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java13
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java4
2 files changed, 12 insertions, 5 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java
index a032b338aae8..3dea0e02c530 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipContentOverlay.java
@@ -132,7 +132,11 @@ public abstract class PipContentOverlay {
tx.show(mLeash);
tx.setLayer(mLeash, Integer.MAX_VALUE);
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.reparent(mLeash, parentLeash);
tx.apply();
@@ -149,10 +153,11 @@ public abstract class PipContentOverlay {
// the atomicTx is committed along with the final WindowContainerTransaction.
final SurfaceControl.Transaction nonAtomicTx = new SurfaceControl.Transaction();
final float scaleX = (float) destinationBounds.width()
- / mSnapshot.getHardwareBuffer().getWidth();
+ / mSourceRectHint.width();
final float scaleY = (float) destinationBounds.height()
- / mSnapshot.getHardwareBuffer().getHeight();
- final float scale = Math.max(scaleX, scaleY);
+ / mSourceRectHint.height();
+ final float scale = Math.max(
+ scaleX * mTaskSnapshotScaleX, scaleY * mTaskSnapshotScaleY);
nonAtomicTx.setScale(mLeash, scale, scale);
nonAtomicTx.setPosition(mLeash,
-scale * mSourceRectHint.left / mTaskSnapshotScaleX,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
index c6e48f53681c..a017a2674359 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
@@ -105,8 +105,10 @@ public class PipSurfaceTransactionHelper {
SurfaceControl leash, Rect sourceRectHint,
Rect sourceBounds, Rect destinationBounds, Rect insets,
boolean isInPipDirection) {
- mTmpSourceRectF.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);
// 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