From 7675809673697d6d8f3a293dfb44d205aff89739 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 6 Oct 2020 13:41:15 -0700 Subject: [PATCH] ScreenRotationAnimation: Use Surface#setScalingMode We are the last user of SurfaceControl#setOverrideScalingMode in ScreenRotationAnimation we have no need to call it since we are the BufferProducer and we can just use Surface#setScalingMode Bug: 161937501 Test: Existing tests pass Change-Id: I049145a91fedbbca5f009648f1537b0380c5e771 --- core/java/android/view/Surface.java | 2 +- .../com/android/server/wm/ScreenRotationAnimation.java | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 5b0d950e3bd8f..0847a179c5535 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -739,7 +739,7 @@ public class Surface implements Parcelable { * Set the scaling mode to be used for this surfaces buffers * @hide */ - void setScalingMode(@ScalingMode int scalingMode) { + public void setScalingMode(@ScalingMode int scalingMode) { synchronized (mLock) { checkNotReleasedLocked(); int err = nativeSetScalingMode(mNativeObject, scalingMode); diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java index 25732e7f0d995..7ed22a1f7777e 100644 --- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java @@ -203,16 +203,14 @@ class ScreenRotationAnimation { .setCallsite("ScreenRotationAnimation") .build(); - // In case display bounds change, screenshot buffer and surface may mismatch so set a - // scaling mode. - SurfaceControl.Transaction t2 = mService.mTransactionFactory.get(); - t2.setOverrideScalingMode(mScreenshotLayer, Surface.SCALING_MODE_SCALE_TO_WINDOW); - t2.apply(true /* sync */); - // Capture a screenshot into the surface we just created. final int displayId = displayContent.getDisplayId(); final Surface surface = mService.mSurfaceFactory.get(); + // In case display bounds change, screenshot buffer and surface may mismatch so set a + // scaling mode. surface.copyFrom(mScreenshotLayer); + surface.setScalingMode(Surface.SCALING_MODE_SCALE_TO_WINDOW); + SurfaceControl.ScreenshotHardwareBuffer screenshotBuffer = mService.mDisplayManagerInternal.systemScreenshot(displayId); if (screenshotBuffer != null) {