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

Commit b3cbd0b4 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Refactor animation out of WindowState."

parents 628e2345 a2c77053
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ class AppWindowToken extends WindowToken {
            if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
                    "performing show on: " + w);
            w.performShowLocked();
            isAnimating |= w.isAnimating();
            isAnimating |= w.mWinAnimator.isAnimating();
        }
        return isAnimating;
    }
@@ -243,11 +243,11 @@ class AppWindowToken extends WindowToken {
        // cache often used attributes locally
        final float tmpFloats[] = service.mTmpFloats;
        thumbnailTransformation.getMatrix().getValues(tmpFloats);
        if (WindowManagerService.SHOW_TRANSACTIONS) service.logSurface(thumbnail,
        if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
                "thumbnail", "POS " + tmpFloats[Matrix.MTRANS_X]
                + ", " + tmpFloats[Matrix.MTRANS_Y], null);
        thumbnail.setPosition(tmpFloats[Matrix.MTRANS_X], tmpFloats[Matrix.MTRANS_Y]);
        if (WindowManagerService.SHOW_TRANSACTIONS) service.logSurface(thumbnail,
        if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
                "thumbnail", "alpha=" + thumbnailTransformation.getAlpha()
                + " layer=" + thumbnailLayer
                + " matrix=[" + tmpFloats[Matrix.MSCALE_X]
@@ -358,7 +358,7 @@ class AppWindowToken extends WindowToken {

        final int N = windows.size();
        for (int i=0; i<N; i++) {
            windows.get(i).finishExit();
            windows.get(i).mWinAnimator.finishExit();
        }
        updateReportedVisibilityLocked();

@@ -388,7 +388,7 @@ class AppWindowToken extends WindowToken {
            if (WindowManagerService.DEBUG_VISIBILITY) {
                Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn="
                        + win.isDrawnLw()
                        + ", isAnimating=" + win.isAnimating());
                        + ", isAnimating=" + win.mWinAnimator.isAnimating());
                if (!win.isDrawnLw()) {
                    Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mSurface
                            + " pv=" + win.mPolicyVisibility
@@ -398,17 +398,17 @@ class AppWindowToken extends WindowToken {
                            + " th="
                            + (win.mAppToken != null
                                    ? win.mAppToken.hiddenRequested : false)
                            + " a=" + win.mAnimating);
                            + " a=" + win.mWinAnimator.mAnimating);
                }
            }
            numInteresting++;
            if (win.isDrawnLw()) {
                numDrawn++;
                if (!win.isAnimating()) {
                if (!win.mWinAnimator.isAnimating()) {
                    numVisible++;
                }
                nowGone = false;
            } else if (win.isAnimating()) {
            } else if (win.mWinAnimator.isAnimating()) {
                nowGone = false;
            }
        }
+4 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ class DimAnimator {

    /**
     * Set's the dim surface's layer and update dim parameters that will be used in
     * {@link updateSurface} after all windows are examined.
     * {@link #updateSurface} after all windows are examined.
     */
    void updateParameters(Resources res, WindowState w, long currentTime) {
        mDimSurface.setLayer(w.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM);
@@ -94,15 +94,15 @@ class DimAnimator {
            // If the desired dim level has changed, then
            // start an animation to it.
            mLastDimAnimTime = currentTime;
            long duration = (w.mAnimating && w.mAnimation != null)
                    ? w.mAnimation.computeDurationHint()
            long duration = (w.mWinAnimator.mAnimating && w.mWinAnimator.mAnimation != null)
                    ? w.mWinAnimator.mAnimation.computeDurationHint()
                    : WindowManagerService.DEFAULT_DIM_DURATION;
            if (target > mDimTargetAlpha) {
                TypedValue tv = new TypedValue();
                res.getValue(com.android.internal.R.fraction.config_dimBehindFadeDuration,
                        tv, true);
                if (tv.type == TypedValue.TYPE_FRACTION) {
                    duration = (long)tv.getFraction((float)duration, (float)duration);
                    duration = (long)tv.getFraction(duration, duration);
                } else if (tv.type >= TypedValue.TYPE_FIRST_INT
                        && tv.type <= TypedValue.TYPE_LAST_INT) {
                    duration = tv.data;
+14 −13
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public class WindowAnimator {

        for (int i = mService.mWindows.size() - 1; i >= 0; i--) {
            WindowState w = mService.mWindows.get(i);
            WindowStateAnimator winAnimator = w.mWinAnimator;

            final WindowManager.LayoutParams attrs = w.mAttrs;

@@ -143,7 +144,7 @@ public class WindowAnimator {
                    // let's do something.
                    Animation a = AnimationUtils.loadAnimation(mContext,
                            com.android.internal.R.anim.window_move_from_decor);
                    w.setAnimation(a);
                    winAnimator.setAnimation(a);
                    w.mAnimDw = w.mLastFrame.left - w.mFrame.left;
                    w.mAnimDh = w.mLastFrame.top - w.mFrame.top;
                } else {
@@ -151,8 +152,8 @@ public class WindowAnimator {
                    w.mAnimDh = mInnerDh;
                }

                final boolean wasAnimating = w.mWasAnimating;
                final boolean nowAnimating = w.stepAnimationLocked(mCurrentTime);
                final boolean wasAnimating = winAnimator.mWasAnimating;
                final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);

                if (WindowManagerService.DEBUG_WALLPAPER) {
                    Slog.v(TAG, w + ": wasAnimating=" + wasAnimating +
@@ -163,17 +164,17 @@ public class WindowAnimator {
                // an animating window and take care of a request to run
                // a detached wallpaper animation.
                if (nowAnimating) {
                    if (w.mAnimation != null) {
                    if (winAnimator.mAnimation != null) {
                        if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0
                                && w.mAnimation.getDetachWallpaper()) {
                                && winAnimator.mAnimation.getDetachWallpaper()) {
                            mService.mInnerFields.mDetachedWallpaper = w;
                        }
                        if (w.mAnimation.getBackgroundColor() != 0) {
                        if (winAnimator.mAnimation.getBackgroundColor() != 0) {
                            if (mWindowAnimationBackground == null
                                    || (w.mAnimLayer < mWindowAnimationBackground.mAnimLayer)) {
                                mWindowAnimationBackground = w;
                                mWindowAnimationBackgroundColor =
                                        w.mAnimation.getBackgroundColor();
                                        winAnimator.mAnimation.getBackgroundColor();
                            }
                        }
                    }
@@ -200,7 +201,7 @@ public class WindowAnimator {
                    }
                }

                if (wasAnimating && !w.mAnimating && mService.mWallpaperTarget == w) {
                if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == w) {
                    mService.mInnerFields.mWallpaperMayChange = true;
                    mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
@@ -219,7 +220,7 @@ public class WindowAnimator {
                            mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3");
                        }
                        mService.mFocusMayChange = true;
                    } else if (w.isReadyForDisplay() && w.mAnimation == null) {
                    } else if (w.isReadyForDisplay() && winAnimator.mAnimation == null) {
                        mForceHiding = true;
                    }
                } else if (mPolicy.canBeForceHidden(w, attrs)) {
@@ -241,7 +242,7 @@ public class WindowAnimator {
                                // clean up later.
                                Animation a = mPolicy.createForceHideEnterAnimation();
                                if (a != null) {
                                    w.setAnimation(a);
                                    winAnimator.setAnimation(a);
                                }
                            }
                            if (mCurrentFocus == null || mCurrentFocus.mLayer < w.mLayer) {
@@ -277,7 +278,7 @@ public class WindowAnimator {
                            WindowManagerService.DEBUG_ORIENTATION) {
                        Slog.v(TAG, "Eval win " + w + ": isDrawn="
                                + w.isDrawnLw()
                                + ", isAnimating=" + w.isAnimating());
                                + ", isAnimating=" + winAnimator.isAnimating());
                        if (!w.isDrawnLw()) {
                            Slog.v(TAG, "Not displayed: s=" + w.mSurface
                                    + " pv=" + w.mPolicyVisibility
@@ -285,7 +286,7 @@ public class WindowAnimator {
                                    + " cdp=" + w.mCommitDrawPending
                                    + " ah=" + w.mAttachedHidden
                                    + " th=" + atoken.hiddenRequested
                                    + " a=" + w.mAnimating);
                                    + " a=" + winAnimator.mAnimating);
                        }
                    }
                    if (w != atoken.startingWindow) {
+24 −23
Original line number Diff line number Diff line
@@ -1238,7 +1238,7 @@ public class WindowManagerService extends IWindowManager.Stub
                if (highestTarget != null) {
                    if (DEBUG_INPUT_METHOD) Slog.v(TAG, "mNextAppTransition="
                            + mNextAppTransition + " " + highestTarget
                            + " animating=" + highestTarget.isAnimating()
                            + " animating=" + highestTarget.mWinAnimator.isAnimating()
                            + " layer=" + highestTarget.mAnimLayer
                            + " new layer=" + w.mAnimLayer);

@@ -1248,7 +1248,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        mInputMethodTargetWaitingAnim = true;
                        mInputMethodTarget = highestTarget;
                        return highestPos + 1;
                    } else if (highestTarget.isAnimating() &&
                    } else if (highestTarget.mWinAnimator.isAnimating() &&
                            highestTarget.mAnimLayer > w.mAnimLayer) {
                        // If the window we are currently targeting is involved
                        // with an animation, and it is on top of the next target
@@ -1601,7 +1601,7 @@ public class WindowManagerService extends IWindowManager.Stub
                foundI = i;
                if (w == mWallpaperTarget && ((w.mAppToken != null
                        && w.mAppToken.animation != null)
                        || w.mAnimation != null)) {
                        || w.mWinAnimator.mAnimation != null)) {
                    // The current wallpaper target is animating, so we'll
                    // look behind it for another possible target and figure
                    // out what is going on below.
@@ -1658,9 +1658,9 @@ public class WindowManagerService extends IWindowManager.Stub
            // Now what is happening...  if the current and new targets are
            // animating, then we are in our super special mode!
            if (foundW != null && oldW != null) {
                boolean oldAnim = oldW.mAnimation != null
                boolean oldAnim = oldW.mWinAnimator.mAnimation != null
                        || (oldW.mAppToken != null && oldW.mAppToken.animation != null);
                boolean foundAnim = foundW.mAnimation != null
                boolean foundAnim = foundW.mWinAnimator.mAnimation != null
                        || (foundW.mAppToken != null && foundW.mAppToken.animation != null);
                if (DEBUG_WALLPAPER) {
                    Slog.v(TAG, "New animation: " + foundAnim
@@ -1712,10 +1712,10 @@ public class WindowManagerService extends IWindowManager.Stub

        } else if (mLowerWallpaperTarget != null) {
            // Is it time to stop animating?
            boolean lowerAnimating = mLowerWallpaperTarget.mAnimation != null
            boolean lowerAnimating = mLowerWallpaperTarget.mWinAnimator.mAnimation != null
                    || (mLowerWallpaperTarget.mAppToken != null
                            && mLowerWallpaperTarget.mAppToken.animation != null);
            boolean upperAnimating = mUpperWallpaperTarget.mAnimation != null
            boolean upperAnimating = mUpperWallpaperTarget.mWinAnimator.mAnimation != null
                    || (mUpperWallpaperTarget.mAppToken != null
                            && mUpperWallpaperTarget.mAppToken.animation != null);
            if (!lowerAnimating || !upperAnimating) {
@@ -2303,7 +2303,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (DEBUG_APP_TRANSITIONS) Slog.v(
                TAG, "Remove " + win + ": mSurface=" + win.mSurface
                + " mExiting=" + win.mExiting
                + " isAnimating=" + win.isAnimating()
                + " isAnimating=" + win.mWinAnimator.isAnimating()
                + " app-animation="
                + (win.mAppToken != null ? win.mAppToken.animation : null)
                + " inPendingTransaction="
@@ -2330,7 +2330,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    win.mExiting = true;
                }
            }
            if (win.mExiting || win.isAnimating()) {
            if (win.mExiting || win.mWinAnimator.isAnimating()) {
                // The exit animation is running... wait for it!
                //Slog.i(TAG, "*** Running exit animation...");
                win.mExiting = true;
@@ -2699,7 +2699,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    (win.mAppToken == null || !win.mAppToken.clientHidden)) {
                displayed = !win.isVisibleLw();
                if (win.mExiting) {
                    win.cancelExitAnimationForNextAnimationLocked();
                    win.mWinAnimator.cancelExitAnimationForNextAnimationLocked();
                }
                if (win.mDestroying) {
                    win.mDestroying = false;
@@ -2803,7 +2803,7 @@ public class WindowManagerService extends IWindowManager.Stub
                              applyAnimationLocked(win, transit, false)) {
                            focusMayChange = true;
                            win.mExiting = true;
                        } else if (win.isAnimating()) {
                        } else if (win.mWinAnimator.isAnimating()) {
                            // Currently in a hide animation... turn this into
                            // an exit.
                            win.mExiting = true;
@@ -2812,7 +2812,7 @@ public class WindowManagerService extends IWindowManager.Stub
                            // window, we need to change both of them inside
                            // of a transaction to avoid artifacts.
                            win.mExiting = true;
                            win.mAnimating = true;
                            win.mWinAnimator.mAnimating = true;
                        } else {
                            if (mInputMethodWindow == win) {
                                mInputMethodWindow = null;
@@ -3026,7 +3026,8 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    boolean applyAnimationLocked(WindowState win,
            int transit, boolean isEntrance) {
        if (win.mLocalAnimating && win.mAnimationIsEntrance == isEntrance) {
        if (win.mWinAnimator.mLocalAnimating &&
                win.mWinAnimator.mAnimationIsEntrance == isEntrance) {
            // If we are trying to apply an animation, but already running
            // an animation of the same type, then just leave that one alone.
            return true;
@@ -3063,7 +3064,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            if (DEBUG_ANIM) Slog.v(TAG, "applyAnimation: win=" + win
                    + " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
                    + " mAnimation=" + win.mAnimation
                    + " mAnimation=" + win.mWinAnimator.mAnimation
                    + " isEntrance=" + isEntrance);
            if (a != null) {
                if (DEBUG_ANIM) {
@@ -3074,14 +3075,14 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                    Slog.v(TAG, "Loaded animation " + a + " for " + win, e);
                }
                win.setAnimation(a);
                win.mAnimationIsEntrance = isEntrance;
                win.mWinAnimator.setAnimation(a);
                win.mWinAnimator.mAnimationIsEntrance = isEntrance;
            }
        } else {
            win.clearAnimation();
            win.mWinAnimator.clearAnimation();
        }

        return win.mAnimation != null;
        return win.mWinAnimator.mAnimation != null;
    }

    private Animation loadAnimation(WindowManager.LayoutParams lp, int animAttr) {
@@ -3370,7 +3371,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    for (int i=0; i<N; i++) {
                        WindowState win = wtoken.windows.get(i);

                        if (win.isAnimating()) {
                        if (win.mWinAnimator.isAnimating()) {
                            delayed = true;
                        }

@@ -4063,7 +4064,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    continue;
                }

                if (win.isAnimating()) {
                if (win.mWinAnimator.isAnimating()) {
                    delayed = true;
                }

@@ -8099,11 +8100,11 @@ public class WindowManagerService extends IWindowManager.Stub
                        if (DEBUG_FOCUS) Slog.i(TAG, "win=" + w + " force hides other windows");
                        mAnimator.mForceHiding = true;
                    } else if (mPolicy.canBeForceHidden(w, attrs)) {
                        if (!w.mAnimating) {
                        if (!w.mWinAnimator.mAnimating) {
                            // We set the animation above so it
                            // is not yet running.
                            // TODO(cmautner): We lose the enter animation when this occurs.
                            w.clearAnimation();
                            w.mWinAnimator.clearAnimation();
                        }
                    }
                }
+43 −289

File changed.

Preview size limit exceeded, changes collapsed.

Loading