Avoid unbounded listener growth on SkImage_Lazy when textures are purged
Generalizes the system used on SkPathRef where a GrTexture's key
destructor signals that a listener on the image can be removed via
the unique key custom data.
Removes texturesAreCacheable() from SkImageGenerator. This was used to
prevent unbounded growth in a narrow situation related to
GrBackendTextureImageGenerator.
Change-Id: I3c605da099acfac94751e793331e356a0979d359
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274038
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index d51d3eb..d269bcf 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -87,7 +87,7 @@
return reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(this) + sizeof(Key));
}
-void GrCCPathCache::Key::onChange() {
+void GrCCPathCache::Key::changed() {
// Our key's corresponding path was invalidated. Post a thread-safe eviction message.
SkMessageBus<sk_sp<Key>>::Post(sk_ref_sp(this));
}
@@ -258,7 +258,7 @@
}
SkASSERT(*entry->fCacheKey == key);
SkASSERT(!entry->hasBeenEvicted());
- entry->fCacheKey->markShouldUnregisterFromPath(); // Unregister the path listener.
+ entry->fCacheKey->markShouldDeregister(); // Unregister the path listener.
entry->releaseCachedAtlas(this);
fLRU.remove(entry);
fHashTable.remove(key);
@@ -325,7 +325,7 @@
SkTArray<sk_sp<Key>> invalidatedKeys;
fInvalidatedKeysInbox.poll(&invalidatedKeys);
for (const sk_sp<Key>& key : invalidatedKeys) {
- bool isInCache = !key->shouldUnregisterFromPath(); // Gets set upon exiting the cache.
+ bool isInCache = !key->shouldDeregister(); // Gets set upon exiting the cache.
if (isInCache) {
this->evict(*key);
}