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

Commit 6f773fa6 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce unnecessary operations in perpareSurface" into udc-dev

parents ebba1751 3284bb4b
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ class Dimmer {
        boolean isVisible;
        SurfaceAnimator mSurfaceAnimator;

        // TODO(b/64816140): Remove after confirming dimmer layer always matches its container.
        final Rect mDimBounds = new Rect();

        /**
         * Determines whether the dim layer should animate before destroying.
         */
@@ -260,11 +263,16 @@ class Dimmer {
     * {@link WindowContainer#prepareSurfaces}. After calling this, the container should
     * chain {@link WindowContainer#prepareSurfaces} down to it's children to give them
     * a chance to request dims to continue.
     * @return Non-null dim bounds if the dimmer is showing.
     */
    void resetDimStates() {
        if (mDimState != null && !mDimState.mDontReset) {
    Rect resetDimStates() {
        if (mDimState == null) {
            return null;
        }
        if (!mDimState.mDontReset) {
            mDimState.mDimming = false;
        }
        return mDimState.mDimBounds;
    }

    void dontAnimateExit() {
@@ -275,13 +283,13 @@ class Dimmer {

    /**
     * Call after invoking {@link WindowContainer#prepareSurfaces} on children as
     * described in {@link #resetDimStates}.
     * described in {@link #resetDimStates}. The dim bounds returned by {@link #resetDimStates}
     * should be set before calling this method.
     *
     * @param t      A transaction in which to update the dims.
     * @param bounds The bounds at which to dim.
     * @return true if any Dims were updated.
     */
    boolean updateDims(SurfaceControl.Transaction t, Rect bounds) {
    boolean updateDims(SurfaceControl.Transaction t) {
        if (mDimState == null) {
            return false;
        }
@@ -297,6 +305,7 @@ class Dimmer {
            mDimState = null;
            return false;
        } else {
            final Rect bounds = mDimState.mDimBounds;
            // TODO: Once we use geometry from hierarchy this falls away.
            t.setPosition(mDimState.mDimLayer, bounds.left, bounds.top);
            t.setWindowCrop(mDimState.mDimLayer, bounds.width(), bounds.height());
+10 −7
Original line number Diff line number Diff line
@@ -767,7 +767,6 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
     */
    static class Dimmable extends DisplayArea<DisplayArea> {
        private final Dimmer mDimmer = new Dimmer(this);
        private final Rect mTmpDimBoundsRect = new Rect();

        Dimmable(WindowManagerService wms, Type type, String name, int featureId) {
            super(wms, type, name, featureId);
@@ -780,11 +779,13 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {

        @Override
        void prepareSurfaces() {
            mDimmer.resetDimStates();
            final Rect dimBounds = mDimmer.resetDimStates();
            super.prepareSurfaces();
            if (dimBounds != null) {
                // Bounds need to be relative, as the dim layer is a child.
            getBounds(mTmpDimBoundsRect);
            mTmpDimBoundsRect.offsetTo(0 /* newLeft */, 0 /* newTop */);
                getBounds(dimBounds);
                dimBounds.offsetTo(0 /* newLeft */, 0 /* newTop */);
            }

            // If SystemUI is dragging for recents, we want to reset the dim state so any dim layer
            // on the display level fades out.
@@ -792,11 +793,13 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
                mDimmer.resetDimStates();
            }

            if (mDimmer.updateDims(getSyncTransaction(), mTmpDimBoundsRect)) {
            if (dimBounds != null) {
                if (mDimmer.updateDims(getSyncTransaction())) {
                    scheduleAnimation();
                }
            }
        }
    }

    enum Type {
        /** Can only contain WindowTokens above the APPLICATION_LAYER. */
+12 −12
Original line number Diff line number Diff line
@@ -481,8 +481,6 @@ class Task extends TaskFragment {
    // to layout without loading all the task snapshots
    final PersistedTaskSnapshotData mLastTaskSnapshotData;

    private final Rect mTmpDimBoundsRect = new Rect();

    /** @see #setCanAffectSystemUiFlags */
    private boolean mCanAffectSystemUiFlags = true;

@@ -3254,22 +3252,24 @@ class Task extends TaskFragment {

    @Override
    void prepareSurfaces() {
        mDimmer.resetDimStates();
        final Rect dimBounds = mDimmer.resetDimStates();
        super.prepareSurfaces();
        getDimBounds(mTmpDimBoundsRect);

        if (dimBounds != null) {
            getDimBounds(dimBounds);

            // Bounds need to be relative, as the dim layer is a child.
            if (inFreeformWindowingMode()) {
                getBounds(mTmpRect);
            mTmpDimBoundsRect.offsetTo(mTmpDimBoundsRect.left - mTmpRect.left,
                    mTmpDimBoundsRect.top - mTmpRect.top);
                dimBounds.offsetTo(dimBounds.left - mTmpRect.left, dimBounds.top - mTmpRect.top);
            } else {
            mTmpDimBoundsRect.offsetTo(0, 0);
                dimBounds.offsetTo(0, 0);
            }
        }

        final SurfaceControl.Transaction t = getSyncTransaction();

        if (mDimmer.updateDims(t, mTmpDimBoundsRect)) {
        if (dimBounds != null && mDimmer.updateDims(t)) {
            scheduleAnimation();
        }

+7 −6
Original line number Diff line number Diff line
@@ -2923,16 +2923,17 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            return;
        }

        mDimmer.resetDimStates();
        final Rect dimBounds = mDimmer.resetDimStates();
        super.prepareSurfaces();

        if (dimBounds != null) {
            // Bounds need to be relative, as the dim layer is a child.
        final Rect dimBounds = getBounds();
            dimBounds.offsetTo(0 /* newLeft */, 0 /* newTop */);
        if (mDimmer.updateDims(getSyncTransaction(), dimBounds)) {
            if (mDimmer.updateDims(getSyncTransaction())) {
                scheduleAnimation();
            }
        }
    }

    @Override
    boolean fillsParent() {
+8 −7
Original line number Diff line number Diff line
@@ -5177,13 +5177,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    @Override
    void prepareSurfaces() {
        mIsDimming = false;
        if (mHasSurface) {
            applyDims();
            updateSurfacePositionNonOrganized();
            // Send information to SurfaceFlinger about the priority of the current window.
            updateFrameRateSelectionPriorityIfNeeded();
            updateScaleIfNeeded();

            mWinAnimator.prepareSurfaceLocked(getSyncTransaction());
        }
        super.prepareSurfaces();
    }

Loading