summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2023-07-25 09:34:11 -0400
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-28 01:50:55 +0000
commit1fd0268011d6f492078e5adcdebbe87dc7fafd29 (patch)
tree481eb9ce68b1bd2bdf4106d7f58e1b71638c01b3
parentc25d8b872b161e65899a1c85a016f2bee15c660e (diff)
downloadnative-1fd0268011d6f492078e5adcdebbe87dc7fafd29.tar.gz
RenderEngine: Limit the size of blur input to the display size
Some layers are extraordinarily large. In the particular case we've found, the layer does not have any content, but even if it did, content outside the display would not impact the blur. So limit the size of the rectangle we use for blurring, which in turn limits the size of the buffers we allocate to compute the blur. Use the canvas' existing clip, which has already been adjusted to the size of the display. Bug: 283427479 Bug: 292539958 Test: manual (logcat) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:763e450b7c5fa6ad1ed35cabb96fdb87467d00c2) Merged-In: I17e646cce0dca02f4e6a18032ecd1e9120fcf880 Change-Id: I17e646cce0dca02f4e6a18032ecd1e9120fcf880
-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 fda6ea189e..76ebf9d0c2 100644
--- a/libs/renderengine/skia/SkiaRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaRenderEngine.cpp
@@ -813,8 +813,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.