Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: src/gpu/GrResourceCache2.cpp

Issue 707493002: Use GrResourceCache2 to service content key lookups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move #ifdef SK_SUPPORT_GPU Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrResourceCache2.h ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache2.cpp
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index 6bc23a3096a5101027f4dfa2aae1c1a4ea6c8a1c..65e522aafbae13b310600138b4fee6f229bdce98 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -9,7 +9,6 @@
#include "GrResourceCache2.h"
#include "GrGpuResource.h"
-#include "SkRefCnt.h"
GrResourceCache2::~GrResourceCache2() {
this->releaseAll();
@@ -22,6 +21,8 @@ void GrResourceCache2::insertResource(GrGpuResource* resource) {
fResources.addToHead(resource);
++fCount;
if (!resource->getScratchKey().isNullScratch()) {
+ // TODO(bsalomon): Make this assertion possible.
+ // SkASSERT(!resource->isWrapped());
fScratchMap.insert(resource->getScratchKey(), resource);
}
}
@@ -32,6 +33,9 @@ void GrResourceCache2::removeResource(GrGpuResource* resource) {
if (!resource->getScratchKey().isNullScratch()) {
fScratchMap.remove(resource->getScratchKey(), resource);
}
+ if (const GrResourceKey* contentKey = resource->getContentKey()) {
+ fContentHash.remove(*contentKey);
+ }
--fCount;
}
@@ -43,6 +47,7 @@ void GrResourceCache2::abandonAll() {
SkASSERT(head != fResources.head());
}
SkASSERT(!fScratchMap.count());
+ SkASSERT(!fContentHash.count());
SkASSERT(!fCount);
}
@@ -89,3 +94,25 @@ GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrResourceKey&
}
return SkSafeRef(fScratchMap.find(scratchKey, AvailableForScratchUse(false)));
}
+
+void GrResourceCache2::willRemoveContentKey(const GrGpuResource* resource) {
+ SkASSERT(resource);
+ SkASSERT(resource->getContentKey());
+ SkDEBUGCODE(GrGpuResource* res = fContentHash.find(*resource->getContentKey()));
+ SkASSERT(res == resource);
+
+ fContentHash.remove(*resource->getContentKey());
+}
+
+bool GrResourceCache2::didAddContentKey(GrGpuResource* resource) {
+ SkASSERT(resource);
+ SkASSERT(resource->getContentKey());
+
+ GrGpuResource* res = fContentHash.find(*resource->getContentKey());
+ if (NULL != res) {
+ return false;
+ }
+
+ fContentHash.add(resource);
+ return true;
+}
« no previous file with comments | « src/gpu/GrResourceCache2.h ('k') | src/gpu/GrTexture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698