Disallow caching of non-ninepatchable blur mask filtered round rects
From our simulation of the Camera App's behavior we get:
w/ caching (old):
Textures Created: 802
Texture Uploads: 802
w/o caching (new):
Textures Created: 6
Texture Uploads: 802
Bug: b/185828492, skia:11953
Change-Id: I7975033bf9f7d24ede6f1add23fe95cda3ba5669
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404202
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index ebf8b28..2b0c50b 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -288,9 +288,13 @@
#ifndef SK_DISABLE_MASKFILTERED_MASK_CACHING
// To prevent overloading the cache with entries during animations we limit the cache of masks
- // to cases where the matrix preserves axis alignment.
- bool useCache = !inverseFilled && viewMatrix.preservesAxisAlignment() &&
- shape.hasUnstyledKey() && as_MFB(maskFilter)->asABlur(nullptr);
+ // to cases where the matrix preserves axis alignment. Additionally, caching blurred masks
+ // for non-nine-patchable blurred round rects can also quickly flood the cache.
+ bool useCache = !inverseFilled &&
+ viewMatrix.preservesAxisAlignment() &&
+ shape.hasUnstyledKey() &&
+ as_MFB(maskFilter)->asABlur(nullptr) &&
+ !shape.asRRect(nullptr, nullptr, nullptr, nullptr);
if (useCache) {
SkIRect clippedMaskRect, unClippedMaskRect;