summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins III <scroggo@google.com> 2021-05-12 10:45:08 -0400
committer Leon Scroggins III <scroggo@google.com> 2021-05-12 17:17:58 -0400
commit63e8695e7889a354813b5e2f00104045adc2f072 (patch)
tree67163a067f9d48551e04f2fb69fd382dd54831d9
parent50f6e980f469f08bc5c860e609bcb2afb1f97ee5 (diff)
Fix shadow corner radius during PIP size change
Bug: 187441996 Test: manual Test: go/wm-smoke Test: libcompositionengine_test Test: TODO The now-deleted code was intended to remove rounding when part of the content is offscreen, but it removes rounding on corners that are entirely on screen. Remove the code, which fixes a bug seen when expanding a PIP. If the content is partially offscreen, our drawing code will handle this correctly. In addition, if the bounds is an SkRect and there is a roundRectClip, draw the rounded version. Change-Id: I6ee07321c04474f96a572015f301e01441ca5afc
-rw-r--r--libs/renderengine/skia/SkiaGLRenderEngine.cpp11
-rw-r--r--services/surfaceflinger/Layer.cpp17
2 files changed, 10 insertions, 18 deletions
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index 6d2af4a77f..95b503f7f7 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -898,7 +898,16 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
if (layer->shadow.length > 0) {
// This would require a new parameter/flag to SkShadowUtils::DrawShadow
LOG_ALWAYS_FATAL_IF(layer->disableBlending, "Cannot disableBlending with a shadow");
- drawShadow(canvas, bounds, layer->shadow);
+
+ // Technically, if bounds is a rect and roundRectClip is not empty,
+ // it means that the bounds and roundedCornersCrop were different
+ // enough that we should intersect them to find the proper shadow.
+ // In practice, this often happens when the two rectangles appear to
+ // not match due to rounding errors. Draw the rounded version, which
+ // looks more like the intent.
+ const auto& rrect =
+ bounds.isRect() && !roundRectClip.isEmpty() ? roundRectClip : bounds;
+ drawShadow(canvas, rrect, layer->shadow);
continue;
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index def271196d..a0b7550ad8 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -623,23 +623,6 @@ std::optional<compositionengine::LayerFE::LayerSettings> Layer::prepareShadowCli
return {};
}
- float casterCornerRadius = shadowLayer.geometry.roundedCornersRadius;
- const FloatRect& cornerRadiusCropRect = shadowLayer.geometry.roundedCornersCrop;
- const FloatRect& casterRect = shadowLayer.geometry.boundaries;
-
- // crop used to set the corner radius may be larger than the content rect. Adjust the corner
- // radius accordingly.
- if (casterCornerRadius > 0.f) {
- float cropRectOffset = std::max(std::abs(cornerRadiusCropRect.top - casterRect.top),
- std::abs(cornerRadiusCropRect.left - casterRect.left));
- if (cropRectOffset > casterCornerRadius) {
- casterCornerRadius = 0;
- } else {
- casterCornerRadius -= cropRectOffset;
- }
- shadowLayer.geometry.roundedCornersRadius = casterCornerRadius;
- }
-
return shadowLayer;
}