From 127b0e6f1e5371761e5dd2c22087fc07010a0380 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 10 Feb 2021 10:40:04 -0800 Subject: [PATCH] Use surface size instead of frame size when adjusting layer bounds When exiting splitscreen we can end up cropping the SurfaceView incorrectly. This is because when drag drag resizing, the surface is resized to full screen and the window frame is updated in a subsequent relayout call. To fix this we use the surface size after adjusting for surface insets. Test: exit chrome from splitscreen to fullscreen, check that SV resizes correctly Test: atest SurfaceViewSyncTest Test: go/wm-smoke Fixes: 179911825 Change-Id: I0ccbdb5afa507b7a67e6aa7071ab5fb71f8a8cb8 --- core/java/android/view/ViewRootImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 036a703f178c8..3e1451ffd3a09 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1897,11 +1897,12 @@ public final class ViewRootImpl implements ViewParent, } private void setBoundsLayerCrop(Transaction t) { - // mWinFrame is already adjusted for surface insets. So offset it and use it as - // the cropping bounds. - mTempBoundsRect.set(mWinFrame); - mTempBoundsRect.offsetTo(mWindowAttributes.surfaceInsets.left, - mWindowAttributes.surfaceInsets.top); + // Adjust of insets and update the bounds layer so child surfaces do not draw into + // the surface inset region. + mTempBoundsRect.set(0, 0, mSurfaceSize.x, mSurfaceSize.y); + mTempBoundsRect.inset(mWindowAttributes.surfaceInsets.left, + mWindowAttributes.surfaceInsets.top, + mWindowAttributes.surfaceInsets.right, mWindowAttributes.surfaceInsets.bottom); t.setWindowCrop(mBoundsLayer, mTempBoundsRect); }