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

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

Merge "Window Manager Flag Migration (9/n)"

parents 56f10484 969c6085
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -257,10 +257,6 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        for (int i = items.size() - 1; i >= 0; i--) {
            final InsetsSourceControl control = items.valueAt(i);
            final InsetsSource source = mInitialInsetsState.getSource(control.getType());
            if (control == null) {
                // TODO: remove this check when we ensure the elements will not be null.
                continue;
            }
            final SurfaceControl leash = control.getLeash();

            mTmpMatrix.setTranslate(control.getSurfacePosition().x, control.getSurfacePosition().y);
+5 −3
Original line number Diff line number Diff line
@@ -375,8 +375,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }
        cancelExistingControllers(types);

        final ArraySet<Integer> internalTypes = mState.toInternalType(types);
        final SparseArray<InsetsSourceConsumer> consumers = new SparseArray<>();
        final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
        final SparseArray<InsetsSourceControl> controls = new SparseArray<>();

        Pair<Integer, Boolean> typesReadyPair = collectSourceControls(
@@ -441,7 +440,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                }
                typesReady |= InsetsState.toPublicType(consumer.getType());
            }
            controls.put(consumer.getType(), consumer.getControl());
            final InsetsSourceControl control = consumer.getControl();
            if (control != null) {
                controls.put(consumer.getType(), control);
            }
        }
        return new Pair<>(typesReady, isReady);
    }
+17 −11
Original line number Diff line number Diff line
@@ -676,6 +676,22 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Set the initial visibility for the SurfaceControl.
         *
         * @param hidden Whether the Surface is initially HIDDEN.
         * @hide
         */
        @NonNull
        public Builder setHidden(boolean hidden) {
            if (hidden) {
                mFlags |= HIDDEN;
            } else {
                mFlags &= ~HIDDEN;
            }
            return this;
        }

        /**
         * Set a parent surface for our new SurfaceControl.
         *
@@ -789,8 +805,7 @@ public final class SurfaceControl implements Parcelable {
     * @param name     The surface name, must not be null.
     * @param w        The surface initial width.
     * @param h        The surface initial height.
     * @param flags    The surface creation flags.  Should always include {@link #HIDDEN}
     *                 in the creation flags.
     * @param flags    The surface creation flags.
     * @param metadata Initial metadata.
     * @throws throws OutOfResourcesException If the SurfaceControl cannot be created.
     */
@@ -801,15 +816,6 @@ public final class SurfaceControl implements Parcelable {
            throw new IllegalArgumentException("name must not be null");
        }

        if ((flags & SurfaceControl.HIDDEN) == 0) {
            Log.w(TAG, "Surfaces should always be created with the HIDDEN flag set "
                    + "to ensure that they are not made visible prematurely before "
                    + "all of the surface's properties have been configured.  "
                    + "Set the other properties and make the surface visible within "
                    + "a transaction.  New surface name: " + name,
                    new Throwable());
        }

        mName = name;
        mWidth = w;
        mHeight = h;
+42 −4
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ class InsetsSourceProvider {
     */
    private boolean mServerVisible;

    private boolean mSeamlessRotating;
    private long mFinishSeamlessRotateFrameNumber = -1;

    private final boolean mControllable;

    InsetsSourceProvider(InsetsSource source, InsetsStateController stateController,
@@ -170,7 +173,9 @@ class InsetsSourceProvider {
        updateSourceFrame();
        if (mControl != null) {
            final Rect frame = mWin.getWindowFrames().mFrame;
            if (mControl.setSurfacePosition(frame.left, frame.top)) {
            if (mControl.setSurfacePosition(frame.left, frame.top) && mControlTarget != null) {
                // The leash has been stale, we need to create a new one for the client.
                updateControlForTarget(mControlTarget, true /* force */);
                mStateController.notifyControlChanged(mControlTarget);
            }
        }
@@ -189,6 +194,11 @@ class InsetsSourceProvider {
    }

    void updateControlForTarget(@Nullable InsetsControlTarget target, boolean force) {
        if (mSeamlessRotating) {
            // We are un-rotating the window against the display rotation. We don't want the target
            // to control the window for now.
            return;
        }
        if (mWin == null) {
            mControlTarget = target;
            return;
@@ -203,13 +213,41 @@ class InsetsSourceProvider {
        }
        mAdapter = new ControlAdapter();
        setClientVisible(InsetsState.getDefaultVisibility(mSource.getType()));
        mWin.startAnimation(mDisplayContent.getPendingTransaction(), mAdapter,
                !mClientVisible /* hidden */);
        final Transaction t = mDisplayContent.getPendingTransaction();
        mWin.startAnimation(t, mAdapter, !mClientVisible /* hidden */);
        final SurfaceControl leash = mAdapter.mCapturedLeash;
        final long frameNumber = mFinishSeamlessRotateFrameNumber;
        mFinishSeamlessRotateFrameNumber = -1;
        if (frameNumber >= 0 && mWin.mHasSurface && leash != null) {
            // We just finished the seamless rotation. We don't want to change the position or the
            // window crop of the surface controls (including the leash) until the client finishes
            // drawing the new frame of the new orientation. Although we cannot defer the reparent
            // operation, it is fine, because reparent won't cause any visual effect.
            final SurfaceControl barrier = mWin.mWinAnimator.mSurfaceController.mSurfaceControl;
            t.deferTransactionUntil(mWin.getSurfaceControl(), barrier, frameNumber);
            t.deferTransactionUntil(leash, barrier, frameNumber);
        }
        mControlTarget = target;
        mControl = new InsetsSourceControl(mSource.getType(), mAdapter.mCapturedLeash,
        mControl = new InsetsSourceControl(mSource.getType(), leash,
                new Point(mWin.getWindowFrames().mFrame.left, mWin.getWindowFrames().mFrame.top));
    }

    void startSeamlessRotation() {
        if (!mSeamlessRotating) {
            mSeamlessRotating = true;

            // This will revoke the leash and clear the control target.
            mWin.cancelAnimation();
        }
    }

    void finishSeamlessRotation(boolean timeout) {
        if (mSeamlessRotating) {
            mSeamlessRotating = false;
            mFinishSeamlessRotateFrameNumber = timeout ? -1 : mWin.getFrameNumber();
        }
    }

    boolean onInsetsModified(InsetsControlTarget caller, InsetsSource modifiedSource) {
        if (mControlTarget != caller || modifiedSource.isVisible() == mClientVisible) {
            return false;
+2 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ class InsetsStateController {
        if (target == previous) {
            return;
        }
        final InsetsSourceProvider provider = getSourceProvider(type);
        final InsetsSourceProvider provider = mProviders.get(type);
        if (provider == null) {
            return;
        }
@@ -211,6 +211,7 @@ class InsetsStateController {
            return;
        }
        provider.updateControlForTarget(target, false /* force */);
        target = provider.getControlTarget();
        if (previous != null) {
            removeFromControlMaps(previous, type, false /* fake */);
            mPendingControlChanged.add(previous);
Loading