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

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

Merge "- Consolidate all animations in a single place outside of layout loop....

Merge "- Consolidate all animations in a single place outside of layout loop. - Move mPolicy.startAnimationLw and mPolicy.finishAnimationLw into same method as mPolicy.animatingWindowLw. - Fix first parameter of performLayoutLockedInner(initial, ...) to pass true on initial pass."
parents 5c9b4329 2f995a7e
Loading
Loading
Loading
Loading
+43 −46
Original line number Original line Diff line number Diff line
@@ -268,6 +268,7 @@ public class WindowManagerService extends IWindowManager.Stub


    final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher(
    final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher(
            new Handler(), "WindowManagerService.mKeyguardTokenWatcher") {
            new Handler(), "WindowManagerService.mKeyguardTokenWatcher") {
        @Override
        public void acquired() {
        public void acquired() {
            if (shouldAllowDisableKeyguard()) {
            if (shouldAllowDisableKeyguard()) {
                mPolicy.enableKeyguard(false);
                mPolicy.enableKeyguard(false);
@@ -276,6 +277,7 @@ public class WindowManagerService extends IWindowManager.Stub
                Log.v(TAG, "Not disabling keyguard since device policy is enforced");
                Log.v(TAG, "Not disabling keyguard since device policy is enforced");
            }
            }
        }
        }
        @Override
        public void released() {
        public void released() {
            mPolicy.enableKeyguard(true);
            mPolicy.enableKeyguard(true);
            synchronized (mKeyguardTokenWatcher) {
            synchronized (mKeyguardTokenWatcher) {
@@ -599,6 +601,7 @@ public class WindowManagerService extends IWindowManager.Stub
        private boolean mSyswin = false;
        private boolean mSyswin = false;
        private float mScreenBrightness = -1;
        private float mScreenBrightness = -1;
        private float mButtonBrightness = -1;
        private float mButtonBrightness = -1;
        private boolean mUpdateRotation = false;
    }
    }
    private LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields();
    private LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields();


@@ -7620,53 +7623,53 @@ public class WindowManagerService extends IWindowManager.Stub
     * @param innerDh Height of app window.
     * @param innerDh Height of app window.
     * @return true if rotation has stopped, false otherwise
     * @return true if rotation has stopped, false otherwise
     */
     */
    private boolean updateAppsAndRotationAnimationsLocked(long currentTime,
    private void updateWindowsAppsAndRotationAnimationsLocked(long currentTime,
                                                          int innerDw, int innerDh) {
                                                          int innerDw, int innerDh) {
        int i;
        int i;
        for (i = mWindows.size() - 1; i >= 0; i--) {
            mInnerFields.mAnimating |= mWindows.get(i).stepAnimationLocked(currentTime);
        }

        final int NAT = mAppTokens.size();
        final int NAT = mAppTokens.size();
        for (i=0; i<NAT; i++) {
        for (i=0; i<NAT; i++) {
            if (mAppTokens.get(i).stepAnimationLocked(currentTime,
            mInnerFields.mAnimating |=
                    innerDw, innerDh)) {
                    mAppTokens.get(i).stepAnimationLocked(currentTime, innerDw, innerDh);
                mInnerFields.mAnimating = true;
            }
        }
        }
        final int NEAT = mExitingAppTokens.size();
        final int NEAT = mExitingAppTokens.size();
        for (i=0; i<NEAT; i++) {
        for (i=0; i<NEAT; i++) {
            if (mExitingAppTokens.get(i).stepAnimationLocked(currentTime,
            mInnerFields.mAnimating |=
                    innerDw, innerDh)) {
                    mExitingAppTokens.get(i).stepAnimationLocked(currentTime, innerDw, innerDh);
                mInnerFields.mAnimating = true;
            }
        }
        }


        boolean updateRotation = false;
        if (mScreenRotationAnimation != null) {
        if (mScreenRotationAnimation != null) {
            if (mScreenRotationAnimation.isAnimating()) {
            if (mScreenRotationAnimation.isAnimating()) {
                if (mScreenRotationAnimation.stepAnimation(currentTime)) {
                if (mScreenRotationAnimation.stepAnimation(currentTime)) {
                    mInnerFields.mUpdateRotation = false;
                    mInnerFields.mAnimating = true;
                    mInnerFields.mAnimating = true;
                } else {
                } else {
                    updateRotation = true;
                    mInnerFields.mUpdateRotation = true;
                    mScreenRotationAnimation.kill();
                    mScreenRotationAnimation.kill();
                    mScreenRotationAnimation = null;
                    mScreenRotationAnimation = null;
                }
                }
            }
            }
        }
        }

        return updateRotation;
    }
    }


    /**
    /**
     * Extracted from {@link #performLayoutAndPlaceSurfacesLockedInner} to reduce size of method.
     * Extracted from {@link #performLayoutAndPlaceSurfacesLockedInner} to reduce size of method.
     *
     *
     * @param currentTime The time which animations use for calculating transitions.
     * @param currentTime The time which animations use for calculating transitions.
     * @param dw Width of app window.
     * @param dh Height of app window.
     * @param innerDw Width of app window.
     * @param innerDw Width of app window.
     * @param innerDh Height of app window.
     * @param innerDh Height of app window.
     */
     */
    private void updateWindowsAndWallpaperLocked(final long currentTime,
    private int updateWindowsAndWallpaperLocked(final long currentTime, final int dw, final int dh,
                                                final int innerDw, final int innerDh) {
                                                final int innerDw, final int innerDh) {
        int i;
        final int N = mWindows.size();


        for (i=N-1; i>=0; i--) {
        mPolicy.beginAnimationLw(dw, dh);

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


            final WindowManager.LayoutParams attrs = w.mAttrs;
            final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -7684,9 +7687,6 @@ public class WindowManagerService extends IWindowManager.Stub


                final boolean wasAnimating = w.mAnimating;
                final boolean wasAnimating = w.mAnimating;


                int animDw = innerDw;
                int animDh = innerDh;

                // If the window has moved due to its containing
                // If the window has moved due to its containing
                // content frame changing, then we'd like to animate
                // content frame changing, then we'd like to animate
                // it.  The checks here are ordered by what is least
                // it.  The checks here are ordered by what is least
@@ -7698,13 +7698,15 @@ public class WindowManagerService extends IWindowManager.Stub
                    Animation a = AnimationUtils.loadAnimation(mContext,
                    Animation a = AnimationUtils.loadAnimation(mContext,
                            com.android.internal.R.anim.window_move_from_decor);
                            com.android.internal.R.anim.window_move_from_decor);
                    w.setAnimation(a);
                    w.setAnimation(a);
                    animDw = w.mLastFrame.left - w.mFrame.left;
                    w.mAnimDw = w.mLastFrame.left - w.mFrame.left;
                    animDh = w.mLastFrame.top - w.mFrame.top;
                    w.mAnimDh = w.mLastFrame.top - w.mFrame.top;
                } else {
                    w.mAnimDw = innerDw;
                    w.mAnimDh = innerDh;
                }
                }


                // Execute animation.
                // Execute animation.
                final boolean nowAnimating = w.stepAnimationLocked(currentTime,
                final boolean nowAnimating = w.isAnimating();
                        animDw, animDh);


                // If this window is animating, make a note that we have
                // If this window is animating, make a note that we have
                // an animating window and take care of a request to run
                // an animating window and take care of a request to run
@@ -7846,6 +7848,8 @@ public class WindowManagerService extends IWindowManager.Stub
                w.performShowLocked();
                w.performShowLocked();
            }
            }
        } // end forall windows
        } // end forall windows

        return mPolicy.finishAnimationLw();
    }
    }


    /**
    /**
@@ -8116,7 +8120,7 @@ public class WindowManagerService extends IWindowManager.Stub
     *
     *
     * @return bitmap indicating if another pass through layout must be made.
     * @return bitmap indicating if another pass through layout must be made.
     */
     */
    private int handleAnimatingAndTransitionLocked() {
    private int handleAnimatingStoppedAndTransitionLocked() {
        int changes = 0;
        int changes = 0;


        mAppTransitionRunning = false;
        mAppTransitionRunning = false;
@@ -8652,7 +8656,6 @@ public class WindowManagerService extends IWindowManager.Stub
        boolean focusDisplayed = false;
        boolean focusDisplayed = false;
        mInnerFields.mAnimating = false;
        mInnerFields.mAnimating = false;
        boolean createWatermark = false;
        boolean createWatermark = false;
        boolean updateRotation = false;


        if (mFxSession == null) {
        if (mFxSession == null) {
            mFxSession = new SurfaceSession();
            mFxSession = new SurfaceSession();
@@ -8706,22 +8709,13 @@ public class WindowManagerService extends IWindowManager.Stub


                // FIRST LOOP: Perform a layout, if needed.
                // FIRST LOOP: Perform a layout, if needed.
                if (repeats < 4) {
                if (repeats < 4) {
                    performLayoutLockedInner(repeats == 0, false /*updateInputWindows*/);
                    performLayoutLockedInner(repeats == 1, false /*updateInputWindows*/);
                } else {
                } else {
                    Slog.w(TAG, "Layout repeat skipped after too many iterations");
                    Slog.w(TAG, "Layout repeat skipped after too many iterations");
                }
                }


                changes = 0;
                ++mTransactionSequence;
                ++mTransactionSequence;


                // Update animations of all applications, including those
                // associated with exiting/removed apps
                mInnerFields.mAnimating = false;

                // SECOND LOOP: Execute animations and update visibility of windows.
                updateRotation |=
                        updateAppsAndRotationAnimationsLocked(currentTime, innerDw, innerDh);

                if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: seq="
                if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: seq="
                        + mTransactionSequence + " mAnimating="
                        + mTransactionSequence + " mAnimating="
                        + mInnerFields.mAnimating);
                        + mInnerFields.mAnimating);
@@ -8733,11 +8727,7 @@ public class WindowManagerService extends IWindowManager.Stub
                mInnerFields.mWindowAnimationBackground = null;
                mInnerFields.mWindowAnimationBackground = null;
                mInnerFields.mWindowAnimationBackgroundColor = 0;
                mInnerFields.mWindowAnimationBackgroundColor = 0;


                mPolicy.beginAnimationLw(dw, dh);
                changes = updateWindowsAndWallpaperLocked(currentTime, dw, dh, innerDw, innerDh);

                updateWindowsAndWallpaperLocked(currentTime, innerDw, innerDh);

                changes |= mPolicy.finishAnimationLw();


                if (mInnerFields.mTokenMayBeDrawn) {
                if (mInnerFields.mTokenMayBeDrawn) {
                    changes |= testTokenMayBeDrawnLocked();
                    changes |= testTokenMayBeDrawnLocked();
@@ -8759,7 +8749,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    // reflects the correct Z-order, but the window list may now
                    // reflects the correct Z-order, but the window list may now
                    // be out of sync with it.  So here we will just rebuild the
                    // be out of sync with it.  So here we will just rebuild the
                    // entire app window list.  Fun!
                    // entire app window list.  Fun!
                    changes |= handleAnimatingAndTransitionLocked();
                    changes |= handleAnimatingStoppedAndTransitionLocked();
                }
                }


                if (mInnerFields.mWallpaperForceHidingChanged && changes == 0 && !mAppTransitionReady) {
                if (mInnerFields.mWallpaperForceHidingChanged && changes == 0 && !mAppTransitionReady) {
@@ -8782,6 +8772,12 @@ public class WindowManagerService extends IWindowManager.Stub
                        + Integer.toHexString(changes));
                        + Integer.toHexString(changes));
            } while (changes != 0);
            } while (changes != 0);


            // Update animations of all applications, including those
            // associated with exiting/removed apps
            mInnerFields.mAnimating = false;

            updateWindowsAppsAndRotationAnimationsLocked(currentTime, innerDw, innerDh);

            // THIRD LOOP: Update the surfaces of all windows.
            // THIRD LOOP: Update the surfaces of all windows.


            final boolean someoneLosingFocus = mLosingFocus.size() != 0;
            final boolean someoneLosingFocus = mLosingFocus.size() != 0;
