Index: src/gpu/GrResourceCache2.cpp |
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp |
index 84a8d48cbc057c5337ca1ddc7dfb137e73b73953..c1656593b5e3195f2197dbeb70d9e243d8209f79 100644 |
--- a/src/gpu/GrResourceCache2.cpp |
+++ b/src/gpu/GrResourceCache2.cpp |
@@ -14,7 +14,7 @@ |
#include "SkGr.h" |
#include "SkMessageBus.h" |
-DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage); |
+DECLARE_SKMESSAGEBUS_MESSAGE(GrContentKeyInvalidatedMessage); |
////////////////////////////////////////////////////////////////////////////// |
@@ -221,6 +221,13 @@ void GrResourceCache2::willRemoveScratchKey(const GrGpuResource* resource) { |
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource); |
} |
+void GrResourceCache2::willRemoveContentKey(const GrGpuResource* resource) { |
+ // Someone has a ref to this resource in order to invalidate it. When the ref count reaches |
+ // zero we will get a notifyPurgable() and figure out what to do with it. |
+ SkASSERT(resource->getContentKey().isValid()); |
+ fContentHash.remove(resource->getContentKey()); |
+} |
+ |
bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) { |
SkASSERT(!fPurging); |
SkASSERT(resource); |
@@ -406,6 +413,17 @@ void GrResourceCache2::purgeAllUnlocked() { |
this->validate(); |
} |
+void GrResourceCache2::processInvalidContentKeys( |
+ const SkTArray<GrContentKeyInvalidatedMessage>& msgs) { |
+ for (int i = 0; i < msgs.count(); ++i) { |
+ GrGpuResource* resource = this->findAndRefContentResource(msgs[i].key()); |
+ if (resource) { |
+ resource->cacheAccess().removeContentKey(); |
+ resource->unref(); // will call notifyPurgeable, if it is indeed now purgeable. |
+ } |
+ } |
+} |
+ |
#ifdef SK_DEBUG |
void GrResourceCache2::validate() const { |
// Reduce the frequency of validations for large resource counts. |