From a0a082b8c99ebbf85cb47e0aa531487047f7f82d Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 5 Apr 2021 15:31:15 -0700 Subject: [PATCH 1/2] WinodowStateAnimator: Remove mD(s|t)d(x|y) They are always either 1 or 0 and so there is no use. We also fix a bug in WindowState#getTransformationMatrix where the value should be equal to mGlobalScale (or at least it was in previous releases). Bug: 161937501 Test: Existing tests pass Change-Id: I8ecc88b6be6b4d9b87bc43a1e0319f33b589b46e --- .../com/android/server/wm/WindowState.java | 8 +-- .../server/wm/WindowStateAnimator.java | 52 ++++++------------- 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 95f3c3711136e..d5d7c00108500 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5175,10 +5175,10 @@ class WindowState extends WindowContainer implements WindowManagerP * @param outMatrix Matrix to fill in the transformation. */ void getTransformationMatrix(float[] float9, Matrix outMatrix) { - float9[Matrix.MSCALE_X] = mWinAnimator.mDsDx; - float9[Matrix.MSKEW_Y] = mWinAnimator.mDtDx; - float9[Matrix.MSKEW_X] = mWinAnimator.mDtDy; - float9[Matrix.MSCALE_Y] = mWinAnimator.mDsDy; + float9[Matrix.MSCALE_X] = mGlobalScale; + float9[Matrix.MSKEW_Y] = 0; + float9[Matrix.MSKEW_X] = 0; + float9[Matrix.MSCALE_Y] = mGlobalScale; transformSurfaceInsetsPosition(mTmpPoint, mAttrs.surfaceInsets); int x = mSurfacePosition.x + mTmpPoint.x; int y = mSurfacePosition.y + mTmpPoint.y; diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index ca38bb90f19cd..a527eab5c45bf 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -125,11 +125,6 @@ class WindowStateAnimator { */ private final Rect mSystemDecorRect = new Rect(); - float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1; - private float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1; - - boolean mHaveMatrix; - // Set to true if, when the window gets displayed, it should perform // an enter animation. boolean mEnterAnimationPending; @@ -478,11 +473,6 @@ class WindowStateAnimator { } mShownAlpha = mAlpha; - mHaveMatrix = false; - mDsDx = 1; - mDtDx = 0; - mDtDy = 0; - mDsDy = 1; } private boolean isInBlastSync() { @@ -522,10 +512,10 @@ class WindowStateAnimator { // Wallpaper is already updated above when calling setWallpaperPositionAndScale so // we only need to consider the non-wallpaper case here. mSurfaceController.setMatrix(t, - mDsDx * w.mHScale, - mDtDx * w.mVScale, - mDtDy * w.mHScale, - mDsDy * w.mVScale); + w.mHScale, + w.mVScale, + w.mHScale, + w.mVScale); } else { setWallpaperPositionAndScale(t, xOffset, yOffset, mWallpaperScale); } @@ -585,25 +575,17 @@ class WindowStateAnimator { "Orientation change skips hidden %s", w); } } else if (mLastAlpha != mShownAlpha - || mLastDsDx != mDsDx - || mLastDtDx != mDtDx - || mLastDsDy != mDsDy - || mLastDtDy != mDtDy || w.mLastHScale != w.mHScale || w.mLastVScale != w.mVScale || mLastHidden) { displayed = true; mLastAlpha = mShownAlpha; - mLastDsDx = mDsDx; - mLastDtDx = mDtDx; - mLastDsDy = mDsDy; - mLastDtDy = mDtDy; w.mLastHScale = w.mHScale; w.mLastVScale = w.mVScale; ProtoLog.i(WM_SHOW_TRANSACTIONS, "SURFACE controller=%s alpha=%f matrix=[%f*%f,%f*%f][%f*%f,%f*%f]: %s", - mSurfaceController, mShownAlpha, mDsDx, w.mHScale, mDtDx, w.mVScale, - mDtDy, w.mHScale, mDsDy, w.mVScale, w); + mSurfaceController, mShownAlpha, w.mHScale, w.mVScale, + w.mHScale, w.mVScale, w); boolean prepared = true; @@ -612,10 +594,10 @@ class WindowStateAnimator { } else { prepared = mSurfaceController.prepareToShowInTransaction(t, mShownAlpha, - mDsDx * w.mHScale, - mDtDx * w.mVScale, - mDtDy * w.mHScale, - mDsDy * w.mVScale + w.mHScale, + w.mVScale, + w.mHScale, + w.mVScale ); } @@ -712,10 +694,10 @@ class WindowStateAnimator { mSurfaceController.setPosition(t,mWin.mTmpMatrixArray[MTRANS_X], mWin.mTmpMatrixArray[MTRANS_Y]); mSurfaceController.setMatrix(t, - mDsDx * mWin.mTmpMatrixArray[MSCALE_X] * mWin.mHScale, - mDtDx * mWin.mTmpMatrixArray[MSKEW_Y] * mWin.mVScale, - mDtDy * mWin.mTmpMatrixArray[MSKEW_X] * mWin.mHScale, - mDsDy * mWin.mTmpMatrixArray[MSCALE_Y] * mWin.mVScale); + mWin.mTmpMatrixArray[MSCALE_X] * mWin.mHScale, + mWin.mTmpMatrixArray[MSKEW_Y] * mWin.mVScale, + mWin.mTmpMatrixArray[MSKEW_X] * mWin.mHScale, + mWin.mTmpMatrixArray[MSCALE_Y] * mWin.mVScale); } /** @@ -917,12 +899,8 @@ class WindowStateAnimator { pw.print(" mAlpha="); pw.print(mAlpha); pw.print(" mLastAlpha="); pw.println(mLastAlpha); } - if (mHaveMatrix || mWin.mGlobalScale != 1) { + if (mWin.mGlobalScale != 1) { pw.print(prefix); pw.print("mGlobalScale="); pw.print(mWin.mGlobalScale); - pw.print(" mDsDx="); pw.print(mDsDx); - pw.print(" mDtDx="); pw.print(mDtDx); - pw.print(" mDtDy="); pw.print(mDtDy); - pw.print(" mDsDy="); pw.println(mDsDy); } } From dae3d40c724c96e309e5a014f5e4f5a9510a6c12 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 5 Apr 2021 15:36:39 -0700 Subject: [PATCH 2/2] WindowStateAnimator: Move HScale/VScale application to WindowState We need to avoid calling setMatrix on WindowStateAnimator so we don't fight with the BLASTBufferQueue. Bug: 161937501 Test: Existing tests pass Change-Id: I28ac9a2d1501caaea674fc31979b60b71486b602 --- data/etc/services.core.protolog.json | 12 +++---- .../com/android/server/wm/WindowState.java | 11 ++++--- .../server/wm/WindowStateAnimator.java | 32 ++++--------------- .../server/wm/WindowSurfaceController.java | 8 +---- 4 files changed, 21 insertions(+), 42 deletions(-) diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 77fe717e22379..efeaf238ac845 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -193,6 +193,12 @@ "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, + "-1906387645": { + "message": "SURFACE controller=%s alpha=%f HScale=%f, VScale=%f: %s", + "level": "INFO", + "group": "WM_SHOW_TRANSACTIONS", + "at": "com\/android\/server\/wm\/WindowStateAnimator.java" + }, "-1905191109": { "message": "SyncGroup %d: Finished!", "level": "VERBOSE", @@ -3283,12 +3289,6 @@ "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, - "1747941491": { - "message": "SURFACE controller=%s alpha=%f matrix=[%f*%f,%f*%f][%f*%f,%f*%f]: %s", - "level": "INFO", - "group": "WM_SHOW_TRANSACTIONS", - "at": "com\/android\/server\/wm\/WindowStateAnimator.java" - }, "1756082882": { "message": "Orientation change skips hidden %s", "level": "VERBOSE", diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index d5d7c00108500..d159c5950e310 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5354,11 +5354,14 @@ class WindowState extends WindowContainer implements WindowManagerP } } - private void updateGlobalScaleIfNeeded() { - if (mLastGlobalScale != mGlobalScale) { + private void updateScaleIfNeeded() { + if (mLastGlobalScale != mGlobalScale || mLastHScale != mHScale || + mLastVScale != mVScale ) { getPendingTransaction().setMatrix(getSurfaceControl(), - mGlobalScale, 0, 0, mGlobalScale); + mGlobalScale*mHScale, 0, 0, mGlobalScale*mVScale); mLastGlobalScale = mGlobalScale; + mLastHScale = mHScale; + mLastVScale = mVScale; } } @@ -5369,7 +5372,7 @@ class WindowState extends WindowContainer implements WindowManagerP updateSurfacePositionNonOrganized(); // Send information to SufaceFlinger about the priority of the current window. updateFrameRateSelectionPriorityIfNeeded(); - if (isVisibleRequested()) updateGlobalScaleIfNeeded(); + if (isVisibleRequested()) updateScaleIfNeeded(); mWinAnimator.prepareSurfaceLocked(getSyncTransaction()); super.prepareSurfaces(); diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index a527eab5c45bf..ea3b0658c4d55 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -509,13 +509,6 @@ class WindowStateAnimator { int yOffset = mYOffset; if (!mIsWallpaper) { mSurfaceController.setPosition(t, xOffset, yOffset); - // Wallpaper is already updated above when calling setWallpaperPositionAndScale so - // we only need to consider the non-wallpaper case here. - mSurfaceController.setMatrix(t, - w.mHScale, - w.mVScale, - w.mHScale, - w.mVScale); } else { setWallpaperPositionAndScale(t, xOffset, yOffset, mWallpaperScale); } @@ -575,17 +568,12 @@ class WindowStateAnimator { "Orientation change skips hidden %s", w); } } else if (mLastAlpha != mShownAlpha - || w.mLastHScale != w.mHScale - || w.mLastVScale != w.mVScale || mLastHidden) { displayed = true; mLastAlpha = mShownAlpha; - w.mLastHScale = w.mHScale; - w.mLastVScale = w.mVScale; ProtoLog.i(WM_SHOW_TRANSACTIONS, - "SURFACE controller=%s alpha=%f matrix=[%f*%f,%f*%f][%f*%f,%f*%f]: %s", - mSurfaceController, mShownAlpha, w.mHScale, w.mVScale, - w.mHScale, w.mVScale, w); + "SURFACE controller=%s alpha=%f HScale=%f, VScale=%f: %s", + mSurfaceController, mShownAlpha, w.mHScale, w.mVScale, w); boolean prepared = true; @@ -593,12 +581,7 @@ class WindowStateAnimator { setWallpaperPositionAndScale(t, mXOffset, mYOffset, mWallpaperScale); } else { prepared = - mSurfaceController.prepareToShowInTransaction(t, mShownAlpha, - w.mHScale, - w.mVScale, - w.mHScale, - w.mVScale - ); + mSurfaceController.prepareToShowInTransaction(t, mShownAlpha); } if (prepared && mDrawState == HAS_DRAWN) { @@ -693,11 +676,10 @@ class WindowStateAnimator { mSurfaceController.setPosition(t,mWin.mTmpMatrixArray[MTRANS_X], mWin.mTmpMatrixArray[MTRANS_Y]); - mSurfaceController.setMatrix(t, - mWin.mTmpMatrixArray[MSCALE_X] * mWin.mHScale, - mWin.mTmpMatrixArray[MSKEW_Y] * mWin.mVScale, - mWin.mTmpMatrixArray[MSKEW_X] * mWin.mHScale, - mWin.mTmpMatrixArray[MSCALE_Y] * mWin.mVScale); + mSurfaceController.setMatrix(t, mWin.mTmpMatrixArray[MSCALE_X], + mWin.mTmpMatrixArray[MSKEW_Y], + mWin.mTmpMatrixArray[MSKEW_X], + mWin.mTmpMatrixArray[MSCALE_Y]); } /** diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java index 636f0bb6086fe..fa0d70833f65e 100644 --- a/services/core/java/com/android/server/wm/WindowSurfaceController.java +++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java @@ -178,19 +178,13 @@ class WindowSurfaceController { t.setMatrix(mSurfaceControl, dsdx, dtdx, dtdy, dsdy); } - boolean prepareToShowInTransaction(SurfaceControl.Transaction t, float alpha, float dsdx, - float dtdx, float dsdy, float dtdy) { + boolean prepareToShowInTransaction(SurfaceControl.Transaction t, float alpha) { if (mSurfaceControl == null) { return false; } mSurfaceAlpha = alpha; t.setAlpha(mSurfaceControl, alpha); - mLastDsdx = dsdx; - mLastDtdx = dtdx; - mLastDsdy = dsdy; - mLastDtdy = dtdy; - t.setMatrix(mSurfaceControl, dsdx, dtdx, dsdy, dtdy); return true; }