@@ -9023,16 +9019,17 @@ public class WindowManagerService extends IWindowManager.Stub
            mTurnOnScreen = false;
            mTurnOnScreen = false;
        }
        }


        if (updateRotation) {
        if (mInnerFields.mUpdateRotation) {
            if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
            if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
            if (updateRotationUncheckedLocked(false)) {
            if (updateRotationUncheckedLocked(false)) {
                mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
                mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
            } else {
            } else {
                updateRotation = false;
                mInnerFields.mUpdateRotation = false;
            }
            }
        }
        }


        if (mInnerFields.mOrientationChangeComplete && !needRelayout && !updateRotation) {
        if (mInnerFields.mOrientationChangeComplete && !needRelayout &&
                !mInnerFields.mUpdateRotation) {
            checkDrawnWindowsLocked();
            checkDrawnWindowsLocked();
        }
        }


+9 −3
Original line number Original line Diff line number Diff line
@@ -297,6 +297,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    CharSequence mLastTitle;
    CharSequence mLastTitle;
    boolean mWasPaused;
    boolean mWasPaused;


    // Used to save animation distances between the time they are calculated and when they are 
    // used.
    int mAnimDw;
    int mAnimDh;

    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
           WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
           WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
           int viewVisibility) {
           int viewVisibility) {
@@ -973,7 +978,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {


    // This must be called while inside a transaction.  Returns true if
    // This must be called while inside a transaction.  Returns true if
    // there is more animation to run.
    // there is more animation to run.
    boolean stepAnimationLocked(long currentTime, int dw, int dh) {
    boolean stepAnimationLocked(long currentTime) {
        if (!mService.mDisplayFrozen && mService.mPolicy.isScreenOnFully()) {
        if (!mService.mDisplayFrozen && mService.mPolicy.isScreenOnFully()) {
            // We will run animations as long as the display isn't frozen.
            // We will run animations as long as the display isn't frozen.


@@ -985,8 +990,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                        WindowManagerService.TAG, "Starting animation in " + this +
                        WindowManagerService.TAG, "Starting animation in " + this +
                        " @ " + currentTime + ": ww=" + mFrame.width() +
                        " @ " + currentTime + ": ww=" + mFrame.width() +
                        " wh=" + mFrame.height() +
                        " wh=" + mFrame.height() +
                        " dw=" + dw + " dh=" + dh + " scale=" + mService.mWindowAnimationScale);
                        " dw=" + mAnimDw + " dh=" + mAnimDh +
                    mAnimation.initialize(mFrame.width(), mFrame.height(), dw, dh);
                        " scale=" + mService.mWindowAnimationScale);
                    mAnimation.initialize(mFrame.width(), mFrame.height(), mAnimDw, mAnimDh);
                    mAnimation.setStartTime(currentTime);
                    mAnimation.setStartTime(currentTime);
                    mLocalAnimating = true;
                    mLocalAnimating = true;
                    mAnimating = true;
                    mAnimating = true;