From fd4c9891f332292e3116b913b2a0c5e8e2273c43 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 1 Feb 2017 10:28:28 -0800 Subject: [PATCH] Scale PiP to stack instead of crop. When changing stacks the finalCrop or crop may not be set so relying on either one for the scaling factor is error prone. Just scale to the stack size. I initially avoided this because I thought some of the crop code may be relevant in computing the size we wan't...but I'm now pretty sure it won't. Test: Expand PiP back to fullscreen on phone, verify no crash. Change-Id: I172daade74bec7374b5fd3310c1bf554e46d8832 --- .../core/java/com/android/server/wm/TaskStack.java | 2 +- .../com/android/server/wm/WindowStateAnimator.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 0ff1f0c9f2cd7..538f0d9f85526 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -1479,7 +1479,7 @@ public class TaskStack extends WindowContainer implements DimLayer.DimLaye return StackId.hasMovementAnimations(mStackId); } - public boolean getForceScaleToCrop() { + public boolean getForceScaleToStack() { return mBoundsAnimating; } diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index abce222bf33fa..b163abf9f20eb 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1313,18 +1313,20 @@ class WindowStateAnimator { float surfaceWidth = mSurfaceController.getWidth(); float surfaceHeight = mSurfaceController.getHeight(); - if ((task != null && task.mStack.getForceScaleToCrop()) || mForceScaleUntilResize) { + if ((task != null && task.mStack.getForceScaleToStack()) || mForceScaleUntilResize) { int hInsets = w.getAttrs().surfaceInsets.left + w.getAttrs().surfaceInsets.right; int vInsets = w.getAttrs().surfaceInsets.top + w.getAttrs().surfaceInsets.bottom; if (!mForceScaleUntilResize) { mSurfaceController.forceScaleableInTransaction(true); } + + task.mStack.getDimBounds(mTmpStackBounds); // We want to calculate the scaling based on the content area, not based on // the entire surface, so that we scale in sync with windows that don't have insets. - mExtraHScale = (finalClipRect.width() - hInsets) / (float)(surfaceWidth - hInsets); - mExtraVScale = (finalClipRect.height() - vInsets) / (float)(surfaceHeight - vInsets); + mExtraHScale = (mTmpStackBounds.width() - hInsets) / (float)(surfaceWidth - hInsets); + mExtraVScale = (mTmpStackBounds.height() - vInsets) / (float)(surfaceHeight - vInsets); - // In the case of ForceScaleToCrop we scale entire tasks together, + // In the case of ForceScaleToStack we scale entire tasks together, // and so we need to scale our offsets relative to the task bounds // or parent and child windows would fall out of alignment. int posX = (int) (mTmpSize.left - w.mAttrs.x * (1 - mExtraHScale));