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

Commit 02360205 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "WM: Consolidate seamless rotation logic"

parents f6fbd166 ddd8074f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -298,9 +298,10 @@ message WindowStateProto {
    optional bool removed = 36;
    optional bool is_on_screen = 37;
    optional bool is_visible = 38;
    optional bool pending_forced_seamless_rotation = 39;
    optional int64 finished_forced_seamless_rotation_frame = 40;
    optional bool pending_seamless_rotation = 39;
    optional int64 finished_seamless_rotation_frame = 40;
    optional WindowFramesProto window_frames = 41;
    optional bool force_seamless_rotation = 42;
}

message IdentifierProto {
+0 −9
Original line number Diff line number Diff line
@@ -7862,15 +7862,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (!displayRotation.getDisplayPolicy().navigationBarCanMove()) {
            return false;
        }
        int delta = newRotation - oldRotation;
        if (delta < 0) delta += 4;
        // Likewise we don't rotate seamlessly for 180 degree rotations
        // in this case the surfaces never resize, and our logic to
        // revert the transformations on size change will fail. We could
        // fix this in the future with the "tagged" frames idea.
        if (delta == Surface.ROTATION_180) {
            return false;
        }

        final WindowState w = mTopFullscreenOpaqueWindowState;
        if (w != mFocusedWindow) {
+2 −6
Original line number Diff line number Diff line
@@ -1199,14 +1199,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }

        forAllWindows(w -> {
            w.forceSeamlesslyRotateIfAllowed(oldRotation, rotation);
            w.seamlesslyRotateIfAllowed(getPendingTransaction(), oldRotation, rotation,
                    rotateSeamlessly);
        }, true /* traverseTopToBottom */);

        // TODO(b/111504081): Consolidate seamless rotation logic.
        if (rotateSeamlessly) {
            seamlesslyRotate(getPendingTransaction(), oldRotation, rotation);
        }

        mService.mDisplayManagerInternal.performTraversal(getPendingTransaction());
        scheduleAnimation();

+11 −6
Original line number Diff line number Diff line
@@ -16,12 +16,14 @@

package com.android.server.wm;

import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import android.graphics.Matrix;
import android.view.DisplayInfo;
import android.view.Surface.Rotation;
import android.view.SurfaceControl.Transaction;

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

@@ -29,22 +31,21 @@ import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Helper class for forced seamless rotation.
 * Helper class for seamless rotation.
 *
 * Works by transforming the window token back into the old display rotation.
 *
 * Uses deferTransactionUntil instead of latching on the buffer size to allow for seamless 180
 * degree rotations.
 * TODO(b/111504081): Consolidate seamless rotation logic.
 */
public class ForcedSeamlessRotator {
public class SeamlessRotator {

    private final Matrix mTransform = new Matrix();
    private final float[] mFloat9 = new float[9];
    private final int mOldRotation;
    private final int mNewRotation;

    public ForcedSeamlessRotator(int oldRotation, int newRotation, DisplayInfo info) {
    public SeamlessRotator(int oldRotation, int newRotation, DisplayInfo info) {
        mOldRotation = oldRotation;
        mNewRotation = newRotation;

@@ -62,8 +63,8 @@ public class ForcedSeamlessRotator {
     * Applies a transform to the window token's surface that undoes the effect of the global
     * display rotation.
     */
    public void unrotate(WindowToken token) {
        token.getPendingTransaction().setMatrix(token.getSurfaceControl(), mTransform, mFloat9);
    public void unrotate(Transaction transaction, WindowToken token) {
        transaction.setMatrix(token.getSurfaceControl(), mTransform, mFloat9);
    }

    /**
@@ -94,6 +95,10 @@ public class ForcedSeamlessRotator {
            win.getPendingTransaction().deferTransactionUntil(win.mSurfaceControl,
                    win.mWinAnimator.mSurfaceController.mSurfaceControl.getHandle(),
                    win.getFrameNumber());
            win.getPendingTransaction().deferTransactionUntil(
                    win.mWinAnimator.mSurfaceController.mSurfaceControl,
                    win.mWinAnimator.mSurfaceController.mSurfaceControl.getHandle(),
                    win.getFrameNumber());
        }
    }

+1 −15
Original line number Diff line number Diff line
@@ -748,20 +748,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return candidate;
    }

    /**
     * Seamlessly rotates the container, by recomputing the location in the new
     * rotation, and rotating buffers until they are updated for the new rotation.
     *
     * @param t the transaction to perform the seamless rotation in
     * @param oldRotation the rotation we are rotating from
     * @param newRotation the rotation we are rotating to
     */
    void seamlesslyRotate(Transaction t, int oldRotation, int newRotation) {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            mChildren.get(i).seamlesslyRotate(t, oldRotation, newRotation);
        }
    }

    /**
     * Returns true if this container is opaque and fills all the space made available by its parent
     * container.
Loading