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

Commit ef21e0de authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Use task bounds as local animation frame in fixed rotation" into rvc-dev am: d5763c4c

Change-Id: If24916bbb212f50f10b0a0c14e72c78e2872d4b1
parents 18441899 d5763c4c
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -7677,12 +7677,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }
        win.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
        if (isFixedRotationTransforming()) {
            // This activity has been rotated but the display is still in old rotation. Because the
            // animation applies in display space coordinates, the rotated animation frames need to
            // be unrotated to avoid being cropped.
            unrotateAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
        }
    }

    void setPictureInPictureParams(PictureInPictureParams p) {
+5 −25
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.IBinder;
import android.view.DisplayInfo;
import android.view.Surface.Rotation;
@@ -28,7 +27,6 @@ import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;

import com.android.server.wm.utils.CoordinateTransforms;
import com.android.server.wm.utils.InsetUtils;

import java.io.PrintWriter;
import java.io.StringWriter;
@@ -47,22 +45,18 @@ public class SeamlessRotator {
    private final float[] mFloat9 = new float[9];
    private final int mOldRotation;
    private final int mNewRotation;
    private final int mRotationDelta;
    private final int mW;
    private final int mH;

    public SeamlessRotator(@Rotation int oldRotation, @Rotation int newRotation, DisplayInfo info) {
        mOldRotation = oldRotation;
        mNewRotation = newRotation;
        mRotationDelta = DisplayContent.deltaRotation(oldRotation, newRotation);

        final boolean flipped = info.rotation == ROTATION_90 || info.rotation == ROTATION_270;
        mH = flipped ? info.logicalWidth : info.logicalHeight;
        mW = flipped ? info.logicalHeight : info.logicalWidth;

        final int pH = flipped ? info.logicalWidth : info.logicalHeight;
        final int pW = flipped ? info.logicalHeight : info.logicalWidth;
        // Initialize transform matrix by physical size.
        final Matrix tmp = new Matrix();
        CoordinateTransforms.transformLogicalToPhysicalCoordinates(oldRotation, mW, mH, mTransform);
        CoordinateTransforms.transformPhysicalToLogicalCoordinates(newRotation, mW, mH, tmp);
        CoordinateTransforms.transformLogicalToPhysicalCoordinates(oldRotation, pW, pH, mTransform);
        CoordinateTransforms.transformPhysicalToLogicalCoordinates(newRotation, pW, pH, tmp);
        mTransform.postConcat(tmp);
    }

@@ -78,20 +72,6 @@ public class SeamlessRotator {
        transaction.setPosition(win.getSurfaceControl(), winSurfacePos[0], winSurfacePos[1]);
    }

    /** Rotates the frame from {@link #mNewRotation} to {@link #mOldRotation}. */
    void unrotateFrame(Rect inOut) {
        if (mRotationDelta == ROTATION_90) {
            inOut.set(inOut.top, mH - inOut.right, inOut.bottom, mH - inOut.left);
        } else if (mRotationDelta == ROTATION_270) {
            inOut.set(mW - inOut.bottom, inOut.left, mW - inOut.top, inOut.right);
        }
    }

    /** Rotates the insets from {@link #mNewRotation} to {@link #mOldRotation}. */
    void unrotateInsets(Rect inOut) {
        InsetUtils.rotateInsets(inOut, mRotationDelta);
    }

    /**
     * Returns the rotation of the display before it started rotating.
     *
+6 −1
Original line number Diff line number Diff line
@@ -5656,7 +5656,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // the status bar). In that case we need to use the final frame.
        if (inFreeformWindowingMode()) {
            outFrame.set(getFrameLw());
        } else if (isLetterboxedAppWindow()) {
        } else if (isLetterboxedAppWindow() || mToken.isFixedRotationTransforming()) {
            // 1. The letterbox surfaces should be animated with the owner activity, so use task
            //    bounds to include them.
            // 2. If the activity has fixed rotation transform, its windows are rotated in activity
            //    level. Because the animation runs before display is rotated, task bounds should
            //    represent the frames in display space coordinates.
            outFrame.set(getTask().getBounds());
        } else if (isDockedResizing()) {
            // If we are animating while docked resizing, then use the stack bounds as the
+4 −14
Original line number Diff line number Diff line
@@ -154,10 +154,13 @@ class WindowToken extends WindowContainer<WindowState> {
        void resetTransform() {
            for (int i = mRotatedContainers.size() - 1; i >= 0; i--) {
                final WindowContainer<?> c = mRotatedContainers.get(i);
                // If the window is detached (no parent), its surface may have been released.
                if (c.getParent() != null) {
                    mRotator.finish(c.getPendingTransaction(), c);
                }
            }
        }
    }

    /**
     * Compares two child window of this token and returns -1 if the first is lesser than the
@@ -509,19 +512,6 @@ class WindowToken extends WindowContainer<WindowState> {
        }
    }

    /**
     * Converts the rotated animation frames and insets back to display space for local animation.
     * It should only be called when {@link #hasFixedRotationTransform} is true.
     */
    void unrotateAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets,
            Rect outSurfaceInsets) {
        final SeamlessRotator rotator = mFixedRotationTransformState.mRotator;
        rotator.unrotateFrame(outFrame);
        rotator.unrotateInsets(outInsets);
        rotator.unrotateInsets(outStableInsets);
        rotator.unrotateInsets(outSurfaceInsets);
    }

    /**
     * Gives a chance to this {@link WindowToken} to adjust the {@link
     * android.view.WindowManager.LayoutParams} of its windows.
+9 −0
Original line number Diff line number Diff line
@@ -1016,6 +1016,15 @@ public class DisplayContentTests extends WindowTestsBase {
        assertTrue(mDisplayContent.getDisplayRotation().shouldRotateSeamlessly(
                ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */,
                false /* forceUpdate */));

        final Rect outFrame = new Rect();
        final Rect outInsets = new Rect();
        final Rect outStableInsets = new Rect();
        final Rect outSurfaceInsets = new Rect();
        mAppWindow.getAnimationFrames(outFrame, outInsets, outStableInsets, outSurfaceInsets);
        // The animation frames should not be rotated because display hasn't rotated.
        assertEquals(mDisplayContent.getBounds(), outFrame);

        // The display should keep current orientation and the rotated configuration should apply
        // to the activity.
        assertEquals(config.orientation, mDisplayContent.getConfiguration().orientation);