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

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

Merge "Refactor to convert four state booleans to int."

parents ea7ff4d2 749a7bb2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -394,8 +394,7 @@ class AppWindowToken extends WindowToken {
                if (!win.isDrawnLw()) {
                    Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurface
                            + " pv=" + win.mPolicyVisibility
                            + " dp=" + win.mWinAnimator.mDrawPending
                            + " cdp=" + win.mWinAnimator.mCommitDrawPending
                            + " mDrawState=" + win.mWinAnimator.mDrawState
                            + " ah=" + win.mAttachedHidden
                            + " th="
                            + (win.mAppToken != null
+2 −3
Original line number Diff line number Diff line
@@ -299,8 +299,7 @@ public class WindowAnimator {
                        if (!w.isDrawnLw()) {
                            Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface
                                    + " pv=" + w.mPolicyVisibility
                                    + " dp=" + winAnimator.mDrawPending
                                    + " cdp=" + winAnimator.mCommitDrawPending
                                    + " mDrawState=" + winAnimator.mDrawState
                                    + " ah=" + w.mAttachedHidden
                                    + " th=" + atoken.hiddenRequested
                                    + " a=" + winAnimator.mAnimating);
@@ -323,7 +322,7 @@ public class WindowAnimator {
                        atoken.startingDisplayed = true;
                    }
                }
            } else if (w.mReadyToShow) {
            } else if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
                if (winAnimator.performShowLocked()) {
                    mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
+6 −7
Original line number Diff line number Diff line
@@ -1589,8 +1589,7 @@ public class WindowManagerService extends IWindowManager.Stub
                }
            }
            if (DEBUG_WALLPAPER) Slog.v(TAG, "Win " + w + ": readyfordisplay="
                    + w.isReadyForDisplay() + " drawpending=" + w.mWinAnimator.mDrawPending
                    + " commitdrawpending=" + w.mWinAnimator.mCommitDrawPending);
                    + w.isReadyForDisplay() + " mDrawState=" + w.mWinAnimator.mDrawState);
            if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
                    && (mWallpaperTarget == w || w.isDrawnLw())) {
                if (DEBUG_WALLPAPER) Slog.v(TAG,
@@ -8111,9 +8110,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    if (DEBUG_ORIENTATION) Slog.v(TAG,
                            "Orientation start waiting for draw in "
                            + w + ", surface " + w.mWinAnimator.mSurface);
                    winAnimator.mDrawPending = true;
                    winAnimator.mCommitDrawPending = false;
                    w.mReadyToShow = false;
                    winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
                    if (w.mAppToken != null) {
                        w.mAppToken.allDrawn = false;
                    }
@@ -8498,12 +8495,14 @@ public class WindowManagerService extends IWindowManager.Stub
                                + Integer.toHexString(diff));
                    }
                    win.mConfiguration = mCurConfiguration;
                    if (DEBUG_ORIENTATION && winAnimator.mDrawPending) Slog.i(
                    if (DEBUG_ORIENTATION &&
                            winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
                            TAG, "Resizing " + win + " WITH DRAW PENDING"); 
                    win.mClient.resized((int)winAnimator.mSurfaceW,
                            (int)winAnimator.mSurfaceH,
                            win.mLastContentInsets, win.mLastVisibleInsets,
                            winAnimator.mDrawPending, configChanged ? win.mConfiguration : null);
                            winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
                            configChanged ? win.mConfiguration : null);
                    win.mContentInsetsChanged = false;
                    win.mVisibleInsetsChanged = false;
                    winAnimator.mSurfaceResized = false;
+6 −20
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    boolean mPolicyVisibilityAfterAnim = true;
    boolean mAppFreezing;
    boolean mAttachedHidden;    // is our parent window hidden?
    boolean mLastHidden;        // was this window last hidden?
    boolean mWallpaperVisible;  // for wallpaper, what was last vis report?

    /**
@@ -206,15 +205,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    // when in that case until the layout is done.
    boolean mLayoutNeeded;

    // This is set during the time after the window's drawing has been
    // committed, and before its surface is actually shown.  It is used
    // to delay showing the surface until all windows in a token are ready
    // to be shown.
    boolean mReadyToShow;

    // Set when the window has been shown in the screen the first time.
    boolean mHasDrawn;

    // Currently running an exit animation?
    boolean mExiting;

@@ -744,7 +734,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
     */
    public boolean isDrawnLw() {
        return mHasSurface && !mDestroying &&
            !mWinAnimator.mDrawPending && !mWinAnimator.mCommitDrawPending;
                (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
                || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
    }

    /**
@@ -764,7 +755,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
     * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
     */
    boolean shouldAnimateMove() {
        return mContentChanged && !mExiting && !mLastHidden && mService.okToDisplay()
        return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
                && (mFrame.top != mLastFrame.top
                        || mFrame.left != mLastFrame.left)
                && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
@@ -837,10 +828,12 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
    }

    @Override
    public boolean hasDrawnLw() {
        return mHasDrawn;
        return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
    }

    @Override
    public boolean showLw(boolean doAnimation) {
        return showLw(doAnimation, true);
    }
@@ -985,7 +978,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            }
            pw.print(prefix); pw.print("mViewVisibility=0x");
            pw.print(Integer.toHexString(mViewVisibility));
            pw.print(" mLastHidden="); pw.print(mLastHidden);
            pw.print(" mHaveFrame="); pw.print(mHaveFrame);
            pw.print(" mObscured="); pw.println(mObscured);
            pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
