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

Commit 63ac65c5 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Some fixes for saved surfaces"

parents c0848f11 bfc2f8f6
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -339,8 +339,7 @@ public class AppWindowAnimator {
                return false;
            }

            if ((mAppToken.allDrawn || mAppToken.mAnimatingWithSavedSurface
                    || animating || mAppToken.startingDisplayed)
            if ((mAppToken.allDrawn || animating || mAppToken.startingDisplayed)
                    && animation != null) {
                if (!animating) {
                    if (DEBUG_ANIM) Slog.v(TAG,
+26 −12
Original line number Diff line number Diff line
@@ -299,10 +299,10 @@ class AppWindowToken extends WindowToken {
        }
    }

    void markSurfacesExiting() {
    void setWindowsExiting(boolean exiting) {
        for (int i = allAppWindows.size() - 1; i >= 0; i--) {
            WindowState win = allAppWindows.get(i);
            win.mExiting = true;
            win.mExiting = exiting;
        }
    }

@@ -312,11 +312,11 @@ class AppWindowToken extends WindowToken {
     * @return true if the surfaces should be saved, false otherwise.
     */
    boolean shouldSaveSurface() {
        // We want to save surface if the app's windows are "allDrawn", or if we're
        // currently animating with save surfaces. (If the app didn't even finish
        // drawing when the user exits, but we have a saved surface from last time,
        // we still want to keep that surface.)
        return allDrawn || mAnimatingWithSavedSurface;
        // We want to save surface if the app's windows are "allDrawn".
        // (If we started entering animation early with saved surfaces, allDrawn
        // should have been restored to true. So we'll save again in that case
        // even if app didn't actually finish drawing.)
        return allDrawn;
    }

    boolean hasSavedSurface() {
@@ -334,13 +334,26 @@ class AppWindowToken extends WindowToken {
            return;
        }
        mAnimatingWithSavedSurface = true;

        // Check if we have enough drawn windows to mark allDrawn= true.
        int numInteresting = 0;
        int numDrawn = 0;
        for (int i = windows.size() - 1; i >= 0; i--) {
            WindowState ws = windows.get(i);
            ws.restoreSavedSurface();
            WindowState w = windows.get(i);
            w.restoreSavedSurface();
            if (w != startingWindow && !w.mAppDied
                    && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
                numInteresting++;
                if (w.isDrawnLw()) {
                    numDrawn++;
                }
        // Mark the app allDrawn since it must be allDrawn at the time
        // it was first saved.
        allDrawn = true;
            }
        }

        allDrawn |= (numInteresting == numDrawn);

        if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
                "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn);
    }

    void destroySavedSurfaces() {
@@ -348,6 +361,7 @@ class AppWindowToken extends WindowToken {
            WindowState win = windows.get(i);
            win.destroySavedSurface();
        }
        mAnimatingWithSavedSurface = false;
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ public class WindowAnimator {

            final AppWindowToken atoken = win.mAppToken;
            if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
                if (atoken == null || atoken.allDrawn || atoken.mAnimatingWithSavedSurface) {
                if (atoken == null || atoken.allDrawn) {
                    if (winAnimator.performShowLocked()) {
                        setPendingLayoutChanges(displayId,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
+13 −2
Original line number Diff line number Diff line
@@ -2691,7 +2691,17 @@ public class WindowManagerService extends IWindowManager.Stub
            } else {
                winAnimator.mEnterAnimationPending = false;
                winAnimator.mEnteringAnimation = false;
                if (winAnimator.hasSurface() && !win.mExiting) {
                final boolean usingSavedSurfaceBeforeVisible =
                        oldVisibility != View.VISIBLE && win.isAnimatingWithSavedSurface();
                if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
                    if (winAnimator.hasSurface() && !win.mExiting
                            && usingSavedSurfaceBeforeVisible) {
                        Slog.d(TAG, "Ignoring layout to invisible when using saved surface " + win);
                    }
                }

                if (winAnimator.hasSurface() && !win.mExiting
                        && !usingSavedSurfaceBeforeVisible) {
                    if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Relayout invis " + win
                            + ": mExiting=" + win.mExiting);
                    // If we are not currently running the exit animation, we
@@ -4219,6 +4229,7 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                wtoken.inPendingTransaction = true;
                if (visible) {
                    wtoken.setWindowsExiting(false);
                    mOpeningApps.add(wtoken);
                    wtoken.startingMoved = false;
                    wtoken.mEnteringAnimation = true;
@@ -4243,7 +4254,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        }
                    }
                } else {
                    wtoken.markSurfacesExiting();
                    wtoken.setWindowsExiting(true);
                    mClosingApps.add(wtoken);
                    wtoken.mEnteringAnimation = false;
                }
+3 −1
Original line number Diff line number Diff line
@@ -1447,8 +1447,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        }
        for (int i = mAppToken.allAppWindows.size() - 1; i >= 0; i--) {
            final WindowState win = mAppToken.allAppWindows.get(i);
            if (DEBUG_ADD_REMOVE) Slog.d(TAG, "Removing replaced window: " + win);
            if (win.mWillReplaceWindow && win.mReplacingWindow == this) {
                if (DEBUG_ADD_REMOVE) Slog.d(TAG, "Removing replaced window: " + win);
                win.mWillReplaceWindow = false;
                win.mAnimateReplacingWindow = false;
                win.mReplacingRemoveRequested = false;
@@ -2190,6 +2190,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
            if (mAppToken != null) {
                pw.print(prefix); pw.print("mAppToken="); pw.print(mAppToken);
                pw.print(" isAnimatingWithSavedSurface()=");
                pw.print(isAnimatingWithSavedSurface());
                pw.print(" mAppDied=");pw.println(mAppDied);
            }
            if (mTargetAppToken != null) {
Loading