summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins III <scroggo@google.com> 2022-03-18 10:02:49 -0400
committer Leon Scroggins III <scroggo@google.com> 2022-03-18 16:29:12 -0400
commita49deeee4af3461e7baf40260fe40050500be70f (patch)
tree6a67e21172d26a00caacf5de0c257bd7d1c3ace4
parentbce590e3562105618aecead911987f7176f4aa4d (diff)
ScreenDecorHwcLayer: better debugging for the transparent region
When DEBUG_COLOR is set, the ScreenDecorHwcLayer becomes a full color buffer (instead of A8) and draws green for the cutouts and transparent green for the transparent region. But the old method calculated the transparent region during every draw call, which doesn't match how it happens when we actually set the transparent region. Instead, do the following: Always call requestTransparentRegion in onAttachedToWindow. This means that gatherTransparentRegion will be called to calculate the transparent region. Do *not* call calculateTransparentRect in onDraw, which would update the rect. The final result is that onDraw will draw using the rect computed for passing to native. When DEBUG_COLOR is set, still compute the rect in gatherTransparentRegion, but set the region to empty. The method is supposed to remove parts of the Region that are not transparent, and with the debug drawing, it essentially draws everywhere. Only call setDisplayDecoration when !DEBUG_COLOR. With DEBUG_COLOR set, we cannot take advantage of DISPLAY_DECORATION layers anyway. Bug: 225212638 Test: debug.screenshot_rounded_corners Change-Id: Ic91d3b22e5c5d768cc1c6f1f8baefe1546ac2006
-rw-r--r--packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt16
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt b/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt
index 498e71546bed..1094622a8ef0 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorHwcLayer.kt
@@ -101,10 +101,10 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
override fun onAttachedToWindow() {
super.onAttachedToWindow()
+ parent.requestTransparentRegion(this)
if (!DEBUG_COLOR) {
- parent.requestTransparentRegion(this)
+ viewRootImpl.setDisplayDecoration(true)
}
- viewRootImpl.setDisplayDecoration(true)
if (useInvertedAlphaColor) {
paint.set(clearPaint)
@@ -128,7 +128,6 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
super.onDraw(canvas)
debugTransparentRegionPaint?.let {
- calculateTransparentRect()
canvas.drawRect(transparentRect, it)
}
}
@@ -136,7 +135,16 @@ class ScreenDecorHwcLayer(context: Context, displayDecorationSupport: DisplayDec
override fun gatherTransparentRegion(region: Region?): Boolean {
region?.let {
calculateTransparentRect()
- region.op(transparentRect, Region.Op.INTERSECT)
+ if (DEBUG_COLOR) {
+ // Since we're going to draw a rectangle where the layer would
+ // normally be transparent, treat the transparent region as
+ // empty. We still want this method to be called, though, so
+ // that it calculates the transparent rect at the right time
+ // to match !DEBUG_COLOR.
+ region.setEmpty()
+ } else {
+ region.op(transparentRect, Region.Op.INTERSECT)
+ }
}
// Always return false - views underneath this should always be visible.
return false