Allow uniqueKey invalidation messages to reach the thread safe cache

With the addition of vertex data to the thread safe cache we also have
to handle the case where a given SkPath becomes inaccessible and
proactively invalidate the matching entry.

Bug: 1108408
Change-Id: Id11ce2aa10517f7c0772a253634d3c0d13e13460
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330261
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrThreadSafeCache.cpp b/src/gpu/GrThreadSafeCache.cpp
index 23c65b2..c33a9fc 100644
--- a/src/gpu/GrThreadSafeCache.cpp
+++ b/src/gpu/GrThreadSafeCache.cpp
@@ -118,6 +118,15 @@
     return {};
 }
 
+#ifdef SK_DEBUG
+bool GrThreadSafeCache::has(const GrUniqueKey& key) {
+    SkAutoSpinlock lock{fSpinLock};
+
+    Entry* tmp = fUniquelyKeyedEntryMap.find(key);
+    return SkToBool(tmp);
+}
+#endif
+
 GrSurfaceProxyView GrThreadSafeCache::find(const GrUniqueKey& key) {
     SkAutoSpinlock lock{fSpinLock};
 
@@ -245,6 +254,12 @@
     return sk_sp<VertexData>(new VertexData(vertices, vertexCount, vertexSize));
 }
 
+sk_sp<GrThreadSafeCache::VertexData> GrThreadSafeCache::MakeVertexData(sk_sp<GrGpuBuffer> buffer,
+                                                                       int vertexCount,
+                                                                       size_t vertexSize) {
+    return sk_sp<VertexData>(new VertexData(std::move(buffer), vertexCount, vertexSize));
+}
+
 std::tuple<sk_sp<GrThreadSafeCache::VertexData>, sk_sp<SkData>> GrThreadSafeCache::internalFindVerts(
                                                                          const GrUniqueKey& key) {
     Entry* tmp = fUniquelyKeyedEntryMap.find(key);