ccpr: Fix an overzealous assert in DDL
Bug: skia:
Change-Id: I307e826704ad28d8ef4810b321258d4ac57929a1
Reviewed-on: https://skia-review.googlesource.com/c/164718
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp
index e61503a..383275d 100644
--- a/src/gpu/ccpr/GrCCPathCache.cpp
+++ b/src/gpu/ccpr/GrCCPathCache.cpp
@@ -169,11 +169,12 @@
GrCCPathCache::GrCCPathCache()
: fInvalidatedEntriesInbox(next_path_cache_id()) {
- SkDEBUGCODE(fGraphicsThreadID = SkGetThreadID());
}
GrCCPathCache::~GrCCPathCache() {
- SkASSERT(SkGetThreadID() == fGraphicsThreadID);
+ // DDL threads never use the cache, in which case it doesn't matter what thread we
+ // clean up on.
+ SkASSERT(kIllegalThreadID == fGraphicsThreadID || SkGetThreadID() == fGraphicsThreadID);
fHashTable.reset(); // Must be cleared first; ~HashNode calls fLRU.remove() on us.
SkASSERT(fLRU.isEmpty()); // Ensure the hash table and LRU list were coherent.
@@ -181,6 +182,11 @@
sk_sp<GrCCPathCacheEntry> GrCCPathCache::find(const GrShape& shape, const MaskTransform& m,
CreateIfAbsent createIfAbsent) {
+#ifdef SK_DEBUG
+ if (kIllegalThreadID == fGraphicsThreadID) {
+ fGraphicsThreadID = SkGetThreadID();
+ }
+#endif
SkASSERT(SkGetThreadID() == fGraphicsThreadID);
if (!shape.hasUnstyledKey()) {
@@ -244,8 +250,6 @@
}
void GrCCPathCache::purgeAsNeeded() {
- SkASSERT(SkGetThreadID() == fGraphicsThreadID);
-
SkTArray<sk_sp<GrCCPathCacheEntry>> invalidatedEntries;
fInvalidatedEntriesInbox.poll(&invalidatedEntries);
for (const sk_sp<GrCCPathCacheEntry>& entry : invalidatedEntries) {