Ensure crop rect is scaled appropriately.

Crop rectangles are scaled to layer space. Previously
we were doing this for transformation applied crops but
failing to do so for stack applied crops. This ensures
we never fail.

Bug: 23974105
Change-Id: I82f59a8696b87253f92cd89fe675aaeab0ecb38d
This commit is contained in:
Robert Carr
2015-10-29 14:19:05 -07:00
committed by Rob Carr
parent ec034cdb63
commit 58f2913f17
2 changed files with 14 additions and 13 deletions

View File

@@ -1968,4 +1968,13 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
return mStringNameCache;
}
void transformFromScreenToSurfaceSpace(Rect rect) {
if (mHScale >= 0) {
rect.right = rect.left + (int)((rect.right - rect.left) / mHScale);
}
if (mVScale >= 0) {
rect.bottom = rect.top + (int)((rect.bottom - rect.top) / mVScale);
}
}
}

View File

@@ -1224,14 +1224,6 @@ class WindowStateAnimator {
mShownAlpha *= appTransformation.getAlpha();
if (appTransformation.hasClipRect()) {
mClipRect.set(appTransformation.getClipRect());
if (mWin.mHScale > 0) {
mClipRect.left /= mWin.mHScale;
mClipRect.right /= mWin.mHScale;
}
if (mWin.mVScale > 0) {
mClipRect.top /= mWin.mVScale;
mClipRect.bottom /= mWin.mVScale;
}
mHasClipRect = true;
}
}
@@ -1351,11 +1343,7 @@ class WindowStateAnimator {
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
// Need to recompute a new system decor rect each time.
if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
// Currently can't do this cropping for scaled windows. We'll
// just keep the crop rect the same as the source surface.
w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight);
} else if (!w.isDefaultDisplay()) {
if (!w.isDefaultDisplay()) {
// On a different display there is no system decor. Crop the window
// by the screen boundaries.
w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
@@ -1408,9 +1396,13 @@ class WindowStateAnimator {
clipRect.offset(attrs.surfaceInsets.left, attrs.surfaceInsets.top);
// We don't want to clip to stack bounds windows that are currently doing entrance
// animation for docked window, otherwise the animating window will be suddenly cut off.
if (!(mAnimator.mAnimating && w.inDockedWorkspace())) {
adjustCropToStackBounds(w, clipRect);
}
w.transformFromScreenToSurfaceSpace(clipRect);
if (!clipRect.equals(mLastClipRect)) {
mLastClipRect.set(clipRect);
try {