diff options
| author | 2021-06-09 14:45:03 -0700 | |
|---|---|---|
| committer | 2021-06-10 18:11:39 -0700 | |
| commit | 6a92728699a576053e8833f3a139cf32cbff142b (patch) | |
| tree | 205c673e0ead3f8d21319beea275d47c38783109 | |
| parent | 4e46adb80847156289609b76a931d0b27c3d2ff9 (diff) | |
Polish YT auto enter PiP transition
- Fixed the round corner radius calculation, take into account the
insets, was applied to the destination bounds side
- Adjust the leash position based on the insets
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/eUpkH2il1vYBVBPt1Vks2u
Bug: 190748719
Test: auto-enter-pip from YT landscape, see video
Change-Id: I2f3f4ae807630c5ae6bcc9968c6b46cf4501ad07
| -rw-r--r-- | packages/SystemUI/shared/src/com/android/systemui/shared/pip/PipSurfaceTransactionHelper.java | 22 |
1 files changed, 14 insertions, 8 deletions
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 fb9aa4a4b358..998b318915af 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,9 +85,7 @@ public class PipSurfaceTransactionHelper { final float left = destinationBounds.left - insets.left * scale; final float top = destinationBounds.top - insets.top * scale; mTmpTransform.setScale(scale, scale); - final Rect cornerRadiusRect = new Rect(destinationBounds); - cornerRadiusRect.inset(insets); - final float cornerRadius = getScaledCornerRadius(sourceBounds, cornerRadiusRect); + final float cornerRadius = getScaledCornerRadius(mTmpDestinationRect, destinationBounds); tx.setMatrix(leash, mTmpTransform, mTmpFloat9) .setWindowCrop(leash, mTmpDestinationRect) .setPosition(leash, left, top) @@ -110,15 +108,23 @@ public class PipSurfaceTransactionHelper { : (float) destinationBounds.height() / sourceBounds.height(); mTmpTransform.setRotate(degree, 0, 0); mTmpTransform.postScale(scale, scale); - final Rect cornerRadiusRect = new Rect(destinationBounds); - cornerRadiusRect.inset(insets); - final float cornerRadius = getScaledCornerRadius(sourceBounds, cornerRadiusRect); + final float cornerRadius = getScaledCornerRadius(mTmpDestinationRect, destinationBounds); + // adjust the positions, take account also the insets + final float adjustedPositionX, adjustedPositionY; + if (degree < 0) { + adjustedPositionX = positionX + insets.top * scale; + adjustedPositionY = positionY + insets.left * scale; + } else { + adjustedPositionX = positionX - insets.top * scale; + adjustedPositionY = positionY - insets.left * scale; + } tx.setMatrix(leash, mTmpTransform, mTmpFloat9) .setWindowCrop(leash, mTmpDestinationRect) - .setPosition(leash, positionX, positionY) + .setPosition(leash, adjustedPositionX, adjustedPositionY) .setCornerRadius(leash, cornerRadius); return new PictureInPictureSurfaceTransaction( - positionX, positionY, mTmpFloat9, degree, cornerRadius, mTmpDestinationRect); + adjustedPositionX, adjustedPositionY, + mTmpFloat9, degree, cornerRadius, mTmpDestinationRect); } /** @return the round corner radius scaled by given from and to bounds */ |