summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins <scroggo@google.com> 2023-07-26 14:44:22 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-26 14:44:22 +0000
commit9032c039f9ac8fe857f9f5330cf3bb5425b28aee (patch)
tree58e0fb675ba8efd997014a8e558ed32865201c66
parent33fe363b4abe8e5b11ffb9195323aad56107a4b1 (diff)
parenta09cddcb63bbb04f59deac653b3ddd1f16d38757 (diff)
Merge "RenderEngine: Limit the size of blur input to the display size" into main
-rw-r--r--libs/renderengine/skia/SkiaRenderEngine.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/libs/renderengine/skia/SkiaRenderEngine.cpp b/libs/renderengine/skia/SkiaRenderEngine.cpp
index 871d258ce7..01acf0e921 100644
--- a/libs/renderengine/skia/SkiaRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaRenderEngine.cpp
@@ -816,8 +816,20 @@ void SkiaRenderEngine::drawLayersInternal(
if (!blurInput) {
blurInput = activeSurface->makeImageSnapshot();
}
+
// rect to be blurred in the coordinate space of blurInput
- const auto blurRect = canvas->getTotalMatrix().mapRect(bounds.rect());
+ SkRect blurRect = canvas->getTotalMatrix().mapRect(bounds.rect());
+
+ // Some layers may be much bigger than the screen. If we used
+ // `blurRect` directly, this would allocate a large buffer with no
+ // benefit. Apply the clip, which already takes the display size
+ // into account. The clipped size will then be used to calculate the
+ // size of the buffer we will create for blurring.
+ if (!blurRect.intersect(SkRect::Make(canvas->getDeviceClipBounds()))) {
+ // This should not happen, but if it did, we would use the full
+ // sized layer, which should still be fine.
+ ALOGW("blur bounds does not intersect display clip!");
+ }
// if the clip needs to be applied then apply it now and make sure
// it is restored before we attempt to draw any shadows.