summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Todd Lee <leetodd@google.com> 2024-12-07 00:46:13 +0000
committer Todd Lee <leetodd@google.com> 2024-12-07 00:49:57 +0000
commitcf128faa5ca16c606d223ae4512934d0b98ffe5c (patch)
treea7bea1e95e2b06ee7d030f0fc9c6cc7fb8231963
parent05bb52996d3f174d7200aa11bd67919e2e0028b0 (diff)
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
-rw-r--r--packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java
index 0317d5f095a1..d0404ec02306 100644
--- a/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java
+++ b/packages/SystemUI/animation/lib/src/com/android/systemui/animation/ViewUIComponent.java
@@ -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();