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

Commit cf128faa authored by Todd Lee's avatar Todd Lee
Browse files

Ensure that views retain clipping in origin transitions

Bug: b/382769622
Test: manual check to ensure visual UX
Flag: NONE exempt trivial
Change-Id: I486d2a90e66a7e4605adcc52f6b1e624fecf9c20
parent 05bb5299
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -18,8 +18,11 @@ package com.android.systemui.animation;

import android.annotation.Nullable;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.util.Log;
import android.view.Surface;
@@ -44,6 +47,9 @@ import java.util.concurrent.Executor;
public class ViewUIComponent implements UIComponent {
    private static final String TAG = "ViewUIComponent";
    private static final boolean DEBUG = Build.IS_USERDEBUG || Log.isLoggable(TAG, Log.DEBUG);
    private final Path mClippingPath = new Path();
    private final Outline mClippingOutline = new Outline();

    private final OnDrawListener mOnDrawListener = this::postDraw;
    private final View mView;

@@ -182,6 +188,17 @@ public class ViewUIComponent implements UIComponent {
            canvas.scale(
                    (float) renderBounds.width() / realBounds.width(),
                    (float) renderBounds.height() / realBounds.height());

            if (mView.getClipToOutline()) {
                mView.getOutlineProvider().getOutline(mView, mClippingOutline);
                mClippingPath.reset();
                RectF rect = new RectF(0, 0, mView.getWidth(), mView.getHeight());
                final float cornerRadius = mClippingOutline.getRadius();
                mClippingPath.addRoundRect(rect, cornerRadius, cornerRadius, Path.Direction.CW);
                mClippingPath.close();
                canvas.clipPath(mClippingPath);
            }

            canvas.saveLayerAlpha(null, (int) (255 * mView.getAlpha()));
            mView.draw(canvas);
            canvas.restore();