From a0876641342c29e87f543d5315f62eaab473ed69 Mon Sep 17 00:00:00 2001 From: Santiago Etchebehere Date: Mon, 30 Mar 2020 11:28:49 -0700 Subject: [PATCH] Account for wallpaper scale in prepareSurfaceLocked This fixes a flicker in the wallpaper when rotating the screen that was caused because prepareSurface was scaling and translating the surface without considering the zoom-in scale that is applied everywhere else to wallpapers so the end result was the surface being scaled down then up again. Also clean up a bit the usages of setWallpaperPositionAndScale Bug: 152002715 Fixes: 152376185 Test: manual Change-Id: I2d2d74a411bee13bee1a7b4cce3744ee450ac549 --- .../android/server/wm/WindowStateAnimator.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 563710b9e41be..9e6550cd307d4 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1066,14 +1066,15 @@ class WindowStateAnimator { if (!w.mSeamlesslyRotated) { + // 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 * mExtraHScale, + mSurfaceController.setMatrixInTransaction( + mDsDx * w.mHScale * mExtraHScale, mDtDx * w.mVScale * mExtraVScale, mDtDy * w.mHScale * mExtraHScale, mDsDy * w.mVScale * mExtraVScale, recoveringMemory); - } else { - setWallpaperPositionAndScale(mXOffset, mYOffset, mWallpaperScale, recoveringMemory); } } @@ -1152,13 +1153,20 @@ class WindowStateAnimator { mSurfaceController, mShownAlpha, mDsDx, w.mHScale, mDtDx, w.mVScale, mDtDy, w.mHScale, mDsDy, w.mVScale, w); - boolean prepared = - mSurfaceController.prepareToShowInTransaction(mShownAlpha, + boolean prepared = true; + + if (mIsWallpaper) { + setWallpaperPositionAndScale( + mXOffset, mYOffset, mWallpaperScale, recoveringMemory); + } else { + prepared = + mSurfaceController.prepareToShowInTransaction(mShownAlpha, mDsDx * w.mHScale * mExtraHScale, mDtDx * w.mVScale * mExtraVScale, mDtDy * w.mHScale * mExtraHScale, mDsDy * w.mVScale * mExtraVScale, recoveringMemory); + } if (prepared && mDrawState == HAS_DRAWN) { if (mLastHidden) {