From 0900271a8d7cc72cf8121f4f9084392df69c6a98 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 16 Jun 2021 21:27:45 -0700 Subject: [PATCH] WindowState: Correct wallpaper scaling A recent CL moved wallpaper scaling to the WindowState level to avoid fighting with the BLAST adapter at the WindowState level. It mistaken scaled from the top left corner of the wallpaper instead of the center. This CL restores the old logic. Bug: 190532253 Test: Existing tests pass Change-Id: Ic809e69d1a2b57b771e0657ba98b508d062e58c9 --- .../java/com/android/server/wm/WindowState.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 03762b3ee8bf2..93b9bc7b0520d 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5508,7 +5508,19 @@ class WindowState extends WindowContainer implements WindowManagerP mSurfacePlacementNeeded = false; transformFrameToSurfacePosition(mWindowFrames.mFrame.left, mWindowFrames.mFrame.top, mSurfacePosition); - mSurfacePosition.offset(mXOffset, mYOffset); + + if (mWallpaperScale != 1f) { + DisplayInfo displayInfo = getDisplayInfo(); + Matrix matrix = mTmpMatrix; + matrix.setTranslate(mXOffset, mYOffset); + matrix.postScale(mWallpaperScale, mWallpaperScale, displayInfo.logicalWidth / 2f, + displayInfo.logicalHeight / 2f); + matrix.getValues(mTmpMatrixArray); + mSurfacePosition.offset(Math.round(mTmpMatrixArray[Matrix.MTRANS_X]), + Math.round(mTmpMatrixArray[Matrix.MTRANS_Y])); + } else { + mSurfacePosition.offset(mXOffset, mYOffset); + } // Freeze position while we're unrotated, so the surface remains at the position it was // prior to the rotation.