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

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

Merge changes I4752bdf1,I37690cf2

* changes:
  Move Surface operations into existing transaction.
  Clear orientation variable until rotation is done.
parents 26c246a3 acaf9cca
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ class ScreenRotationAnimation {
    private boolean mMoreStartEnter;
    private boolean mMoreStartExit;
    private boolean mMoreStartFrame;
    long mHalfwayPoint;

    public void printTo(String prefix, PrintWriter pw) {
        pw.print(prefix); pw.print("mSurface="); pw.print(mSurface);
@@ -655,6 +656,9 @@ class ScreenRotationAnimation {
    }

    private boolean stepAnimation(long now) {
        if (now > mHalfwayPoint) {
            mHalfwayPoint = Long.MAX_VALUE;
        }
        if (mFinishAnimReady && mFinishAnimStartTime < 0) {
            if (DEBUG_STATE) Slog.v(TAG, "Step: finish anim now ready");
            mFinishAnimStartTime = now;
@@ -915,6 +919,7 @@ class ScreenRotationAnimation {
                mRotateExitAnimation.setStartTime(now);
            }
            mAnimRunning = true;
            mHalfwayPoint = now + mRotateEnterAnimation.getDuration() / 2;
        }

        return stepAnimation(now);
+71 −69
Original line number Diff line number Diff line
@@ -4245,6 +4245,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    if (w.mHasSurface && !w.mOrientationChanging) {
                        if (DEBUG_ORIENTATION) Slog.v(TAG, "set mOrientationChanging of " + w);
                        w.mOrientationChanging = true;
                        mInnerFields.mOrientationChangeComplete = false;
                    }
                    unfrozeWindows = true;
                }
@@ -5550,6 +5551,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (w.mHasSurface) {
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Set mOrientationChanging of " + w);
                w.mOrientationChanging = true;
                mInnerFields.mOrientationChangeComplete = false;
            }
        }
        for (int i=mRotationWatchers.size()-1; i>=0; i--) {
@@ -7654,6 +7656,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (DEBUG_ORIENTATION) Slog.v(TAG,
                    "Changing surface while display frozen: " + w);
            w.mOrientationChanging = true;
            mInnerFields.mOrientationChangeComplete = false;
            if (!mWindowsFreezingScreen) {
                mWindowsFreezingScreen = true;
                // XXX should probably keep timeout from
@@ -8022,7 +8025,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    Slog.v(TAG, "Resize reasons: "
                            + " contentInsetsChanged=" + w.mContentInsetsChanged
                            + " visibleInsetsChanged=" + w.mVisibleInsetsChanged
                            + " surfaceResized=" + w.mWinAnimator.mSurfaceResized
                            + " surfaceResized=" + winAnimator.mSurfaceResized
                            + " configChanged=" + configChanged);
                }

@@ -8037,7 +8040,7 @@ public class WindowManagerService extends IWindowManager.Stub
                if (w.mOrientationChanging) {
                    if (DEBUG_ORIENTATION) Slog.v(TAG,
                            "Orientation start waiting for draw in "
                            + w + ", surface " + w.mWinAnimator.mSurface);
                            + w + ", surface " + winAnimator.mSurface);
                    winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
                    if (w.mAppToken != null) {
                        w.mAppToken.allDrawn = false;
@@ -8045,15 +8048,15 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                if (!mResizingWindows.contains(w)) {
                    if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                            "Resizing window " + w + " to " + w.mWinAnimator.mSurfaceW
                            + "x" + w.mWinAnimator.mSurfaceH);
                            "Resizing window " + w + " to " + winAnimator.mSurfaceW
                            + "x" + winAnimator.mSurfaceH);
                    mResizingWindows.add(w);
                }
            } else if (w.mOrientationChanging) {
                if (w.isDrawnLw()) {
                    if (DEBUG_ORIENTATION) Slog.v(TAG,
                            "Orientation not waiting for draw in "
                            + w + ", surface " + w.mWinAnimator.mSurface);
                            + w + ", surface " + winAnimator.mSurface);
                    w.mOrientationChanging = false;
                }
            }
@@ -8125,7 +8128,8 @@ public class WindowManagerService extends IWindowManager.Stub
    private final void performLayoutAndPlaceSurfacesLockedInner(
            boolean recoveringMemory) {
        if (DEBUG_WINDOW_TRACE) {
            Slog.v(TAG, "performLayoutAndPlaceSurfacesLockedInner: entry");
            Slog.v(TAG, "performLayoutAndPlaceSurfacesLockedInner: entry. Called by "
                    + getCallers(3));
        }
        if (mDisplay == null) {
            Slog.i(TAG, "skipping performLayoutAndPlaceSurfacesLockedInner with no mDisplay");
@@ -8258,7 +8262,52 @@ public class WindowManagerService extends IWindowManager.Stub
                    // has been updated accordingly.
                    updateWallpaperVisibilityLocked();
                }

                final WindowStateAnimator winAnimator = w.mWinAnimator;

                // If the window has moved due to its containing
                // content frame changing, then we'd like to animate
                // it.
                if (w.mHasSurface && w.shouldAnimateMove()) {
                    // Frame has moved, containing content frame
                    // has also moved, and we're not currently animating...
                    // let's do something.
                    Animation a = AnimationUtils.loadAnimation(mContext,
                            com.android.internal.R.anim.window_move_from_decor);
                    winAnimator.setAnimation(a);
                    winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left;
                    winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top;
                } else {
                    winAnimator.mAnimDw = innerDw;
                    winAnimator.mAnimDh = innerDh;
                }

                //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
                w.mContentChanged = false;

                // Moved from updateWindowsAndWallpaperLocked().
                if (w.mHasSurface) {
                    // Take care of the window being ready to display.
                    if (winAnimator.commitFinishDrawingLocked(currentTime)) {
                        if ((w.mAttrs.flags
                                & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                            if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
                                    "First draw done in potential wallpaper target " + w);
                            mInnerFields.mWallpaperMayChange = true;
                            mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                            if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                                debugLayoutRepeats("updateWindowsAndWallpaperLocked 1",
                                    mPendingLayoutChanges);
                            }
                        }
                    }

                    winAnimator.setSurfaceBoundaries(recoveringMemory);
                }

                updateResizingWindows(w);
            }

            if (focusDisplayed) {
                mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
            }
