summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Carr <racarr@google.com> 2018-02-23 12:17:51 -0800
committer Robert Carr <racarr@google.com> 2018-02-28 11:43:10 -0800
commit74a66a2c7ba0ee3472d4863c958df5d41bbc3267 (patch)
tree703787656f48f170056baa278f9f4dd846f3eedb
parent217e7cc2212204bb14eae15c055ee0c2d640e861 (diff)
Various pinned animation bug fixes.
First we need to change the way the aspect scale cropping happens on the way down, previously we relied on the stack bounds to crop us and did not expand the stack bounds for shadows. Now that the stack surface bounds are expanded for shadows we have to do the additional cropping required by this animation at the WSA level. Namely we interpolate such that when the animation reaches 100% progress everything except the source bounds will be cropped out. If we didn't do this we would see a surfaceInsets sized sliver of the original app at the end of the animation. A second fix is to update the stack bounds when changing windowing modes to make sure we immediately expand for the pinned insets (as the WindowState level may now immediately reposition to compensate). A third fix is to correct the stack outset logic to match the client side in WindowManager.java A fourth fix is to bump the default and arbitrary surface size to allow for surfaces slightly larger than full-screen and positioned at a negative position, e.g. a full-screen-surface which retained it's insets due to a slow or non-cooperative client. Bug: 70666541 Test: Manual. go/wm-smoke. Change-Id: I045ddf191cd3875f5d32c2e15da6e01fb50f3a01
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java9
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java30
3 files changed, 35 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 19c634a55d5a..332bdb7fa8fb 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -747,7 +747,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
mDividerControllerLocked = new DockedStackDividerController(service, this);
mPinnedStackControllerLocked = new PinnedStackController(service, this);
- mSurfaceSize = Math.max(mBaseDisplayHeight, mBaseDisplayWidth);
+ // We use this as our arbitrary surface size for buffer-less parents
+ // that don't impose cropping on their children. It may need to be larger
+ // than the display size because fullscreen windows can be shifted offscreen
+ // due to surfaceInsets. 2 times the largest display dimension feels like an
+ // appropriately arbitrary number. Eventually we would like to give SurfaceFlinger
+ // layers the ability to match their parent sizes and be able to skip
+ // such arbitrary size settings.
+ mSurfaceSize = Math.max(mBaseDisplayHeight, mBaseDisplayWidth) * 2;
final SurfaceControl.Builder b = mService.makeSurfaceBuilder(mSession)
.setSize(mSurfaceSize, mSurfaceSize)
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index ba08fcd2e177..b5d00a75d7e6 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -751,8 +751,11 @@ public class TaskStack extends WindowContainer<Task> implements
int getStackOutset() {
if (inPinnedWindowingMode()) {
final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
- return mService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP,
- displayMetrics);
+
+ // We multiply by two to match the client logic for converting view elevation
+ // to insets, as in {@link WindowManager.LayoutParams#setSurfaceInsets}
+ return (int)Math.ceil(mService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP,
+ displayMetrics) * 2);
}
return 0;
}
@@ -824,6 +827,7 @@ public class TaskStack extends WindowContainer<Task> implements
}
updateDisplayInfo(bounds);
+ updateSurfaceBounds();
}
/**
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 92145be92115..0e80819a149f 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -862,17 +862,19 @@ class WindowStateAnimator {
float surfaceWidth = mSurfaceController.getWidth();
float surfaceHeight = mSurfaceController.getHeight();
+ final Rect insets = attrs.surfaceInsets;
+
if (isForceScaled()) {
- int hInsets = attrs.surfaceInsets.left + attrs.surfaceInsets.right;
- int vInsets = attrs.surfaceInsets.top + attrs.surfaceInsets.bottom;
+ int hInsets = insets.left + insets.right;
+ int vInsets = insets.top + insets.bottom;
float surfaceContentWidth = surfaceWidth - hInsets;
float surfaceContentHeight = surfaceHeight - vInsets;
if (!mForceScaleUntilResize) {
mSurfaceController.forceScaleableInTransaction(true);
}
- int posX = mTmpSize.left;
- int posY = mTmpSize.top;
+ int posX = 0;
+ int posY = 0;
task.mStack.getDimBounds(mTmpStackBounds);
boolean allowStretching = false;
@@ -919,9 +921,19 @@ class WindowStateAnimator {
posX -= (int) (tw * mExtraHScale * mTmpSourceBounds.left);
posY -= (int) (th * mExtraVScale * mTmpSourceBounds.top);
- // Always clip to the stack bounds since the surface can be larger with the current
- // scale
- clipRect = null;
+ // In pinned mode the clip rectangle applied to us by our stack has been
+ // expanded outwards to allow for shadows. However in case of source bounds set
+ // we need to crop to within the surface. The code above has scaled and positioned
+ // the surface to fit the unexpanded stack bounds, but now we need to reapply
+ // the cropping that the stack would have applied if it weren't expanded. This
+ // can be different in each direction based on the source bounds.
+ clipRect = mTmpClipRect;
+ clipRect.set((int)((insets.left + mTmpSourceBounds.left) * tw),
+ (int)((insets.top + mTmpSourceBounds.top) * th),
+ insets.left + (int)(surfaceWidth
+ - (tw* (surfaceWidth - mTmpSourceBounds.right))),
+ insets.top + (int)(surfaceHeight
+ - (th * (surfaceHeight - mTmpSourceBounds.bottom))));
} else {
// 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.
@@ -947,8 +959,8 @@ class WindowStateAnimator {
// non inset content at the same position, we have to shift the whole window
// forward. Likewise for scaling up, we've increased this distance, and we need
// to shift by a negative number to compensate.
- posX += attrs.surfaceInsets.left * (1 - mExtraHScale);
- posY += attrs.surfaceInsets.top * (1 - mExtraVScale);
+ posX += insets.left * (1 - mExtraHScale);
+ posY += insets.top * (1 - mExtraVScale);
mSurfaceController.setPositionInTransaction((float) Math.floor(posX),
(float) Math.floor(posY), recoveringMemory);