OSDN Git Service

Fix minor issues with new window animations.
authorJorim Jaggi <jjaggi@google.com>
Tue, 12 Dec 2017 16:18:57 +0000 (17:18 +0100)
committerWinson Chung <winsonc@google.com>
Thu, 14 Dec 2017 02:45:41 +0000 (18:45 -0800)
- Fix screen rotation anim by pulling it back to DC.
- Fix surface insets by correcting at WindowState.prepareSurfaces,
and then going into the other direction in the WSA.

Test: Open PopupWindow, observe shadow is not clipping
Test: Rotate screen, ensure the animation is correct
Test: go/wm-smoke
Bug: 64674361
Change-Id: I0e0910a72aa5f06b86d4e90061e4f807fb164316

services/core/java/com/android/server/wm/DisplayContent.java
services/core/java/com/android/server/wm/WindowState.java
services/core/java/com/android/server/wm/WindowStateAnimator.java

index f05cf2a..f458457 100644 (file)
@@ -381,6 +381,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
      */
     private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>();
 
+    /** Temporary float array to retrieve 3x3 matrix values. */
+    private final float[] mTmpFloats = new float[9];
+
     private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
         WindowStateAnimator winAnimator = w.mWinAnimator;
         final AppWindowToken atoken = w.mAppToken;
@@ -3777,4 +3780,21 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
         }
         mPendingDestroyingSurfaces.clear();
     }
+
+    @Override
+    void prepareSurfaces() {
+        final ScreenRotationAnimation screenRotationAnimation =
+                mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
+        if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
+            screenRotationAnimation.getEnterTransformation().getMatrix().getValues(mTmpFloats);
+            mPendingTransaction.setMatrix(mWindowingLayer,
+                    mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
+                    mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
+            mPendingTransaction.setPosition(mWindowingLayer,
+                    mTmpFloats[Matrix.MTRANS_X], mTmpFloats[Matrix.MTRANS_Y]);
+            mPendingTransaction.setAlpha(mWindowingLayer,
+                    screenRotationAnimation.getEnterTransformation().getAlpha());
+        }
+        super.prepareSurfaces();
+    }
 }
index 559d5b6..a9708ce 100644 (file)
@@ -4444,6 +4444,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
             left -= parent.mFrame.left;
             top -= parent.mFrame.top;
         }
+
+        // Expand for surface insets. See WindowState.expandForSurfaceInsets.
+        left -= mAttrs.surfaceInsets.left;
+        top -= mAttrs.surfaceInsets.top;
         mSurfacePosition.set(left, top);
         if (!mSurfaceAnimator.hasLeash()) {
             t.setPosition(mSurfaceControl, mSurfacePosition.x, mSurfacePosition.y);
index e3d2d1c..0eabc89 100644 (file)
@@ -704,16 +704,15 @@ class WindowStateAnimator {
             }
             tmpMatrix.postScale(mWin.mGlobalScale, mWin.mGlobalScale);
 
+            // WindowState.prepareSurfaces expands for surface insets (in order they don't get
+            // clipped by the WindowState surface), so we need to go into the other direction here.
+            tmpMatrix.postTranslate(mWin.mXOffset + mWin.mAttrs.surfaceInsets.left,
+                    mWin.mYOffset + mWin.mAttrs.surfaceInsets.top);
+
             if (appTransformation != null) {
                 tmpMatrix.postConcat(appTransformation.getMatrix());
             }
 
-            tmpMatrix.postTranslate(mWin.mXOffset, mWin.mYOffset);
-
-            if (screenAnimation) {
-                tmpMatrix.postConcat(screenRotationAnimation.getEnterTransformation().getMatrix());
-            }
-
             // "convert" it into SurfaceFlinger's format
             // (a 2x2 matrix + an offset)
             // Here we must not transform the position of the surface
@@ -788,7 +787,10 @@ class WindowStateAnimator {
                 TAG, "computeShownFrameLocked: " + this +
                 " not attached, mAlpha=" + mAlpha);
 
-        mWin.mShownPosition.set(mWin.mXOffset, mWin.mYOffset);
+        // WindowState.prepareSurfaces expands for surface insets (in order they don't get
+        // clipped by the WindowState surface), so we need to go into the other direction here.
+        mWin.mShownPosition.set(mWin.mXOffset + mWin.mAttrs.surfaceInsets.left,
+                mWin.mYOffset + mWin.mAttrs.surfaceInsets.top);
         mShownAlpha = mAlpha;
         mHaveMatrix = false;
         mDsDx = mWin.mGlobalScale;