summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hongwei Wang <hwwang@google.com> 2025-03-13 15:39:58 -0700
committer Hongwei Wang <hwwang@google.com> 2025-03-13 16:09:41 -0700
commit9f608cfa69fcf4d828bb44fc6f149a7ad3ba3263 (patch)
tree6f3dafcf1f6a67ff074734f25ada0f1acc91cffd
parent35b49cfff5a4e6346f80690c936321d14d53365c (diff)
[1/N] Check destination against src aspect ratio
This is the fix on SystemUI side. There is a counterpart on Launcher side. PictureInPictureParams#isSameAspectRatio has 1-pixel allowance when comparing a given Rect against the aspect ratio. When we compare the source rect hint against the aspect ratio inferred from the destination bounds, the float error during the destination bounds calculation is amped. For instance: - Source rect hint: Rect(152, 0 - 2072, 1080), 1920x1080 - Destination bounds: Rect(440, 1218 - 1038, 1554), 598x336 When do the isSameAspectRatio - If we fix the height=1080, expected width=1922, it's 2 pixels off - If we fix the width=1920, expected height=1078, it's 2 pixels off The check would fail. Instead, in this change, we compare the destination bounds against the aspect ratio from the source rect hint. For the same source rect hint and destination bounds - If we fix the height=336, expected width=597, it's 1 pixel off - If we fix the width=598, expect height=336, it's 0 pixel off Note: this change applies to both PiP1 and PiP2 Flag: EXEMPT bugfix Bug: 402190788 Video: http://recall/-/aaaaaabFQoRHlzixHdtY/cUXaoJxzXDdKdSyqkQZOG1 Test: Swipe to enter PiP from landscape playback, see also Video Change-Id: I02d6ddf2d0f2ffdc2e33c52ff9577fcba07d26ce
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipBoundsAlgorithm.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipBoundsAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipBoundsAlgorithm.java
index 04e8d8dee520..5d603d6c087d 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipBoundsAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipBoundsAlgorithm.java
@@ -221,8 +221,11 @@ public class PipBoundsAlgorithm {
+ " than destination(%s)", sourceRectHint, destinationBounds);
return false;
}
- if (!PictureInPictureParams.isSameAspectRatio(sourceRectHint,
- new Rational(destinationBounds.width(), destinationBounds.height()))) {
+ // We use the aspect ratio of source rect hint to check against destination bounds
+ // here to avoid upscaling error.
+ final Rational srcAspectRatio = new Rational(
+ sourceRectHint.width(), sourceRectHint.height());
+ if (!PictureInPictureParams.isSameAspectRatio(destinationBounds, srcAspectRatio)) {
ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
"isSourceRectHintValidForEnterPip=false, hint(%s) does not match"
+ " destination(%s) aspect ratio", sourceRectHint, destinationBounds);