summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Lin <linben@google.com> 2021-05-17 18:00:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-05-17 18:00:08 +0000
commit4e04b705e30e2041526b4219abf34c73f2c6f839 (patch)
treeed2299a13384c311770e3dd38a5c895ef539092f
parent54441572a926bebb59605ee60acfee2d416b4386 (diff)
parent620ee55cc38d770d8b1de33d4804a08edfcaae31 (diff)
Merge "PiP: Damp resizing after going over max size." into sc-dev
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipPinchResizingAlgorithm.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipPinchResizingAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipPinchResizingAlgorithm.java
index f8125fd5764e..23153be72890 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipPinchResizingAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipPinchResizingAlgorithm.java
@@ -27,6 +27,7 @@ public class PipPinchResizingAlgorithm {
private static final int PINCH_RESIZE_MAX_ANGLE_ROTATION = 45;
private static final float OVERROTATE_DAMP_FACTOR = 0.4f;
private static final float ANGLE_THRESHOLD = 5f;
+ private static final float OVERRESIZE_DAMP_FACTOR = 0.25f;
private final PointF mTmpDownVector = new PointF();
private final PointF mTmpLastVector = new PointF();
@@ -46,7 +47,10 @@ public class PipPinchResizingAlgorithm {
lastSecondPoint.y - lastPoint.y);
float minScale = getMinScale(initialBounds, minSize);
float maxScale = getMaxScale(initialBounds, maxSize);
- float scale = Math.max(minScale, Math.min(maxScale, dist / downDist));
+ float overStretchMin = minScale - dist / downDist > 0 ? minScale - dist / downDist : 0;
+ float overStretchMax = dist / downDist - maxScale > 0 ? dist / downDist - maxScale : 0;
+ float scale = Math.max(minScale - overStretchMin * OVERRESIZE_DAMP_FACTOR,
+ Math.min(maxScale + overStretchMax * OVERRESIZE_DAMP_FACTOR, dist / downDist));
// Scale the bounds by the change in distance between the points
resizeBoundsOut.set(initialBounds);