diff options
| author | 2022-10-24 15:03:43 -0700 | |
|---|---|---|
| committer | 2022-10-26 05:22:55 +0000 | |
| commit | 8be07d9105d138822aff7ee9a83a7ea31577375b (patch) | |
| tree | 622dade02f06bc3a5ef4b4dc8efa57e526d8893a | |
| parent | 23161303beab2021d6bd69a176f8fa422f322b96 (diff) | |
Fix the scale for entering PiP animation
The entering PiP animation used to overscale when entered from large
screen landscape mode.
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/hMdoi9O3JEDSMvB9qqFNrc
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/jpZQhYk17hPEnWnWtjeRR
Bug: 201824622
Test: Entering PiP from large screen, landscape and portrait, in both \
button and gesture navigation mode. See also the video
Change-Id: Ic4a4c2a8e83f794a999d8a91c6ebdb03537011f3
2 files changed, 8 insertions, 10 deletions
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 b9746e338ced..cbed4b5a501f 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 @@ -115,8 +115,8 @@ public class PipSurfaceTransactionHelper { // 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 + // Scale to the bounds no smaller than the destination and offset such that the top/left + // of the scaled inset source rect aligns with the top/left of the destination bounds final float scale; if (isInPipDirection && sourceRectHint != null && sourceRectHint.width() < sourceBounds.width()) { @@ -129,9 +129,8 @@ public class PipSurfaceTransactionHelper { : (float) destinationBounds.height() / sourceBounds.height(); scale = (1 - fraction) * startScale + fraction * endScale; } else { - scale = sourceBounds.width() <= sourceBounds.height() - ? (float) destinationBounds.width() / sourceBounds.width() - : (float) destinationBounds.height() / sourceBounds.height(); + scale = Math.max((float) destinationBounds.width() / sourceBounds.width(), + (float) destinationBounds.height() / sourceBounds.height()); } final float left = destinationBounds.left - insets.left * scale; final float top = destinationBounds.top - insets.top * scale; diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/pip/PipSurfaceTransactionHelper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/pip/PipSurfaceTransactionHelper.java index 7e42e1b89b1f..8ac1de898be8 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/pip/PipSurfaceTransactionHelper.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/pip/PipSurfaceTransactionHelper.java @@ -85,13 +85,12 @@ public class PipSurfaceTransactionHelper { mTmpSourceRectF.set(sourceBounds); mTmpDestinationRect.set(sourceBounds); 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 + // Scale to the bounds no smaller than the destination and offset such that the top/left + // of the scaled inset source rect aligns with the top/left of the destination bounds final float scale; if (sourceRectHint.isEmpty() || sourceRectHint.width() == sourceBounds.width()) { - scale = sourceBounds.width() <= sourceBounds.height() - ? (float) destinationBounds.width() / sourceBounds.width() - : (float) destinationBounds.height() / sourceBounds.height(); + scale = Math.max((float) destinationBounds.width() / sourceBounds.width(), + (float) destinationBounds.height() / sourceBounds.height()); } else { // scale by sourceRectHint if it's not edge-to-edge final float endScale = sourceRectHint.width() <= sourceRectHint.height() |