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

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

Merge "More steps to isolate animation."

parents 048311ca 01cd0e7d
Loading
Loading
Loading
Loading
+57 −40
Original line number Diff line number Diff line
@@ -38,10 +38,18 @@ public class WindowAnimator {
    ArrayList<WindowStateAnimator> mWinAnimators = new ArrayList<WindowStateAnimator>();

    boolean mAnimating;

    /** Variables only intended to be valid within each pass through animate(). Does not contain
     * persistent state. */
    private class InnerLoopParams {
        boolean mTokenMayBeDrawn;
        boolean mForceHiding;
        WindowState mDetachedWallpaper = null;
        WindowState mWindowAnimationBackground;
        int mWindowAnimationBackgroundColor;
    }
    InnerLoopParams mInner = new InnerLoopParams();

    int mAdjResult;

    int mPendingLayoutChanges;
@@ -65,9 +73,9 @@ public class WindowAnimator {
    // Window currently running an animation that has requested it be detached
    // from the wallpaper.  This means we need to ensure the wallpaper is
    // visible behind it in case it animates in a way that would allow it to be
    // seen.
    // seen. If multiple windows satisfy this, use the lowest window.
    WindowState mWindowDetachedWallpaper = null;
    WindowState mDetachedWallpaper = null;

    DimSurface mWindowAnimationBackgroundSurface = null;

    int mBulkUpdateParams = 0;
@@ -103,19 +111,20 @@ public class WindowAnimator {
    }

    private void testWallpaperAndBackgroundLocked() {
        if (mWindowDetachedWallpaper != mDetachedWallpaper) {
        final WindowState detachedWallpaper = mInner.mDetachedWallpaper;
        if (mWindowDetachedWallpaper != detachedWallpaper) {
            if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
                    "Detached wallpaper changed from " + mWindowDetachedWallpaper
                    + " to " + mDetachedWallpaper);
            mWindowDetachedWallpaper = mDetachedWallpaper;
                    + " to " + detachedWallpaper);
            mWindowDetachedWallpaper = detachedWallpaper;
            mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
        }

        if (mWindowAnimationBackgroundColor != 0) {
        if (mInner.mWindowAnimationBackgroundColor != 0) {
            // If the window that wants black is the current wallpaper
            // target, then the black goes *below* the wallpaper so we
            // don't cause the wallpaper to suddenly disappear.
            WindowState target = mWindowAnimationBackground;
            WindowState target = mInner.mWindowAnimationBackground;
            if (mService.mWallpaperTarget == target
                    || mService.mLowerWallpaperTarget == target
                    || mService.mUpperWallpaperTarget == target) {
@@ -135,7 +144,7 @@ public class WindowAnimator {
            final int dh = mDh;
            mWindowAnimationBackgroundSurface.show(dw, dh,
                    target.mWinAnimator.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM,
                    mWindowAnimationBackgroundColor);
                    mInner.mWindowAnimationBackgroundColor);
        } else if (mWindowAnimationBackgroundSurface != null) {
            mWindowAnimationBackgroundSurface.hide();
        }
@@ -199,9 +208,9 @@ public class WindowAnimator {
        ArrayList<WindowStateAnimator> unForceHiding = null;
        boolean wallpaperInUnForceHiding = false;

        for (int i = mService.mWindows.size() - 1; i >= 0; i--) {
            WindowState win = mService.mWindows.get(i);
            WindowStateAnimator winAnimator = win.mWinAnimator;
        for (int i = mWinAnimators.size() - 1; i >= 0; i--) {
            WindowStateAnimator winAnimator = mWinAnimators.get(i);
            WindowState win = winAnimator.mWin;
            final int flags = winAnimator.mAttrFlags;

            if (winAnimator.mSurface != null) {
@@ -220,15 +229,15 @@ public class WindowAnimator {
                    if (winAnimator.mAnimation != null) {
                        if ((flags & FLAG_SHOW_WALLPAPER) != 0
                                && winAnimator.mAnimation.getDetachWallpaper()) {
                            mDetachedWallpaper = win;
                            mInner.mDetachedWallpaper = win;
                        }
                        final int backgroundColor = winAnimator.mAnimation.getBackgroundColor();
                        if (backgroundColor != 0) {
                            if (mWindowAnimationBackground == null
                                    || (winAnimator.mAnimLayer <
                                            mWindowAnimationBackground.mWinAnimator.mAnimLayer)) {
                                mWindowAnimationBackground = win;
                                mWindowAnimationBackgroundColor = backgroundColor;
                            final WindowState background = mInner.mWindowAnimationBackground;
                            if (background == null || (winAnimator.mAnimLayer <
                                    background.mWinAnimator.mAnimLayer)) {
                                mInner.mWindowAnimationBackground = win;
                                mInner.mWindowAnimationBackgroundColor = backgroundColor;
                            }
                        }
                    }
@@ -244,15 +253,15 @@ public class WindowAnimator {
                        && appAnimator.animating) {
                    if ((flags & FLAG_SHOW_WALLPAPER) != 0
                            && appAnimator.animation.getDetachWallpaper()) {
                        mDetachedWallpaper = win;
                        mInner.mDetachedWallpaper = win;
                    }
                    final int backgroundColor = appAnimator.animation.getBackgroundColor();
                    if (backgroundColor != 0) {
                        if (mWindowAnimationBackground == null
                                || (winAnimator.mAnimLayer <
                                        mWindowAnimationBackground.mWinAnimator.mAnimLayer)) {
                            mWindowAnimationBackground = win;
                            mWindowAnimationBackgroundColor = backgroundColor;
                        final WindowState background = mInner.mWindowAnimationBackground;
                        if (background == null || (winAnimator.mAnimLayer <
                                background.mWinAnimator.mAnimLayer)) {
                            mInner.mWindowAnimationBackground = win;
                            mInner.mWindowAnimationBackgroundColor = backgroundColor;
                        }
                    }
                }
@@ -280,10 +289,10 @@ public class WindowAnimator {
                        mService.mFocusMayChange = true;
                    }
                    if (win.isReadyForDisplay() && !winAnimator.isAnimating()) {
                        mForceHiding = true;
                        mInner.mForceHiding = true;
                    }
                    if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
                            "Force hide " + mForceHiding
                            "Force hide " + mInner.mForceHiding
                            + " hasSurface=" + win.mHasSurface
                            + " policyVis=" + win.mPolicyVisibility
                            + " destroying=" + win.mDestroying
@@ -293,7 +302,7 @@ public class WindowAnimator {
                            + " anim=" + win.mWinAnimator.mAnimation);
                } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
                    final boolean changed;
                    if (mForceHiding && !winAnimator.isAnimating()) {
                    if (mInner.mForceHiding && !winAnimator.isAnimating()) {
                        changed = win.hideLw(false, false);
                        if (WindowManagerService.DEBUG_VISIBILITY && changed) Slog.v(TAG,
                                "Now policy hidden: " + win);
@@ -308,7 +317,7 @@ public class WindowAnimator {
                                    unForceHiding = new ArrayList<WindowStateAnimator>();
                                }
                                unForceHiding.add(winAnimator);
                                if ((win.mAttrs.flags&WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                                if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                                    wallpaperInUnForceHiding = true;
                                }
                            }
@@ -320,7 +329,7 @@ public class WindowAnimator {
                            }
                        }
                    }
                    if (changed && (flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                    if (changed && (flags & FLAG_SHOW_WALLPAPER) != 0) {
                        mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
@@ -364,7 +373,7 @@ public class WindowAnimator {
                                        "tokenMayBeDrawn: " + atoken
                                        + " freezingScreen=" + atoken.mAppAnimator.freezingScreen
                                        + " mAppFreezing=" + win.mAppFreezing);
                                mTokenMayBeDrawn = true;
                                mInner.mTokenMayBeDrawn = true;
                            }
                        }
                    } else if (win.isDrawnLw()) {
@@ -454,18 +463,18 @@ public class WindowAnimator {
    }

    private void performAnimationsLocked() {
        mTokenMayBeDrawn = false;
        mForceHiding = false;
        mDetachedWallpaper = null;
        mWindowAnimationBackground = null;
        mWindowAnimationBackgroundColor = 0;
        mInner.mTokenMayBeDrawn = false;
        mInner.mForceHiding = false;
        mInner.mDetachedWallpaper = null;
        mInner.mWindowAnimationBackground = null;
        mInner.mWindowAnimationBackgroundColor = 0;

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

        if (mTokenMayBeDrawn) {
        if (mInner.mTokenMayBeDrawn) {
            testTokenMayBeDrawnLocked();
        }
    }
@@ -526,7 +535,15 @@ public class WindowAnimator {
            Surface.closeTransaction();
        }

        mService.bulkSetParameters(mBulkUpdateParams, mPendingLayoutChanges);
        if (mBulkUpdateParams != 0 || mPendingLayoutChanges != 0) {
            final WindowManagerService.AnimatorToLayoutParams animToLayout = mService.mAnimToLayout;
            synchronized (animToLayout) {
                animToLayout.mBulkUpdateParams = mBulkUpdateParams;
                animToLayout.mPendingLayoutChanges = mPendingLayoutChanges;
                animToLayout.mWindowDetachedWallpaper = mWindowDetachedWallpaper;
                mService.setAnimatorParameters();
            }
        }

        if (mAnimating) {
            mService.scheduleAnimationLocked();
+62 −49
Original line number Diff line number Diff line
@@ -640,7 +640,17 @@ public class WindowManagerService extends IWindowManager.Stub
        private float mButtonBrightness = -1;
        private boolean mUpdateRotation = false;
    }
    LayoutFields mInnerFields = new LayoutFields();
    final LayoutFields mInnerFields = new LayoutFields();

    static class AnimatorToLayoutParams {
      int mBulkUpdateParams;
      int mPendingLayoutChanges;
      WindowState mWindowDetachedWallpaper;
    }
    final AnimatorToLayoutParams mAnimToLayout = new AnimatorToLayoutParams();

    /** The lowest wallpaper target with a detached wallpaper animation on it. */
    WindowState mWindowDetachedWallpaper = null;

    /** Only do a maximum of 6 repeated layouts. After that quit */
    private int mLayoutRepeatCount;
@@ -1576,9 +1586,9 @@ public class WindowManagerService extends IWindowManager.Stub
                    Slog.v(TAG, "List with no IM target:");
                    logWindowList("  ");
                }
                if (DN > 0) moveInputMethodDialogsLocked(-1);;
                if (DN > 0) moveInputMethodDialogsLocked(-1);
            } else {
                moveInputMethodDialogsLocked(-1);;
                moveInputMethodDialogsLocked(-1);
            }

        }
@@ -1640,7 +1650,7 @@ public class WindowManagerService extends IWindowManager.Stub
                continue;
            }
            topCurW = null;
            if (w != mAnimator.mWindowDetachedWallpaper && w.mAppToken != null) {
            if (w != mWindowDetachedWallpaper && w.mAppToken != null) {
                // If this window's app token is hidden and not animating,
                // it is of no interest to us.
                if (w.mAppToken.hidden && w.mAppToken.mAppAnimator.animation == null) {
@@ -1666,7 +1676,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    continue;
                }
                break;
            } else if (w == mAnimator.mWindowDetachedWallpaper) {
            } else if (w == mWindowDetachedWallpaper) {
                windowDetachedI = i;
            }
        }
@@ -3108,13 +3118,12 @@ public class WindowManagerService extends IWindowManager.Stub
            a.setDetachWallpaper(true);
            a.setDuration(duration);
            return a;
        } else {
        }
        // For normal animations, the exiting element just holds in place.
        Animation a = new AlphaAnimation(1, 1);
        a.setDuration(duration);
        return a;
    }
    }

    /**
     * Compute the pivot point for an animation that is scaling from a small
@@ -6826,7 +6835,7 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int REPORT_HARD_KEYBOARD_STATUS_CHANGE = 22;
        public static final int BOOT_TIMEOUT = 23;
        public static final int WAITING_FOR_DRAWN_TIMEOUT = 24;
        public static final int BULK_UPDATE_PARAMETERS = 25;
        public static final int UPDATE_ANIM_PARAMETERS = 25;
        public static final int SHOW_STRICT_MODE_VIOLATION = 26;
        public static final int DO_ANIMATION_CALLBACK = 27;

@@ -7253,25 +7262,27 @@ public class WindowManagerService extends IWindowManager.Stub
                    break;
                }

                case BULK_UPDATE_PARAMETERS: {
                case UPDATE_ANIM_PARAMETERS: {
                    // Used to send multiple changes from the animation side to the layout side.
                    synchronized (mWindowMap) {
                        synchronized (mAnimToLayout) {
                            boolean doRequest = false;
                            final int bulkUpdateParams = mAnimToLayout.mBulkUpdateParams;
                            // TODO(cmautner): As the number of bits grows, use masks of bit groups to
                            //  eliminate unnecessary tests.
                        if ((msg.arg1 & LayoutFields.SET_UPDATE_ROTATION) != 0) {
                            if ((bulkUpdateParams & LayoutFields.SET_UPDATE_ROTATION) != 0) {
                                mInnerFields.mUpdateRotation = true;
                                doRequest = true;
                            }
                        if ((msg.arg1 & LayoutFields.SET_WALLPAPER_MAY_CHANGE) != 0) {
                            if ((bulkUpdateParams & LayoutFields.SET_WALLPAPER_MAY_CHANGE) != 0) {
                                mInnerFields.mWallpaperMayChange = true;
                                doRequest = true;
                            }
                        if ((msg.arg1 & LayoutFields.SET_FORCE_HIDING_CHANGED) != 0) {
                            if ((bulkUpdateParams & LayoutFields.SET_FORCE_HIDING_CHANGED) != 0) {
                                mInnerFields.mWallpaperForceHidingChanged = true;
                                doRequest = true;
                            }
                        if ((msg.arg1 & LayoutFields.CLEAR_ORIENTATION_CHANGE_COMPLETE) != 0) {
                            if ((bulkUpdateParams & LayoutFields.CLEAR_ORIENTATION_CHANGE_COMPLETE) != 0) {
                                mInnerFields.mOrientationChangeComplete = false;
                            } else {
                                mInnerFields.mOrientationChangeComplete = true;
@@ -7279,20 +7290,23 @@ public class WindowManagerService extends IWindowManager.Stub
                                    doRequest = true;
                                }
                            }
                        if ((msg.arg1 & LayoutFields.SET_TURN_ON_SCREEN) != 0) {
                            if ((bulkUpdateParams & LayoutFields.SET_TURN_ON_SCREEN) != 0) {
                                mTurnOnScreen = true;
                            }

                        mPendingLayoutChanges |= msg.arg2;
                            mPendingLayoutChanges |= mAnimToLayout.mPendingLayoutChanges;
                            if (mPendingLayoutChanges != 0) {
                                doRequest = true;
                            }

                            mWindowDetachedWallpaper = mAnimToLayout.mWindowDetachedWallpaper;

                            if (doRequest) {
                                mH.sendEmptyMessage(CLEAR_PENDING_ACTIONS);
                                performLayoutAndPlaceSurfacesLocked();
                            }
                        }
                    }
                    break;
                }

@@ -10008,8 +10022,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    void bulkSetParameters(final int bulkUpdateParams, int pendingLayoutChanges) {
        mH.sendMessage(mH.obtainMessage(H.BULK_UPDATE_PARAMETERS, bulkUpdateParams,
                pendingLayoutChanges));
    void setAnimatorParameters() {
        mH.sendMessage(mH.obtainMessage(H.UPDATE_ANIM_PARAMETERS));
    }
}