Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d7349bb authored by Craig Mautner's avatar Craig Mautner
Browse files

Remove flicker from transitions.

Change state progressions to handle animation/layout separation.
Also added debug as needed.

Fixes bug 6360835.
Fixes bug 6206366.
Fixes bug 6286371.
Fixes bug 6240494.

Change-Id: I1079756a7e3e35ebb9f711f02d005bde9bf65ef0
parent 8e2f4142
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -42,10 +42,17 @@ class DimAnimator {
    DimAnimator (SurfaceSession session) {
        if (mDimSurface == null) {
            try {
                if (WindowManagerService.DEBUG_SURFACE_TRACE) {
                    mDimSurface = new WindowStateAnimator.SurfaceTrace(session, 0,
                        "DimAnimator",
                        -1, 16, 16, PixelFormat.OPAQUE,
                        Surface.FX_SURFACE_DIM);
                } else {
                    mDimSurface = new Surface(session, 0,
                        "DimAnimator",
                        -1, 16, 16, PixelFormat.OPAQUE,
                        Surface.FX_SURFACE_DIM);
                }
                if (WindowManagerService.SHOW_TRANSACTIONS ||
                        WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
                                "  DIM " + mDimSurface + ": CREATE");
+14 −2
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ public class WindowAnimator {
    DimAnimator mDimAnimator = null;
    DimAnimator.Parameters mDimParams = null;

    static final int WALLPAPER_ACTION_PENDING = 1;
    int mPendingActions;

    WindowAnimator(final WindowManagerService service, final Context context,
            final WindowManagerPolicy policy) {
        mService = service;
@@ -364,7 +367,9 @@ public class WindowAnimator {
            for (int i=unForceHiding.size()-1; i>=0; i--) {
                Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding);
                if (a != null) {
                    unForceHiding.get(i).setAnimation(a);
                    final WindowStateAnimator winAnimator = unForceHiding.get(i);
                    winAnimator.setAnimation(a);
                    winAnimator.mAnimationIsEntrance = true;
                }
            }
        }
@@ -421,13 +426,16 @@ public class WindowAnimator {
        mWindowAnimationBackgroundColor = 0;

        updateWindowsAndWallpaperLocked();
        if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
            mPendingActions |= WALLPAPER_ACTION_PENDING;
        }

        if (mTokenMayBeDrawn) {
            testTokenMayBeDrawnLocked();
        }
    }

    void animate() {
    synchronized void animate() {
        mPendingLayoutChanges = 0;
        mCurrentTime = SystemClock.uptimeMillis();
        mBulkUpdateParams = 0;
@@ -554,4 +562,8 @@ public class WindowAnimator {
            mAnimDh = animDh;
        }
    }

    synchronized void clearPendingActions() {
        mPendingActions = 0;
    }
}
+9 −4
Original line number Diff line number Diff line
@@ -1629,9 +1629,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        "Found wallpaper activity: #" + i + "=" + w);
                foundW = w;
                foundI = i;
                if (w == mWallpaperTarget && ((w.mAppToken != null
                        && w.mAppToken.mAppAnimator.animation != null)
                        || w.mWinAnimator.mAnimation != null)) {
                if (w == mWallpaperTarget && w.mWinAnimator.isAnimating()) {
                    // The current wallpaper target is animating, so we'll
                    // look behind it for another possible target and figure
                    // out what is going on below.
@@ -6618,6 +6616,7 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int SET_WALLPAPER_OFFSET = ANIMATOR_WHAT_OFFSET + 2;
        public static final int SET_DIM_PARAMETERS = ANIMATOR_WHAT_OFFSET + 3;
        public static final int SET_MOVE_ANIMATION = ANIMATOR_WHAT_OFFSET + 4;
        public static final int CLEAR_PENDING_ACTIONS = ANIMATOR_WHAT_OFFSET + 5;

        private Session mLastReportedHold;

@@ -7070,7 +7069,8 @@ public class WindowManagerService extends IWindowManager.Stub
                        }

                        if (doRequest) {
                            requestTraversalLocked();
                            mH.sendEmptyMessage(CLEAR_PENDING_ACTIONS);
                            performLayoutAndPlaceSurfacesLocked();
                        }
                    }
                    break;
@@ -7111,6 +7111,11 @@ public class WindowManagerService extends IWindowManager.Stub
                    scheduleAnimationLocked();
                    break;
                }

                case CLEAR_PENDING_ACTIONS: {
                    mAnimator.clearPendingActions();
                    break;
                }
            }
            if (DEBUG_WINDOW_TRACE) {
                Slog.v(TAG, "handleMessage: exit");
+17 −20
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ class WindowStateAnimator {
        if (mAnimation != null) {
            mAnimation.cancel();
            mAnimation = null;
            mLocalAnimating = false;
            destroySurfaceLocked();
        }
    }
@@ -262,9 +263,6 @@ class WindowStateAnimator {
            // If the display is frozen, and there is a pending animation,
            // clear it and make sure we run the cleanup code.
            mAnimating = true;
            mLocalAnimating = true;
            mAnimation.cancel();
            mAnimation = null;
        }

        if (!mAnimating && !mLocalAnimating) {
@@ -878,6 +876,9 @@ class WindowStateAnimator {
                ": " + mWin.mShownFrame +
                ", alpha=" + mTransformation.getAlpha() + ", mShownAlpha=" + mShownAlpha);
            return;
        } else if (mWin.mIsWallpaper &&
                    (mAnimator.mPendingActions & WindowAnimator.WALLPAPER_ACTION_PENDING) != 0) {
            return;
        }

        if (WindowManagerService.localLOGV) Slog.v(
@@ -920,19 +921,19 @@ class WindowStateAnimator {
            mSurfaceH = height;
        }

        if (mSurfaceX != w.mShownFrame.left
                || mSurfaceY != w.mShownFrame.top) {
        final float left = w.mShownFrame.left;
        final float top = w.mShownFrame.top;
        if (mSurfaceX != left || mSurfaceY != top) {
            try {
                if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
                        "POS " + w.mShownFrame.left
                        + ", " + w.mShownFrame.top, null);
                mSurfaceX = w.mShownFrame.left;
                mSurfaceY = w.mShownFrame.top;
                mSurface.setPosition(w.mShownFrame.left, w.mShownFrame.top);
                        "POS " + left + ", " + top, null);
                mSurfaceX = left;
                mSurfaceY = top;
                mSurface.setPosition(left, top);
            } catch (RuntimeException e) {
                Slog.w(TAG, "Error positioning surface of " + w
                        + " pos=(" + w.mShownFrame.left
                        + "," + w.mShownFrame.top + ")", e);
                        + " pos=(" + left
                        + "," + top + ")", e);
                if (!recoveringMemory) {
                    mService.reclaimSomeSurfaceMemoryLocked(this, "position", true);
                }
@@ -1177,12 +1178,7 @@ class WindowStateAnimator {
                    // will do an animation to reveal it from behind the
                    // starting window, so there is no need for it to also
                    // be doing its own stuff.
                    if (mAnimation != null) {
                        mAnimation.cancel();
                        mAnimation = null;
                        // Make sure we clean up the animation.
                        mAnimating = true;
                    }
                    clearAnimation();
                    mService.mFinishedStarting.add(mWin.mAppToken);
                    mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
                }
@@ -1286,6 +1282,7 @@ class WindowStateAnimator {
            if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
                    "applyAnimation: win=" + this
                    + " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
                    + " a=" + a
                    + " mAnimation=" + mAnimation
                    + " isEntrance=" + isEntrance);
            if (a != null) {