@@ -1048,12 +1040,6 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                    pw.println();
        }
        mWinAnimator.dump(pw, prefix, dumpAll);
        if (dumpAll) {
            pw.print(prefix); pw.print("mDrawPending="); pw.print(mWinAnimator.mDrawPending);
                    pw.print(" mCommitDrawPending="); pw.print(mWinAnimator.mCommitDrawPending);
                    pw.print(" mReadyToShow="); pw.print(mReadyToShow);
                    pw.print(" mHasDrawn="); pw.println(mHasDrawn);
        }
        if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
            pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
                    pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
+54 −49
Original line number Diff line number Diff line
@@ -100,14 +100,24 @@ class WindowStateAnimator {
    // an enter animation.
    boolean mEnterAnimationPending;

    // This is set after the Surface has been created but before the
    // window has been drawn.  During this time the surface is hidden.
    boolean mDrawPending;

    // This is set after the window has finished drawing for the first
    // time but before its surface is shown.  The surface will be
    // displayed when the next layout is run.
    boolean mCommitDrawPending;
    /** This is set when there is no Surface */
    static final int NO_SURFACE = 0;
    /** This is set after the Surface has been created but before the window has been drawn. During
     * this time the surface is hidden. */
    static final int DRAW_PENDING = 1;
    /** This is set after the window has finished drawing for the first time but before its surface
     * is shown.  The surface will be displayed when the next layout is run. */
    static final int COMMIT_DRAW_PENDING = 2;
    /** This is set during the time after the window's drawing has been committed, and before its
     * surface is actually shown.  It is used to delay showing the surface until all windows in a
     * token are ready to be shown. */
    static final int READY_TO_SHOW = 3;
    /** Set when the window has been shown in the screen the first time. */
    static final int HAS_DRAWN = 4;
    int mDrawState;

    /** Was this window last hidden? */
    boolean mLastHidden;

    public WindowStateAnimator(final WindowManagerService service, final WindowState win,
                               final WindowState attachedWindow) {
@@ -130,7 +140,7 @@ class WindowStateAnimator {
        mAnimation.scaleCurrentDuration(mService.mWindowAnimationScale);
        // Start out animation gone if window is gone, or visible if window is visible.
        mTransformation.clear();
        mTransformation.setAlpha(mWin.mLastHidden ? 0 : 1);
        mTransformation.setAlpha(mLastHidden ? 0 : 1);
        mHasLocalTransformation = true;
    }

@@ -291,7 +301,7 @@ class WindowStateAnimator {
            }
        }
        mTransformation.clear();
        if (mWin.mHasDrawn
        if (mDrawState == HAS_DRAWN
                && mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
                && mWin.mAppToken != null
                && mWin.mAppToken.firstWindowDrawn
@@ -347,7 +357,7 @@ class WindowStateAnimator {
            } catch (RuntimeException e) {
                Slog.w(TAG, "Error hiding surface in " + this, e);
            }
            mWin.mLastHidden = true;
            mLastHidden = true;
        }
        mWin.mExiting = false;
        if (mWin.mRemoveOnExit) {
@@ -357,11 +367,10 @@ class WindowStateAnimator {
    }

    boolean finishDrawingLocked() {
        if (mDrawPending) {
        if (mDrawState == DRAW_PENDING) {
            if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
                TAG, "finishDrawingLocked: " + this + " in " + mSurface);
            mCommitDrawPending = true;
            mDrawPending = false;
            mDrawState = COMMIT_DRAW_PENDING;
            return true;
        }
        return false;
@@ -370,11 +379,10 @@ class WindowStateAnimator {
    // This must be called while inside a transaction.
    boolean commitFinishDrawingLocked(long currentTime) {
        //Slog.i(TAG, "commitFinishDrawingLocked: " + mSurface);
        if (!mCommitDrawPending) {
        if (mDrawState != COMMIT_DRAW_PENDING) {
            return false;
        }
        mCommitDrawPending = false;
        mWin.mReadyToShow = true;
        mDrawState = READY_TO_SHOW;
        final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
        final AppWindowToken atoken = mWin.mAppToken;
        if (atoken == null || atoken.allDrawn || starting) {
@@ -389,9 +397,7 @@ class WindowStateAnimator {
            mSurfacePendingDestroy = false;
            if (DEBUG_ORIENTATION) Slog.i(TAG,
                    "createSurface " + this + ": DRAW NOW PENDING");
            mDrawPending = true;
            mCommitDrawPending = false;
            mWin.mReadyToShow = false;
            mDrawState = DRAW_PENDING;
            if (mWin.mAppToken != null) {
                mWin.mAppToken.allDrawn = false;
            }
@@ -456,10 +462,12 @@ class WindowStateAnimator {
                mWin.mHasSurface = false;
                Slog.w(TAG, "OutOfResourcesException creating surface");
                mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);
                mDrawState = NO_SURFACE;
                return null;
            } catch (Exception e) {
                mWin.mHasSurface = false;
                Slog.e(TAG, "Exception creating surface", e);
                mDrawState = NO_SURFACE;
                return null;
            }

@@ -492,7 +500,7 @@ class WindowStateAnimator {
                    Slog.w(TAG, "Error creating surface in " + w, e);
                    mService.reclaimSomeSurfaceMemoryLocked(this, "create-init", true);
                }
                mWin.mLastHidden = true;
                mLastHidden = true;
            } finally {
                Surface.closeTransaction();
                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
@@ -509,10 +517,8 @@ class WindowStateAnimator {
            mWin.mAppToken.startingDisplayed = false;
        }

        mDrawState = NO_SURFACE;
        if (mSurface != null) {
            mDrawPending = false;
            mCommitDrawPending = false;
            mWin.mReadyToShow = false;

            int i = mWin.mChildWindows.size();
            while (i > 0) {
@@ -823,9 +829,9 @@ class WindowStateAnimator {
        }

        if (w.mAttachedHidden || !w.isReadyForDisplay()) {
            if (!w.mLastHidden) {
            if (!mLastHidden) {
                //dump();
                w.mLastHidden = true;
                mLastHidden = true;
                if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
                        "HIDE (performLayout)", null);
                if (mSurface != null) {
@@ -856,7 +862,7 @@ class WindowStateAnimator {
                || mLastDtDy != mDtDy
                || w.mLastHScale != w.mHScale
                || w.mLastVScale != w.mVScale
                || w.mLastHidden) {
                || mLastHidden) {
            displayed = true;
            mLastAlpha = mShownAlpha;
            mLastLayer = mAnimLayer;
@@ -881,23 +887,14 @@ class WindowStateAnimator {
                    mSurface.setMatrix(
                        mDsDx*w.mHScale, mDtDx*w.mVScale,
                        mDsDy*w.mHScale, mDtDy*w.mVScale);
                } catch (RuntimeException e) {
                    Slog.w(TAG, "Error updating surface in " + w, e);
                    if (!recoveringMemory) {
                        mService.reclaimSomeSurfaceMemoryLocked(this, "update", true);
                    }
                }
            }

            if (w.mLastHidden && w.isDrawnLw()
                    && !w.mReadyToShow) {
                    if (mLastHidden && mDrawState == HAS_DRAWN) {
                        if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
                                "SHOW (performLayout)", null);
                        if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + w
                                + " during relayout");
                        if (showSurfaceRobustlyLocked()) {
                    w.mHasDrawn = true;
                    w.mLastHidden = false;
                            mLastHidden = false;
                        } else {
                            w.mOrientationChanging = false;
                        }
@@ -905,6 +902,13 @@ class WindowStateAnimator {
                    if (mSurface != null) {
                        w.mToken.hasVisible = true;
                    }
                } catch (RuntimeException e) {
                    Slog.w(TAG, "Error updating surface in " + w, e);
                    if (!recoveringMemory) {
                        mService.reclaimSomeSurfaceMemoryLocked(this, "update", true);
                    }
                }
            }
        } else {
            displayed = true;
        }
@@ -961,11 +965,11 @@ class WindowStateAnimator {
                e.fillInStackTrace();
            }
            Slog.v(TAG, "performShow on " + this
                    + ": readyToShow=" + mWin.mReadyToShow + " readyForDisplay="
                    + ": mDrawState=" + mDrawState + " readyForDisplay="
                    + mWin.isReadyForDisplay()
                    + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING), e);
        }
        if (mWin.mReadyToShow && mWin.isReadyForDisplay()) {
        if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplay()) {
            if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
                WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null);
            if (DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + this
@@ -987,9 +991,8 @@ class WindowStateAnimator {
            applyEnterAnimationLocked();

            mLastAlpha = -1;
            mWin.mHasDrawn = true;
            mWin.mLastHidden = false;
            mWin.mReadyToShow = false;
            mLastHidden = false;
            mDrawState = HAS_DRAWN;

            int i = mWin.mChildWindows.size();
            while (i > 0) {
@@ -1170,6 +1173,8 @@ class WindowStateAnimator {
        if (mSurface != null) {
            if (dumpAll) {
                pw.print(prefix); pw.print("mSurface="); pw.println(mSurface);
                pw.print(prefix); pw.print("mDrawState="); pw.print(mDrawState);
                pw.print(" mLastHidden="); pw.println(mLastHidden);
            }
            pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown);
                    pw.print(" layer="); pw.print(mSurfaceLayer);