Allow extra pixel for app bounds containment PiP

Allow an extra one pixel delta on each side of the
app bounds for source-rect-hint containment checks
when swiping to enter PiP.

Bug: 349821386
Flag: EXEMPT bugfix
Test: swipe PiP to home with 21:9 video from landscape to portrait
Change-Id: Ibc53e426b49cfcd58e977433358b9980732ac289
This commit is contained in:
Ikram Gabiyev
2024-07-12 10:46:16 -07:00
parent 21b2215968
commit 402a96f588
@@ -139,6 +139,10 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim {
final float aspectRatio = destinationBounds.width() / (float) destinationBounds.height();
String reasonForCreateOverlay = null; // For debugging purpose.
// Slightly larger app bounds to allow for off by 1 pixel source-rect-hint errors.
Rect overflowAppBounds = new Rect(appBounds.left - 1, appBounds.top - 1,
appBounds.right + 1, appBounds.bottom + 1);
if (sourceRectHint.isEmpty()) {
reasonForCreateOverlay = "Source rect hint is empty";
} else if (sourceRectHint.width() < destinationBounds.width()
@@ -149,7 +153,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim {
// animation in this case.
reasonForCreateOverlay = "Source rect hint is too small " + sourceRectHint;
sourceRectHint.setEmpty();
} else if (!appBounds.contains(sourceRectHint)) {
} else if (!overflowAppBounds.contains(sourceRectHint)) {
// This is a situation in which the source hint rect is outside the app bounds, so it is
// not a valid rectangle to use for cropping app surface
reasonForCreateOverlay = "Source rect hint exceeds display bounds " + sourceRectHint;