From 263932e7299804e8c3e3d7ea976d793d74a74515 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 13 Jun 2024 09:38:58 -0700 Subject: [PATCH] Ignore the mismatched source rect hint When the app provided source rect hint does not match the aspect ratio, by a certain threshold, we ignore that and in turn apply content overlay during the enter animation, to avoid size change at the end. In button-navigation mode, some special logical's applied as to crop the content to its shorter edge for this case, which is inconsistent and we will address that later in a separate change set. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/d4kLspMrqb7Xsc2JtkTW0m Flag: NONE bug fix Bug: 338616637 Test: Enter PiP from zoomed and non-zoomed video Change-Id: I5059553cb9b6c02810e9638bfaf29dde9ab6140f --- .../quickstep/util/SwipePipToHomeAnimator.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index 2d606f384a..e44f14819a 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -50,6 +50,8 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { private static final float END_PROGRESS = 1.0f; + private static final float PIP_ASPECT_RATIO_MISMATCH_THRESHOLD = 0.01f; + private final int mTaskId; private final ActivityInfo mActivityInfo; private final SurfaceControl mLeash; @@ -135,6 +137,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { mDestinationBoundsTransformed.set(destinationBoundsTransformed); mSurfaceTransactionHelper = new PipSurfaceTransactionHelper(cornerRadius, shadowRadius); + final float aspectRatio = destinationBounds.width() / (float) destinationBounds.height(); String reasonForCreateOverlay = null; // For debugging purpose. if (sourceRectHint.isEmpty()) { reasonForCreateOverlay = "Source rect hint is empty"; @@ -149,15 +152,20 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { } else if (!appBounds.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 - sourceRectHint.setEmpty(); reasonForCreateOverlay = "Source rect hint exceeds display bounds " + sourceRectHint; + sourceRectHint.setEmpty(); + } else if (Math.abs( + aspectRatio - (sourceRectHint.width() / (float) sourceRectHint.height())) + > PIP_ASPECT_RATIO_MISMATCH_THRESHOLD) { + // The source rect hint does not aspect ratio + reasonForCreateOverlay = "Source rect hint does not match aspect ratio " + + sourceRectHint + " aspect ratio " + aspectRatio; + sourceRectHint.setEmpty(); } if (sourceRectHint.isEmpty()) { // Crop a Rect matches the aspect ratio and pivots at the center point. // To make the animation path simplified. - final float aspectRatio = destinationBounds.width() - / (float) destinationBounds.height(); if ((appBounds.width() / (float) appBounds.height()) > aspectRatio) { // use the full height. mSourceRectHint.set(0, 0,