@@ -8340,64 +8389,6 @@ public class WindowManagerService extends IWindowManager.Stub
            if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded", mPendingLayoutChanges);
        }

        final int N = mWindows.size();
        for (i=N-1; i>=0; i--) {
            final WindowState w = mWindows.get(i);
            final WindowStateAnimator winAnimator = w.mWinAnimator; 
            
            // If the window has moved due to its containing
            // content frame changing, then we'd like to animate
            // it.
            if (w.mHasSurface && w.shouldAnimateMove()) {
                // Frame has moved, containing content frame
                // has also moved, and we're not currently animating...
                // let's do something.
                Animation a = AnimationUtils.loadAnimation(mContext,
                        com.android.internal.R.anim.window_move_from_decor);
                winAnimator.setAnimation(a);
                winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left;
                winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top;
            } else {
                winAnimator.mAnimDw = innerDw;
                winAnimator.mAnimDh = innerDh;
            }

            //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
            w.mContentChanged = false;
            
            // TODO(cmautner): Can this move up to the loop at the end of try/catch above?
            updateResizingWindows(w);

            // Moved from updateWindowsAndWallpaperLocked().
            if (w.mHasSurface) {
                // Take care of the window being ready to display.
                if (winAnimator.commitFinishDrawingLocked(currentTime)) {
                    if ((w.mAttrs.flags
                            & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                        if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
                                "First draw done in potential wallpaper target " + w);
                        mInnerFields.mWallpaperMayChange = true;
                        mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            debugLayoutRepeats("updateWindowsAndWallpaperLocked 1",
                                mPendingLayoutChanges);
                        }
                    }
                }
            }
        }

        if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG,
                "With display frozen, orientationChangeComplete="
                + mInnerFields.mOrientationChangeComplete);
        if (mInnerFields.mOrientationChangeComplete) {
            if (mWindowsFreezingScreen) {
                mWindowsFreezingScreen = false;
                mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
            }
            stopFreezingDisplayLocked();
        }

        if (!mResizingWindows.isEmpty()) {
            for (i = mResizingWindows.size() - 1; i >= 0; i--) {
                WindowState win = mResizingWindows.get(i);
@@ -8436,6 +8427,17 @@ public class WindowManagerService extends IWindowManager.Stub
            mResizingWindows.clear();
        }

        if (DEBUG_ORIENTATION && mDisplayFrozen) Slog.v(TAG,
                "With display frozen, orientationChangeComplete="
                + mInnerFields.mOrientationChangeComplete);
        if (mInnerFields.mOrientationChangeComplete) {
            if (mWindowsFreezingScreen) {
                mWindowsFreezingScreen = false;
                mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
            }
            stopFreezingDisplayLocked();
        }

        // Destroy the surface of any windows that are no longer visible.
        boolean wallpaperDestroyed = false;
        i = mDestroySurface.size();
+30 −15
Original line number Diff line number Diff line
@@ -499,6 +499,14 @@ class WindowStateAnimator {
            sSurfaces.remove(this);
        }

        @Override
        public void release() {
            super.release();
            Slog.v(SURFACE_TAG, "release: " + this + ". Called by "
                    + WindowManagerService.getCallers(3));
            sSurfaces.remove(this);
        }

        static void dumpAllSurfaces() {
            final int N = sSurfaces.size();
            for (int i = 0; i < N; i++) {
@@ -886,22 +894,8 @@ class WindowStateAnimator {
        mDtDy = mWin.mGlobalScale;
    }

    public void prepareSurfaceLocked(final boolean recoveringMemory) {
    void setSurfaceBoundaries(final boolean recoveringMemory) {
        final WindowState w = mWin;
        if (mSurface == null) {
            if (w.mOrientationChanging) {
                if (DEBUG_ORIENTATION) {
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                }
                w.mOrientationChanging = false;
            }
            return;
        }

        boolean displayed = false;

        computeShownFrameLocked();

        int width, height;
        if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
            // for a scaled surface, we just want to use
@@ -950,6 +944,8 @@ class WindowStateAnimator {
                        "SIZE " + width + "x" + height, null);
                mSurfaceResized = true;
                mSurface.setSize(width, height);
                mAnimator.mPendingLayoutChanges |=
                        WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
            } catch (RuntimeException e) {
                // If something goes wrong with the surface (such
                // as running out of memory), don't take down the
@@ -961,6 +957,25 @@ class WindowStateAnimator {
                }
            }
        }
    }

    public void prepareSurfaceLocked(final boolean recoveringMemory) {
        final WindowState w = mWin;
        if (mSurface == null) {
            if (w.mOrientationChanging) {
                if (DEBUG_ORIENTATION) {
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                }
                w.mOrientationChanging = false;
            }
            return;
        }

        boolean displayed = false;

        computeShownFrameLocked();

        setSurfaceBoundaries(recoveringMemory);

        if (w.mAttachedHidden || !w.isReadyForDisplay()) {
            if (!mLastHidden) {