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

Commit b3715834 authored by Vadim Caen's avatar Vadim Caen
Browse files

Move ScreenRotationAnimation to DisplayContent

Move the reference to the ScreenRotationAnimation from WindowAnimator to
DisplayContent now that the animation runs on the
SurfaceAnimationRunner.

Next step is to delete the DisplayContentsAnimator class in
WindowAnimator.

Bug: 131727512
Test: WmTests
Change-Id: I7c9994eebcf95ae0f329c65e39832c18f025101d
parent f8474266
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -449,9 +449,9 @@ public class AppTransitionController {
                "Checking " + apps.size() + " opening apps (frozen="
                        + mService.mDisplayFrozen + " timeout="
                        + mDisplayContent.mAppTransition.isTimeout() + ")...");
        final ScreenRotationAnimation screenRotationAnimation =
                mService.mAnimator.getScreenRotationAnimationLocked(
                        Display.DEFAULT_DISPLAY);

        final ScreenRotationAnimation screenRotationAnimation = mService.mRoot.getDisplayContent(
                Display.DEFAULT_DISPLAY).getRotationAnimation();

        if (!mDisplayContent.mAppTransition.isTimeout()) {
            // Imagine the case where we are changing orientation due to an app transition, but a
+28 −5
Original line number Diff line number Diff line
@@ -497,6 +497,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    /** Windows removed since {@link #mCurrentFocus} was set to null. Used for ANR blaming. */
    final ArrayList<WindowState> mWinRemovedSinceNullFocus = new ArrayList<>();

    private ScreenRotationAnimation mScreenRotationAnimation;

    /**
     * We organize all top-level Surfaces in to the following layers.
     * mOverlayLayer contains a few Surfaces which are always on top of others
@@ -1302,9 +1304,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    void applyRotationLocked(final int oldRotation, final int rotation) {
        mDisplayRotation.applyCurrentRotation(rotation);
        final boolean rotateSeamlessly = mDisplayRotation.isRotatingSeamlessly();
        final ScreenRotationAnimation screenRotationAnimation = rotateSeamlessly
                ? null : mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
        final Transaction transaction = getPendingTransaction();
        ScreenRotationAnimation screenRotationAnimation = rotateSeamlessly
                ? null : getRotationAnimation();
        // We need to update our screen size information to match the new rotation. If the rotation
        // has actually changed then this method will return true and, according to the comment at
        // the top of the method, the caller is obligated to call computeNewConfigurationLocked().
@@ -2386,6 +2388,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            super.removeImmediately();
            if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this);
            mPointerEventDispatcher.dispose();
            setRotationAnimation(null);
            mWmService.mAnimator.removeDisplayLocked(mDisplayId);
            mWindowingLayer.release();
            mOverlayLayer.release();
@@ -2550,6 +2553,17 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        return delta;
    }

    public void setRotationAnimation(ScreenRotationAnimation screenRotationAnimation) {
        if (mScreenRotationAnimation != null) {
            mScreenRotationAnimation.kill();
        }
        mScreenRotationAnimation = screenRotationAnimation;
    }

    public ScreenRotationAnimation getRotationAnimation() {
        return mScreenRotationAnimation;
    }

    private static void createRotationMatrix(int rotation, float displayWidth, float displayHeight,
            Matrix outMatrix) {
        // For rotations without Z-ordering we don't need the target rectangle's position.
@@ -2612,8 +2626,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        proto.write(DPI, mBaseDisplayDensity);
        mDisplayInfo.writeToProto(proto, DISPLAY_INFO);
        proto.write(ROTATION, getRotation());
        final ScreenRotationAnimation screenRotationAnimation =
                mWmService.mAnimator.getScreenRotationAnimationLocked(mDisplayId);
        final ScreenRotationAnimation screenRotationAnimation = getRotationAnimation();
        if (screenRotationAnimation != null) {
            screenRotationAnimation.writeToProto(proto, SCREEN_ROTATION_ANIMATION);
        }
@@ -2725,6 +2738,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            }
        }

        final ScreenRotationAnimation rotationAnimation = getRotationAnimation();
        if (rotationAnimation != null) {
            pw.print(subPrefix);
            pw.println("  mScreenRotationAnimation:");
            rotationAnimation.printTo("  ", pw);
        } else if (dumpAll) {
            pw.print(subPrefix);
            pw.println("  no ScreenRotationAnimation ");
        }

        pw.println();

        // Dump stack references
@@ -3734,7 +3757,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        convertCropForSurfaceFlinger(frame, rot, dw, dh);

        final ScreenRotationAnimation screenRotationAnimation =
                mWmService.mAnimator.getScreenRotationAnimationLocked(DEFAULT_DISPLAY);
                mWmService.mRoot.getDisplayContent(DEFAULT_DISPLAY).getRotationAnimation();
        final boolean inRotation = screenRotationAnimation != null &&
                screenRotationAnimation.isAnimating();
        if (DEBUG_SCREENSHOT && inRotation) Slog.v(TAG_WM, "Taking screenshot while rotating");
+1 −1
Original line number Diff line number Diff line
@@ -404,7 +404,7 @@ public class DisplayRotation {
            }

            final ScreenRotationAnimation screenRotationAnimation =
                    mService.mAnimator.getScreenRotationAnimationLocked(displayId);
                    mDisplayContent.getRotationAnimation();
            if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) {
                // Rotation updates cannot be performed while the previous rotation change animation
                // is still in progress. Skip this update. We will try updating again after the
+0 −34
Original line number Diff line number Diff line
@@ -107,14 +107,6 @@ public class WindowAnimator {
    }

    void removeDisplayLocked(final int displayId) {
        final DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId);
        if (displayAnimator != null) {
            if (displayAnimator.mScreenRotationAnimation != null) {
                displayAnimator.mScreenRotationAnimation.kill();
                displayAnimator.mScreenRotationAnimation = null;
            }
        }

        mDisplayContentsAnimators.delete(displayId);
    }

@@ -245,22 +237,14 @@ public class WindowAnimator {

    public void dumpLocked(PrintWriter pw, String prefix, boolean dumpAll) {
        final String subPrefix = "  " + prefix;
        final String subSubPrefix = "  " + subPrefix;

        for (int i = 0; i < mDisplayContentsAnimators.size(); i++) {
            pw.print(prefix); pw.print("DisplayContentsAnimator #");
                    pw.print(mDisplayContentsAnimators.keyAt(i));
                    pw.println(":");
            final DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.valueAt(i);
            final DisplayContent dc =
                    mService.mRoot.getDisplayContent(mDisplayContentsAnimators.keyAt(i));
            dc.dumpWindowAnimators(pw, subPrefix);
            if (displayAnimator.mScreenRotationAnimation != null) {
                pw.print(subPrefix); pw.println("mScreenRotationAnimation:");
                displayAnimator.mScreenRotationAnimation.printTo(subSubPrefix, pw);
            } else if (dumpAll) {
                pw.print(subPrefix); pw.println("no ScreenRotationAnimation ");
            }
            pw.println();
        }

@@ -294,23 +278,6 @@ public class WindowAnimator {
        return displayAnimator;
    }

    void setScreenRotationAnimationLocked(int displayId, ScreenRotationAnimation animation) {
        final DisplayContentsAnimator animator = getDisplayContentsAnimatorLocked(displayId);

        if (animator != null) {
            animator.mScreenRotationAnimation = animation;
        }
    }

    ScreenRotationAnimation getScreenRotationAnimationLocked(int displayId) {
        if (displayId < 0) {
            return null;
        }

        DisplayContentsAnimator animator = getDisplayContentsAnimatorLocked(displayId);
        return animator != null? animator.mScreenRotationAnimation : null;
    }

    void requestRemovalOfReplacedWindows(WindowState win) {
        mRemoveReplacedWindows = true;
    }
@@ -330,7 +297,6 @@ public class WindowAnimator {
    }

    private class DisplayContentsAnimator {
        ScreenRotationAnimation mScreenRotationAnimation = null;
    }

    boolean isAnimating() {
+6 −7
Original line number Diff line number Diff line
@@ -5380,7 +5380,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mExitAnimId = exitAnim;
        mEnterAnimId = enterAnim;
        ScreenRotationAnimation screenRotationAnimation =
                mAnimator.getScreenRotationAnimationLocked(mFrozenDisplayId);
                displayContent.getRotationAnimation();
        if (screenRotationAnimation != null) {
            screenRotationAnimation.kill();
        }
@@ -5392,8 +5392,7 @@ public class WindowManagerService extends IWindowManager.Stub
        screenRotationAnimation = new ScreenRotationAnimation(mContext, displayContent,
                displayContent.getDisplayRotation().isFixedToUserRotation(), isSecure,
                this);
        mAnimator.setScreenRotationAnimationLocked(mFrozenDisplayId,
                screenRotationAnimation);
        displayContent.setRotationAnimation(screenRotationAnimation);
    }

    void stopFreezingDisplayLocked() {
@@ -5444,8 +5443,8 @@ public class WindowManagerService extends IWindowManager.Stub

        boolean updateRotation = false;

        ScreenRotationAnimation screenRotationAnimation =
                mAnimator.getScreenRotationAnimationLocked(displayId);
        ScreenRotationAnimation screenRotationAnimation = displayContent == null ? null
                : displayContent.getRotationAnimation();
        if (screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) {
            if (DEBUG_ORIENTATION) Slog.i(TAG_WM, "**** Dismissing screen rotation animation");
            DisplayInfo displayInfo = displayContent.getDisplayInfo();
@@ -5460,13 +5459,13 @@ public class WindowManagerService extends IWindowManager.Stub
                mTransaction.apply();
            } else {
                screenRotationAnimation.kill();
                mAnimator.setScreenRotationAnimationLocked(displayId, null);
                displayContent.setRotationAnimation(null);
                updateRotation = true;
            }
        } else {
            if (screenRotationAnimation != null) {
                screenRotationAnimation.kill();
                mAnimator.setScreenRotationAnimationLocked(displayId, null);
                displayContent.setRotationAnimation(null);
            }
            updateRotation = true;
        }
Loading