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

Commit 0bfae776 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Update sync rt applier for background blur" into rvc-dev am: 896f664c...

Merge "Update sync rt applier for background blur" into rvc-dev am: 896f664c am: 3b0029a2 am: 61b4dc53

Change-Id: I031116e03f5f2b15152985093d54bf6b15c72cad
parents bf7008ef 61b4dc53
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -282,10 +282,14 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            if (leash != null) {
                // TODO: use a better interpolation for fade.
                alpha = mFade ? ((float) inset / maxInset * 0.3f + 0.7f) : alpha;
                surfaceParams.add(new SurfaceParams(leash, side == ISIDE_FLOATING ? 1 : alpha,
                        mTmpMatrix, null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/,
                        side == ISIDE_FLOATING ? state.getSource(source.getType()).isVisible()
                                : inset != 0 /* visible */));
                SurfaceParams params = new SurfaceParams.Builder(leash)
                        .withAlpha(side == ISIDE_FLOATING ? 1 : alpha)
                        .withMatrix(mTmpMatrix)
                        .withVisibility(side == ISIDE_FLOATING
                                ? state.getSource(source.getType()).isVisible()
                                : inset != 0 /* visible */)
                        .build();
                surfaceParams.add(params);
            }
        }
    }
+24 −32
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ public class SyncRtSurfaceTransactionApplier {
    public static final int FLAG_WINDOW_CROP = 1 << 2;
    public static final int FLAG_LAYER = 1 << 3;
    public static final int FLAG_CORNER_RADIUS = 1 << 4;
    public static final int FLAG_VISIBILITY = 1 << 5;
    public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5;
    public static final int FLAG_VISIBILITY = 1 << 6;

    private SurfaceControl mTargetSc;
    private final ViewRootImpl mTargetViewRootImpl;
@@ -108,6 +109,9 @@ public class SyncRtSurfaceTransactionApplier {
        if ((params.flags & FLAG_CORNER_RADIUS) != 0) {
            t.setCornerRadius(params.surface, params.cornerRadius);
        }
        if ((params.flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
            t.setBackgroundBlurRadius(params.surface, params.backgroundBlurRadius);
        }
        if ((params.flags & FLAG_VISIBILITY) != 0) {
            if (params.visible) {
                t.show(params.surface);
@@ -153,6 +157,7 @@ public class SyncRtSurfaceTransactionApplier {
            int flags;
            float alpha;
            float cornerRadius;
            int backgroundBlurRadius;
            Matrix matrix;
            Rect windowCrop;
            int layer;
@@ -215,6 +220,16 @@ public class SyncRtSurfaceTransactionApplier {
                return this;
            }

            /**
             * @param radius the Radius for blur to apply to the background surfaces.
             * @return this Builder
             */
            public Builder withBackgroundBlur(int radius) {
                this.backgroundBlurRadius = radius;
                flags |= FLAG_BACKGROUND_BLUR_RADIUS;
                return this;
            }

            /**
             * @param visible The visibility to apply to the surface.
             * @return this Builder
@@ -230,12 +245,13 @@ public class SyncRtSurfaceTransactionApplier {
             */
            public SurfaceParams build() {
                return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer,
                        cornerRadius, visible);
                        cornerRadius, backgroundBlurRadius, visible);
            }
        }

        private SurfaceParams(SurfaceControl surface, int params, float alpha, Matrix matrix,
                Rect windowCrop, int layer, float cornerRadius, boolean visible) {
                Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius,
                boolean visible) {
            this.flags = params;
            this.surface = surface;
            this.alpha = alpha;
@@ -243,34 +259,7 @@ public class SyncRtSurfaceTransactionApplier {
            this.windowCrop = new Rect(windowCrop);
            this.layer = layer;
            this.cornerRadius = cornerRadius;
            this.visible = visible;
        }


        /**
         * Constructs surface parameters to be applied when the current view state gets pushed to
         * RenderThread.
         *
         * @param surface The surface to modify.
         * @param alpha Alpha to apply.
         * @param matrix Matrix to apply.
         * @param windowCrop Crop to apply.
         * @param layer The layer to apply.
         * @param cornerRadius The corner radius to apply.
         * @param visible The visibility to apply.
         *
         * @deprecated Use {@link SurfaceParams.Builder} to create an instance.
         */
        @Deprecated
        public SurfaceParams(SurfaceControl surface, float alpha, Matrix matrix,
                Rect windowCrop, int layer, float cornerRadius, boolean visible) {
            this.flags = FLAG_ALL;
            this.surface = surface;
            this.alpha = alpha;
            this.matrix = new Matrix(matrix);
            this.windowCrop = windowCrop != null ? new Rect(windowCrop) : null;
            this.layer = layer;
            this.cornerRadius = cornerRadius;
            this.backgroundBlurRadius = backgroundBlurRadius;
            this.visible = visible;
        }

@@ -283,7 +272,10 @@ public class SyncRtSurfaceTransactionApplier {
        public final float alpha;

        @VisibleForTesting
        final float cornerRadius;
        public final float cornerRadius;

        @VisibleForTesting
        public final int backgroundBlurRadius;

        @VisibleForTesting
        public final Matrix matrix;
+14 −1
Original line number Diff line number Diff line
@@ -17,11 +17,24 @@
package com.android.systemui.shared.system;

import android.view.SurfaceControl;
import android.view.View;
import android.view.ViewRootImpl;

public class SurfaceControlCompat {
    SurfaceControl mSurfaceControl;
    final SurfaceControl mSurfaceControl;

    public SurfaceControlCompat(SurfaceControl surfaceControl) {
        mSurfaceControl = surfaceControl;
    }

    public SurfaceControlCompat(View v) {
        ViewRootImpl viewRootImpl = v.getViewRootImpl();
        mSurfaceControl = viewRootImpl != null
                ? viewRootImpl.getSurfaceControl()
                : null;
    }

    public boolean isValid() {
        return mSurfaceControl != null && mSurfaceControl.isValid();
    }
}
+143 −7
Original line number Diff line number Diff line
@@ -38,6 +38,15 @@ import java.util.function.Consumer;
 */
public class SyncRtSurfaceTransactionApplierCompat {

    public static final int FLAG_ALL = 0xffffffff;
    public static final int FLAG_ALPHA = 1;
    public static final int FLAG_MATRIX = 1 << 1;
    public static final int FLAG_WINDOW_CROP = 1 << 2;
    public static final int FLAG_LAYER = 1 << 3;
    public static final int FLAG_CORNER_RADIUS = 1 << 4;
    public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5;
    public static final int FLAG_VISIBILITY = 1 << 6;

    private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0;

    private final SurfaceControl mBarrierSurfaceControl;
@@ -143,14 +152,31 @@ public class SyncRtSurfaceTransactionApplierCompat {

    public static void applyParams(TransactionCompat t,
            SyncRtSurfaceTransactionApplierCompat.SurfaceParams params) {
        if ((params.flags & FLAG_MATRIX) != 0) {
            t.setMatrix(params.surface, params.matrix);
        if (params.windowCrop != null) {
        }
        if ((params.flags & FLAG_WINDOW_CROP) != 0) {
            t.setWindowCrop(params.surface, params.windowCrop);
        }
        if ((params.flags & FLAG_ALPHA) != 0) {
            t.setAlpha(params.surface, params.alpha);
        }
        if ((params.flags & FLAG_LAYER) != 0) {
            t.setLayer(params.surface, params.layer);
        }
        if ((params.flags & FLAG_CORNER_RADIUS) != 0) {
            t.setCornerRadius(params.surface, params.cornerRadius);
        }
        if ((params.flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
            t.setBackgroundBlurRadius(params.surface, params.backgroundBlurRadius);
        }
        if ((params.flags & FLAG_VISIBILITY) != 0) {
            if (params.visible) {
                t.show(params.surface);
            } else {
                t.hide(params.surface);
            }
        }
    }

    /**
@@ -183,6 +209,102 @@ public class SyncRtSurfaceTransactionApplierCompat {
    }

    public static class SurfaceParams {
        public static class Builder {
            final SurfaceControlCompat surface;
            int flags;
            float alpha;
            float cornerRadius;
            int backgroundBlurRadius;
            Matrix matrix;
            Rect windowCrop;
            int layer;
            boolean visible;

            /**
             * @param surface The surface to modify.
             */
            public Builder(SurfaceControlCompat surface) {
                this.surface = surface;
            }

            /**
             * @param alpha The alpha value to apply to the surface.
             * @return this Builder
             */
            public Builder withAlpha(float alpha) {
                this.alpha = alpha;
                flags |= FLAG_ALPHA;
                return this;
            }

            /**
             * @param matrix The matrix to apply to the surface.
             * @return this Builder
             */
            public Builder withMatrix(Matrix matrix) {
                this.matrix = matrix;
                flags |= FLAG_MATRIX;
                return this;
            }

            /**
             * @param windowCrop The window crop to apply to the surface.
             * @return this Builder
             */
            public Builder withWindowCrop(Rect windowCrop) {
                this.windowCrop = windowCrop;
                flags |= FLAG_WINDOW_CROP;
                return this;
            }

            /**
             * @param layer The layer to assign the surface.
             * @return this Builder
             */
            public Builder withLayer(int layer) {
                this.layer = layer;
                flags |= FLAG_LAYER;
                return this;
            }

            /**
             * @param radius the Radius for rounded corners to apply to the surface.
             * @return this Builder
             */
            public Builder withCornerRadius(float radius) {
                this.cornerRadius = radius;
                flags |= FLAG_CORNER_RADIUS;
                return this;
            }

            /**
             * @param radius the Radius for blur to apply to the background surfaces.
             * @return this Builder
             */
            public Builder withBackgroundBlur(int radius) {
                this.backgroundBlurRadius = radius;
                flags |= FLAG_BACKGROUND_BLUR_RADIUS;
                return this;
            }

            /**
             * @param visible The visibility to apply to the surface.
             * @return this Builder
             */
            public Builder withVisibility(boolean visible) {
                this.visible = visible;
                flags |= FLAG_VISIBILITY;
                return this;
            }

            /**
             * @return a new SurfaceParams instance
             */
            public SurfaceParams build() {
                return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer,
                        cornerRadius, backgroundBlurRadius, visible);
            }
        }

        /**
         * Constructs surface parameters to be applied when the current view state gets pushed to
@@ -195,19 +317,33 @@ public class SyncRtSurfaceTransactionApplierCompat {
         */
        public SurfaceParams(SurfaceControlCompat surface, float alpha, Matrix matrix,
                Rect windowCrop, int layer, float cornerRadius) {
            this(surface, FLAG_ALL & ~(FLAG_VISIBILITY | FLAG_BACKGROUND_BLUR_RADIUS), alpha,
                    matrix, windowCrop, layer, cornerRadius, 0 /* backgroundBlurRadius */, true);
        }

        private SurfaceParams(SurfaceControlCompat surface, int flags, float alpha, Matrix matrix,
                Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius,
                boolean visible) {
            this.flags = flags;
            this.surface = surface;
            this.alpha = alpha;
            this.matrix = new Matrix(matrix);
            this.windowCrop = windowCrop != null ? new Rect(windowCrop) : null;
            this.layer = layer;
            this.cornerRadius = cornerRadius;
            this.backgroundBlurRadius = backgroundBlurRadius;
            this.visible = visible;
        }

        private final int flags;

        public final SurfaceControlCompat surface;
        public final float alpha;
        final float cornerRadius;
        public final float cornerRadius;
        public final int backgroundBlurRadius;
        public final Matrix matrix;
        public final Rect windowCrop;
        public final int layer;
        public final boolean visible;
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -87,6 +87,12 @@ public class TransactionCompat {
        return this;
    }

    public TransactionCompat setBackgroundBlurRadius(SurfaceControlCompat surfaceControl,
            int radius) {
        mTransaction.setBackgroundBlurRadius(surfaceControl.mSurfaceControl, radius);
        return this;
    }

    public TransactionCompat deferTransactionUntil(SurfaceControlCompat surfaceControl,
            SurfaceControl barrier, long frameNumber) {
        mTransaction.deferTransactionUntil(surfaceControl.mSurfaceControl, barrier,
Loading