ccpr: Unregister path listeners when their cache entries are evicted
Bug: skia:8452
Change-Id: I5cf63c07481db38fc37e920e04ca140bad8966e4
Reviewed-on: https://skia-review.googlesource.com/c/163560
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index db85641..32008c2 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -187,12 +187,15 @@
}
void GrCCPathCache::evict(GrCCPathCacheEntry* entry) {
- bool isInCache = entry->fNext || (fLRU.tail() == entry);
- SkASSERT(isInCache == fLRU.isInList(entry));
- if (isInCache) {
- fLRU.remove(entry);
- fHashTable.remove(HashNode::GetKey(entry)); // Do this last, as it might delete the entry.
+ // Has the entry already been evicted? (SkPaths can post eviction messages from any thread.)
+ if (entry->shouldUnregisterFromPath()) {
+ SkASSERT(!fLRU.isInList(entry));
+ return;
}
+
+ entry->markShouldUnregisterFromPath();
+ fLRU.remove(entry);
+ fHashTable.remove(HashNode::GetKey(entry)); // Do this last, as it might delete the entry.
}
void GrCCPathCache::purgeAsNeeded() {