diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 67924307f009a..adf330f0db454 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7864,7 +7864,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A InsetUtils.addInsets(insets, getLetterboxInsets()); return new RemoteAnimationTarget(task.mTaskId, record.getMode(), record.mAdapter.mCapturedLeash, !fillsParent(), - mainWindow.mWinAnimator.mLastClipRect, insets, + new Rect(), insets, getPrefixOrderIndex(), record.mAdapter.mPosition, record.mAdapter.mLocalBounds, record.mAdapter.mStackBounds, task.getWindowConfiguration(), false /*isNotInRecents*/, diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index b50cb4c34398b..42a20ff7ed7bb 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -929,7 +929,7 @@ public class RecentsAnimationController implements DeathRecipient { ? MODE_OPENING : MODE_CLOSING; mTarget = new RemoteAnimationTarget(mTask.mTaskId, mode, mCapturedLeash, - !topApp.fillsParent(), mainWindow.mWinAnimator.mLastClipRect, + !topApp.fillsParent(), new Rect(), insets, mTask.getPrefixOrderIndex(), new Point(mBounds.left, mBounds.top), mLocalBounds, mBounds, mTask.getWindowConfiguration(), mIsRecentTaskInvisible, null, null); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 0a1c184d84853..f01b68f4393f2 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -4952,93 +4952,6 @@ class WindowState extends WindowContainer implements WindowManagerP return mToken.canLayerAboveSystemBars(); } - /** - * Calculate the window crop according to system decor policy. In general this is - * the system decor rect (see #calculateSystemDecorRect), but we also have some - * special cases. This rectangle is in screen space. - */ - void calculatePolicyCrop(Rect policyCrop) { - final DisplayContent displayContent = getDisplayContent(); - - if (!displayContent.isDefaultDisplay && !displayContent.supportsSystemDecorations()) { - // On a different display there is no system decor. Crop the window - // by the screen boundaries. - final DisplayInfo displayInfo = getDisplayInfo(); - policyCrop.set(0, 0, mWindowFrames.mCompatFrame.width(), - mWindowFrames.mCompatFrame.height()); - policyCrop.intersect(-mWindowFrames.mCompatFrame.left, -mWindowFrames.mCompatFrame.top, - displayInfo.logicalWidth - mWindowFrames.mCompatFrame.left, - displayInfo.logicalHeight - mWindowFrames.mCompatFrame.top); - } else if (skipDecorCrop()) { - // Windows without policy decor aren't cropped. - policyCrop.set(0, 0, mWindowFrames.mCompatFrame.width(), - mWindowFrames.mCompatFrame.height()); - } else { - // Crop to the system decor specified by policy. - calculateSystemDecorRect(policyCrop); - } - } - - /** - * The system decor rect is the region of the window which is not covered - * by system decorations. - */ - private void calculateSystemDecorRect(Rect systemDecorRect) { - final Rect decorRect = mWindowFrames.mDecorFrame; - final int width = mWindowFrames.mFrame.width(); - final int height = mWindowFrames.mFrame.height(); - - final int left = mWindowFrames.mFrame.left; - final int top = mWindowFrames.mFrame.top; - - // Initialize the decor rect to the entire frame. - if (isDockedResizing()) { - // If we are resizing with the divider, the task bounds might be smaller than the - // stack bounds. The system decor is used to clip to the task bounds, which we don't - // want in this case in order to avoid holes. - // - // We take care to not shrink the width, for surfaces which are larger than - // the display region. Of course this area will not eventually be visible - // but if we truncate the width now, we will calculate incorrectly - // when adjusting to the stack bounds. - final DisplayInfo displayInfo = getDisplayContent().getDisplayInfo(); - systemDecorRect.set(0, 0, - Math.max(width, displayInfo.logicalWidth), - Math.max(height, displayInfo.logicalHeight)); - } else { - systemDecorRect.set(0, 0, width, height); - } - - // If a freeform window is animating from a position where it would be cutoff, it would be - // cutoff during the animation. We don't want that, so for the duration of the animation - // we ignore the decor cropping and depend on layering to position windows correctly. - - // We also ignore cropping when the window is currently being drag resized in split screen - // to prevent issues with the crop for screenshot. - final boolean cropToDecor = - !(inFreeformWindowingMode() && isAnimatingLw()) && !isDockedResizing(); - if (cropToDecor) { - // Intersect with the decor rect, offsetted by window position. - systemDecorRect.intersect(decorRect.left - left, decorRect.top - top, - decorRect.right - left, decorRect.bottom - top); - } - - // If size compatibility is being applied to the window, the - // surface is scaled relative to the screen. Also apply this - // scaling to the crop rect. We aren't using the standard rect - // scale function because we want to round things to make the crop - // always round to a larger rect to ensure we don't crop too - // much and hide part of the window that should be seen. - if (mInvGlobalScale != 1.0f && inSizeCompatMode()) { - final float scale = mInvGlobalScale; - systemDecorRect.left = (int) (systemDecorRect.left * scale - 0.5f); - systemDecorRect.top = (int) (systemDecorRect.top * scale - 0.5f); - systemDecorRect.right = (int) ((systemDecorRect.right + 1) * scale - 0.5f); - systemDecorRect.bottom = (int) ((systemDecorRect.bottom + 1) * scale - 0.5f); - } - - } - /** * Expand the given rectangle by this windows surface insets. This * takes you from the 'window size' to the 'surface size'. diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index a31c5fef29b80..1f7324d4d7801 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -135,9 +135,6 @@ class WindowStateAnimator { float mAlpha = 0; float mLastAlpha = 0; - Rect mTmpClipRect = new Rect(); - Rect mLastClipRect = new Rect(); - Rect mLastFinalClipRect = new Rect(); Rect mTmpStackBounds = new Rect(); private Rect mTmpAnimatingBounds = new Rect(); private Rect mTmpSourceBounds = new Rect(); @@ -469,9 +466,6 @@ class WindowStateAnimator { + " format=" + attrs.format + " flags=" + flags); } - // We may abort, so initialize to defaults. - mLastClipRect.set(0, 0, 0, 0); - // Set up surface control with initial size. try { @@ -641,77 +635,6 @@ class WindowStateAnimator { mDsDy = mWin.mGlobalScale; } - /** - * Calculate the window-space crop rect and fill clipRect. - * @return true if clipRect has been filled otherwise, no window space crop should be applied. - */ - private boolean calculateCrop(Rect clipRect) { - final WindowState w = mWin; - final DisplayContent displayContent = w.getDisplayContent(); - clipRect.setEmpty(); - - if (displayContent == null) { - return false; - } - - if (w.getWindowConfiguration().tasksAreFloating() - || WindowConfiguration.isSplitScreenWindowingMode(w.getWindowingMode())) { - return false; - } - - // During forced seamless rotation, the surface bounds get updated with the crop in the - // new rotation, which is not compatible with showing the surface in the old rotation. - // To work around that we disable cropping for such windows, as it is not necessary anyways. - if (w.mForceSeamlesslyRotate) { - return false; - } - - // If we're animating, the wallpaper should only - // be updated at the end of the animation. - if (w.mAttrs.type == TYPE_WALLPAPER) { - return false; - } - - if (DEBUG_WINDOW_CROP) Slog.d(TAG, - "Updating crop win=" + w + " mLastCrop=" + mLastClipRect); - - w.calculatePolicyCrop(mSystemDecorRect); - - if (DEBUG_WINDOW_CROP) Slog.d(TAG, "Applying decor to crop win=" + w + " mDecorFrame=" - + w.getDecorFrame() + " mSystemDecorRect=" + mSystemDecorRect); - - // We use the clip rect as provided by the tranformation for non-fullscreen windows to - // avoid premature clipping with the system decor rect. - clipRect.set(mSystemDecorRect); - if (DEBUG_WINDOW_CROP) Slog.d(TAG, "win=" + w + " Initial clip rect: " + clipRect); - - w.expandForSurfaceInsets(clipRect); - - // The clip rect was generated assuming (0,0) as the window origin, - // so we need to translate to match the actual surface coordinates. - clipRect.offset(w.mAttrs.surfaceInsets.left, w.mAttrs.surfaceInsets.top); - - if (DEBUG_WINDOW_CROP) Slog.d(TAG, - "win=" + w + " Clip rect after stack adjustment=" + clipRect); - - w.transformClipRectFromScreenToSurfaceSpace(clipRect); - - return true; - } - - private void applyCrop(Rect clipRect, boolean recoveringMemory) { - if (DEBUG_WINDOW_CROP) Slog.d(TAG, "applyCrop: win=" + mWin - + " clipRect=" + clipRect); - if (clipRect != null) { - if (!clipRect.equals(mLastClipRect)) { - mLastClipRect.set(clipRect); - mSurfaceController.setCropInTransaction(clipRect, recoveringMemory); - } - } else { - mSurfaceController.clearCropInTransaction(recoveringMemory); - } - } - private boolean shouldConsumeMainWindowSizeTransaction() { // We only consume the transaction when the client is calling relayout // because this is the only time we know the frameNumber will be valid @@ -738,15 +661,6 @@ class WindowStateAnimator { final LayoutParams attrs = mWin.getAttrs(); final Task task = w.getTask(); - // If we are undergoing seamless rotation, the surface has already - // been set up to persist at it's old location. We need to freeze - // updates until a resize occurs. - - Rect clipRect = null; - if (calculateCrop(mTmpClipRect)) { - clipRect = mTmpClipRect; - } - if (shouldConsumeMainWindowSizeTransaction()) { task.getMainWindowSizeChangeTask().getSurfaceControl().deferTransactionUntil( mWin.getClientViewRootSurface(), mWin.getFrameNumber()); @@ -788,12 +702,6 @@ class WindowStateAnimator { } xOffset = -mTmpPos.x; yOffset = -mTmpPos.y; - // Crop also needs to be extended so the bottom isn't cut off when the WSA - // position is moved. - if (clipRect != null) { - clipRect.right += mTmpPos.x; - clipRect.bottom += mTmpPos.y; - } } } if (!mIsWallpaper) { @@ -808,7 +716,6 @@ class WindowStateAnimator { // Wallpaper is already updated above when calling setWallpaperPositionAndScale so // we only need to consider the non-wallpaper case here. if (!mIsWallpaper) { - applyCrop(clipRect, recoveringMemory); mSurfaceController.setMatrixInTransaction( mDsDx * w.mHScale, mDtDx * w.mVScale, @@ -1010,7 +917,6 @@ class WindowStateAnimator { mDtDy * mWin.mTmpMatrixArray[MSKEW_X] * mWin.mHScale, mDsDy * mWin.mTmpMatrixArray[MSCALE_Y] * mWin.mVScale, recoveringMemory); - applyCrop(null, recoveringMemory); } /** @@ -1201,7 +1107,6 @@ class WindowStateAnimator { void dumpDebug(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); - mLastClipRect.dumpDebug(proto, LAST_CLIP_RECT); if (mSurfaceController != null) { mSurfaceController.dumpDebug(proto, SURFACE); } @@ -1222,11 +1127,7 @@ class WindowStateAnimator { pw.print(prefix); pw.print(" mLastHidden="); pw.println(mLastHidden); pw.print(prefix); pw.print("mEnterAnimationPending=" + mEnterAnimationPending); pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw); - pw.print(" mLastClipRect="); mLastClipRect.printShortString(pw); - if (!mLastFinalClipRect.isEmpty()) { - pw.print(" mLastFinalClipRect="); mLastFinalClipRect.printShortString(pw); - } pw.println(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java index 13f04d23ccd34..2efd4b53efccb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java @@ -117,7 +117,6 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { assertEquals(win.mActivityRecord.getPrefixOrderIndex(), app.prefixOrderIndex); assertEquals(win.mActivityRecord.getTask().mTaskId, app.taskId); assertEquals(mMockLeash, app.leash); - assertEquals(win.mWinAnimator.mLastClipRect, app.clipRect); assertEquals(false, app.isTranslucent); verify(mMockTransaction).setPosition(mMockLeash, app.position.x, app.position.y); verify(mMockTransaction).setWindowCrop(mMockLeash, 100, 50); @@ -274,7 +273,6 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { assertEquals(new Rect(0, 0, 200, 200), app.startBounds); assertEquals(mMockLeash, app.leash); assertEquals(mMockThumbnailLeash, app.startLeash); - assertEquals(win.mWinAnimator.mLastClipRect, app.clipRect); assertEquals(false, app.isTranslucent); verify(mMockTransaction).setPosition( mMockLeash, app.startBounds.left, app.startBounds.top); @@ -325,7 +323,6 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { assertEquals(new Rect(50, 100, 150, 150), app.startBounds); assertEquals(mMockLeash, app.leash); assertEquals(mMockThumbnailLeash, app.startLeash); - assertEquals(win.mWinAnimator.mLastClipRect, app.clipRect); assertEquals(false, app.isTranslucent); verify(mMockTransaction).setPosition( mMockLeash, app.startBounds.left, app.startBounds.top); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java index ca3626d09062b..0cf63f4ff21d6 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java @@ -115,12 +115,6 @@ public class WindowFrameTests extends WindowTestsBase { expectedRect.bottom); } - private void assertPolicyCrop(WindowState w, int left, int top, int right, int bottom) { - Rect policyCrop = new Rect(); - w.calculatePolicyCrop(policyCrop); - assertRect(policyCrop, left, top, right, bottom); - } - @Test public void testLayoutInFullscreenTaskInsets() { // fullscreen task doesn't use bounds for computeFrame @@ -335,12 +329,10 @@ public class WindowFrameTests extends WindowTestsBase { final WindowFrames windowFrames = w.getWindowFrames(); windowFrames.setFrames(pf, df, cf, vf, dcf, sf); w.computeFrame(); - assertPolicyCrop(w, 0, cf.top, logicalWidth, cf.bottom); windowFrames.mDecorFrame.setEmpty(); // Likewise with no decor frame we would get no crop w.computeFrame(); - assertPolicyCrop(w, 0, 0, logicalWidth, logicalHeight); // Now we set up a window which doesn't fill the entire decor frame. // Normally it would be cropped to it's frame but in the case of docked resizing @@ -355,16 +347,7 @@ public class WindowFrameTests extends WindowTestsBase { w.mRequestedHeight = logicalHeight / 2; w.computeFrame(); - // Normally the crop is shrunk from the decor frame - // to the computed window frame. - assertPolicyCrop(w, 0, 0, logicalWidth / 2, logicalHeight / 2); - doReturn(true).when(w).isDockedResizing(); - // But if we are docked resizing it won't be, however we will still be - // shrunk to the decor frame and the display. - assertPolicyCrop(w, 0, 0, - Math.min(pf.width(), displayInfo.logicalWidth), - Math.min(pf.height(), displayInfo.logicalHeight)); } @Test