Loading services/core/java/com/android/server/wm/DisplayContent.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -5395,7 +5395,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp SurfaceControl[] findRoundedCornerOverlays() { SurfaceControl[] findRoundedCornerOverlays() { List<SurfaceControl> roundedCornerOverlays = new ArrayList<>(); List<SurfaceControl> roundedCornerOverlays = new ArrayList<>(); for (WindowToken token : mTokenMap.values()) { for (WindowToken token : mTokenMap.values()) { if (token.mRoundedCornerOverlay) { if (token.mRoundedCornerOverlay && token.isVisible()) { roundedCornerOverlays.add(token.mSurfaceControl); roundedCornerOverlays.add(token.mSurfaceControl); } } } } Loading services/core/java/com/android/server/wm/ScreenRotationAnimation.java +36 −12 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,7 @@ class ScreenRotationAnimation { private SurfaceControl mEnterBlackFrameLayer; private SurfaceControl mEnterBlackFrameLayer; /** This layer contains the actual screenshot that is to be faded out. */ /** This layer contains the actual screenshot that is to be faded out. */ private SurfaceControl mScreenshotLayer; private SurfaceControl mScreenshotLayer; private SurfaceControl[] mRoundedCornerOverlay; /** /** * Only used for screen rotation and not custom animations. Layered behind all other layers * Only used for screen rotation and not custom animations. Layered behind all other layers * to avoid showing any "empty" spots * to avoid showing any "empty" spots Loading Loading @@ -151,6 +152,11 @@ class ScreenRotationAnimation { final boolean flipped = delta == Surface.ROTATION_90 || delta == Surface.ROTATION_270; final boolean flipped = delta == Surface.ROTATION_90 || delta == Surface.ROTATION_270; mOriginalWidth = flipped ? height : width; mOriginalWidth = flipped ? height : width; mOriginalHeight = flipped ? width : height; mOriginalHeight = flipped ? width : height; final int logicalWidth = displayInfo.logicalWidth; final int logicalHeight = displayInfo.logicalHeight; final boolean isSizeChanged = logicalWidth > mOriginalWidth == logicalHeight > mOriginalHeight && (logicalWidth != mOriginalWidth || logicalHeight != mOriginalHeight); mSurfaceRotationAnimationController = new SurfaceRotationAnimationController(); mSurfaceRotationAnimationController = new SurfaceRotationAnimationController(); // Check whether the current screen contains any secure content. // Check whether the current screen contains any secure content. Loading @@ -159,18 +165,23 @@ class ScreenRotationAnimation { final SurfaceControl.Transaction t = mService.mTransactionFactory.get(); final SurfaceControl.Transaction t = mService.mTransactionFactory.get(); try { try { SurfaceControl.LayerCaptureArgs args = SurfaceControl.LayerCaptureArgs.Builder builder = new SurfaceControl.LayerCaptureArgs.Builder(displayContent.getSurfaceControl()) new SurfaceControl.LayerCaptureArgs.Builder(displayContent.getSurfaceControl()) .setCaptureSecureLayers(true) .setCaptureSecureLayers(true) .setAllowProtected(true) .setAllowProtected(true) .setSourceCrop(new Rect(0, 0, width, height)) .setSourceCrop(new Rect(0, 0, width, height)); if (isSizeChanged) { mRoundedCornerOverlay = displayContent.findRoundedCornerOverlays(); } else { // Exclude rounded corner overlay from screenshot buffer. Rounded // Exclude rounded corner overlay from screenshot buffer. Rounded // corner overlay windows are un-rotated during rotation animation // corner overlay windows are un-rotated during rotation animation // for a seamless transition. // for a seamless transition. .setExcludeLayers(displayContent.findRoundedCornerOverlays()) builder.setExcludeLayers(displayContent.findRoundedCornerOverlays()); .build(); } SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = SurfaceControl.captureLayers(args); SurfaceControl.captureLayers(builder.build()); if (screenshotBuffer == null) { if (screenshotBuffer == null) { Slog.w(TAG, "Unable to take screenshot of display " + displayId); Slog.w(TAG, "Unable to take screenshot of display " + displayId); return; return; Loading Loading @@ -232,6 +243,14 @@ class ScreenRotationAnimation { t.show(mScreenshotLayer); t.show(mScreenshotLayer); t.show(mBackColorSurface); t.show(mBackColorSurface); if (mRoundedCornerOverlay != null) { for (SurfaceControl sc : mRoundedCornerOverlay) { if (sc.isValid()) { t.hide(sc); } } } } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate freeze surface", e); Slog.w(TAG, "Unable to allocate freeze surface", e); } } Loading @@ -240,10 +259,7 @@ class ScreenRotationAnimation { // the new logical display size. Currently pending transaction and RWC#mDisplayTransaction // the new logical display size. Currently pending transaction and RWC#mDisplayTransaction // are merged to global transaction, so it can be synced with display change when calling // are merged to global transaction, so it can be synced with display change when calling // DisplayManagerInternal#performTraversal(transaction). // DisplayManagerInternal#performTraversal(transaction). final int logicalWidth = displayInfo.logicalWidth; if (mScreenshotLayer != null && isSizeChanged) { final int logicalHeight = displayInfo.logicalHeight; if (logicalWidth > mOriginalWidth == logicalHeight > mOriginalHeight && (logicalWidth != mOriginalWidth || logicalHeight != mOriginalHeight)) { displayContent.getPendingTransaction().setGeometry(mScreenshotLayer, displayContent.getPendingTransaction().setGeometry(mScreenshotLayer, new Rect(0, 0, mOriginalWidth, mOriginalHeight), new Rect(0, 0, mOriginalWidth, mOriginalHeight), new Rect(0, 0, logicalWidth, logicalHeight), Surface.ROTATION_0); new Rect(0, 0, logicalWidth, logicalHeight), Surface.ROTATION_0); Loading Loading @@ -472,6 +488,14 @@ class ScreenRotationAnimation { } } mBackColorSurface = null; mBackColorSurface = null; } } if (mRoundedCornerOverlay != null) { for (SurfaceControl sc : mRoundedCornerOverlay) { if (sc.isValid()) { t.show(sc); } } mRoundedCornerOverlay = null; } t.apply(); t.apply(); } } Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -5395,7 +5395,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp SurfaceControl[] findRoundedCornerOverlays() { SurfaceControl[] findRoundedCornerOverlays() { List<SurfaceControl> roundedCornerOverlays = new ArrayList<>(); List<SurfaceControl> roundedCornerOverlays = new ArrayList<>(); for (WindowToken token : mTokenMap.values()) { for (WindowToken token : mTokenMap.values()) { if (token.mRoundedCornerOverlay) { if (token.mRoundedCornerOverlay && token.isVisible()) { roundedCornerOverlays.add(token.mSurfaceControl); roundedCornerOverlays.add(token.mSurfaceControl); } } } } Loading
services/core/java/com/android/server/wm/ScreenRotationAnimation.java +36 −12 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,7 @@ class ScreenRotationAnimation { private SurfaceControl mEnterBlackFrameLayer; private SurfaceControl mEnterBlackFrameLayer; /** This layer contains the actual screenshot that is to be faded out. */ /** This layer contains the actual screenshot that is to be faded out. */ private SurfaceControl mScreenshotLayer; private SurfaceControl mScreenshotLayer; private SurfaceControl[] mRoundedCornerOverlay; /** /** * Only used for screen rotation and not custom animations. Layered behind all other layers * Only used for screen rotation and not custom animations. Layered behind all other layers * to avoid showing any "empty" spots * to avoid showing any "empty" spots Loading Loading @@ -151,6 +152,11 @@ class ScreenRotationAnimation { final boolean flipped = delta == Surface.ROTATION_90 || delta == Surface.ROTATION_270; final boolean flipped = delta == Surface.ROTATION_90 || delta == Surface.ROTATION_270; mOriginalWidth = flipped ? height : width; mOriginalWidth = flipped ? height : width; mOriginalHeight = flipped ? width : height; mOriginalHeight = flipped ? width : height; final int logicalWidth = displayInfo.logicalWidth; final int logicalHeight = displayInfo.logicalHeight; final boolean isSizeChanged = logicalWidth > mOriginalWidth == logicalHeight > mOriginalHeight && (logicalWidth != mOriginalWidth || logicalHeight != mOriginalHeight); mSurfaceRotationAnimationController = new SurfaceRotationAnimationController(); mSurfaceRotationAnimationController = new SurfaceRotationAnimationController(); // Check whether the current screen contains any secure content. // Check whether the current screen contains any secure content. Loading @@ -159,18 +165,23 @@ class ScreenRotationAnimation { final SurfaceControl.Transaction t = mService.mTransactionFactory.get(); final SurfaceControl.Transaction t = mService.mTransactionFactory.get(); try { try { SurfaceControl.LayerCaptureArgs args = SurfaceControl.LayerCaptureArgs.Builder builder = new SurfaceControl.LayerCaptureArgs.Builder(displayContent.getSurfaceControl()) new SurfaceControl.LayerCaptureArgs.Builder(displayContent.getSurfaceControl()) .setCaptureSecureLayers(true) .setCaptureSecureLayers(true) .setAllowProtected(true) .setAllowProtected(true) .setSourceCrop(new Rect(0, 0, width, height)) .setSourceCrop(new Rect(0, 0, width, height)); if (isSizeChanged) { mRoundedCornerOverlay = displayContent.findRoundedCornerOverlays(); } else { // Exclude rounded corner overlay from screenshot buffer. Rounded // Exclude rounded corner overlay from screenshot buffer. Rounded // corner overlay windows are un-rotated during rotation animation // corner overlay windows are un-rotated during rotation animation // for a seamless transition. // for a seamless transition. .setExcludeLayers(displayContent.findRoundedCornerOverlays()) builder.setExcludeLayers(displayContent.findRoundedCornerOverlays()); .build(); } SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = SurfaceControl.captureLayers(args); SurfaceControl.captureLayers(builder.build()); if (screenshotBuffer == null) { if (screenshotBuffer == null) { Slog.w(TAG, "Unable to take screenshot of display " + displayId); Slog.w(TAG, "Unable to take screenshot of display " + displayId); return; return; Loading Loading @@ -232,6 +243,14 @@ class ScreenRotationAnimation { t.show(mScreenshotLayer); t.show(mScreenshotLayer); t.show(mBackColorSurface); t.show(mBackColorSurface); if (mRoundedCornerOverlay != null) { for (SurfaceControl sc : mRoundedCornerOverlay) { if (sc.isValid()) { t.hide(sc); } } } } catch (OutOfResourcesException e) { } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate freeze surface", e); Slog.w(TAG, "Unable to allocate freeze surface", e); } } Loading @@ -240,10 +259,7 @@ class ScreenRotationAnimation { // the new logical display size. Currently pending transaction and RWC#mDisplayTransaction // the new logical display size. Currently pending transaction and RWC#mDisplayTransaction // are merged to global transaction, so it can be synced with display change when calling // are merged to global transaction, so it can be synced with display change when calling // DisplayManagerInternal#performTraversal(transaction). // DisplayManagerInternal#performTraversal(transaction). final int logicalWidth = displayInfo.logicalWidth; if (mScreenshotLayer != null && isSizeChanged) { final int logicalHeight = displayInfo.logicalHeight; if (logicalWidth > mOriginalWidth == logicalHeight > mOriginalHeight && (logicalWidth != mOriginalWidth || logicalHeight != mOriginalHeight)) { displayContent.getPendingTransaction().setGeometry(mScreenshotLayer, displayContent.getPendingTransaction().setGeometry(mScreenshotLayer, new Rect(0, 0, mOriginalWidth, mOriginalHeight), new Rect(0, 0, mOriginalWidth, mOriginalHeight), new Rect(0, 0, logicalWidth, logicalHeight), Surface.ROTATION_0); new Rect(0, 0, logicalWidth, logicalHeight), Surface.ROTATION_0); Loading Loading @@ -472,6 +488,14 @@ class ScreenRotationAnimation { } } mBackColorSurface = null; mBackColorSurface = null; } } if (mRoundedCornerOverlay != null) { for (SurfaceControl sc : mRoundedCornerOverlay) { if (sc.isValid()) { t.show(sc); } } mRoundedCornerOverlay = null; } t.apply(); t.apply(); } } Loading