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

Unified Diff: src/gpu/GrResourceCache2.h

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/GrResourceCache.cpp ('k') | src/gpu/GrResourceCache2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache2.h
diff --git a/src/gpu/GrResourceCache2.h b/src/gpu/GrResourceCache2.h
index a365a5aec77f06c28551b19e3bfe8fc2b7bfb840..9424c40850a22bbf42c438e9544f45ceecf169cc 100644
--- a/src/gpu/GrResourceCache2.h
+++ b/src/gpu/GrResourceCache2.h
@@ -11,6 +11,7 @@
#include "GrGpuResource.h"
#include "GrResourceKey.h"
+#include "SkRefCnt.h"
#include "SkTInternalLList.h"
#include "SkTMultiMap.h"
@@ -28,6 +29,14 @@ public:
void removeResource(GrGpuResource*);
+ void willRemoveContentKey(const GrGpuResource*);
+
+ // This currently returns a bool and fails when an existing resource has a key that collides
+ // with the new content key. In the future it will null out the content key for the existing
+ // resource. The failure is a temporary measure taken because duties are split between two
+ // cache objects currently.
+ bool didAddContentKey(GrGpuResource*);
+
void abandonAll();
void releaseAll();
@@ -39,6 +48,24 @@ public:
kRequireNoPendingIO_ScratchFlag = 0x2,
};
GrGpuResource* findAndRefScratchResource(const GrResourceKey& scratchKey, uint32_t flags = 0);
+
+#ifdef SK_DEBUG
+ // This is not particularly fast and only used for validation, so debug only.
+ int countScratchEntriesForKey(const GrResourceKey& scratchKey) const {
+ SkASSERT(scratchKey.isScratch());
+ return fScratchMap.countForKey(scratchKey);
+ }
+#endif
+
+ GrGpuResource* findAndRefContentResource(const GrResourceKey& contentKey) {
+ SkASSERT(!contentKey.isScratch());
+ return SkSafeRef(fContentHash.find(contentKey));
+ }
+
+ bool hasContentKey(const GrResourceKey& contentKey) const {
+ SkASSERT(!contentKey.isScratch());
+ return SkToBool(fContentHash.find(contentKey));
+ }
private:
#ifdef SK_DEBUG
@@ -56,10 +83,21 @@ private:
};
typedef SkTMultiMap<GrGpuResource, GrResourceKey, ScratchMapTraits> ScratchMap;
+ struct ContentHashTraits {
+ static const GrResourceKey& GetKey(const GrGpuResource& r) {
+ return *r.getContentKey();
+ }
+
+ static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); }
+ };
+ typedef SkTDynamicHash<GrGpuResource, GrResourceKey, ContentHashTraits> ContentHash;
+
int fCount;
SkTInternalLList<GrGpuResource> fResources;
// This map holds all resources that can be used as scratch resources.
- ScratchMap fScratchMap;
+ ScratchMap fScratchMap;
+ // This holds all resources that have content keys.
+ ContentHash fContentHash;
};
#endif
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | src/gpu/GrResourceCache2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698