OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef GrResourceCache2_DEFINED | 9 #ifndef GrResourceCache2_DEFINED |
10 #define GrResourceCache2_DEFINED | 10 #define GrResourceCache2_DEFINED |
11 | 11 |
12 #include "GrGpuResource.h" | 12 #include "GrGpuResource.h" |
| 13 #include "GrGpuResourceCacheAccess.h" |
13 #include "GrResourceKey.h" | 14 #include "GrResourceKey.h" |
14 #include "SkRefCnt.h" | 15 #include "SkRefCnt.h" |
15 #include "SkTInternalLList.h" | 16 #include "SkTInternalLList.h" |
16 #include "SkTMultiMap.h" | 17 #include "SkTMultiMap.h" |
17 | 18 |
18 /** | 19 /** |
19 * Eventual replacement for GrResourceCache. Currently it simply holds a list | 20 * Eventual replacement for GrResourceCache. Currently it simply holds a list |
20 * of all GrGpuResource objects for a GrContext. It is used to invalidate all | 21 * of all GrGpuResource objects for a GrContext. It is used to invalidate all |
21 * the resources when necessary. | 22 * the resources when necessary. |
22 */ | 23 */ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 private: | 69 private: |
69 #ifdef SK_DEBUG | 70 #ifdef SK_DEBUG |
70 bool isInCache(const GrGpuResource* r) const { return fResources.isInList(r)
; } | 71 bool isInCache(const GrGpuResource* r) const { return fResources.isInList(r)
; } |
71 #endif | 72 #endif |
72 | 73 |
73 class AvailableForScratchUse; | 74 class AvailableForScratchUse; |
74 | 75 |
75 struct ScratchMapTraits { | 76 struct ScratchMapTraits { |
76 static const GrResourceKey& GetKey(const GrGpuResource& r) { | 77 static const GrResourceKey& GetKey(const GrGpuResource& r) { |
77 return r.getScratchKey(); | 78 return r.cacheAccess().getScratchKey(); |
78 } | 79 } |
79 | 80 |
80 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } | 81 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } |
81 }; | 82 }; |
82 typedef SkTMultiMap<GrGpuResource, GrResourceKey, ScratchMapTraits> ScratchM
ap; | 83 typedef SkTMultiMap<GrGpuResource, GrResourceKey, ScratchMapTraits> ScratchM
ap; |
83 | 84 |
84 struct ContentHashTraits { | 85 struct ContentHashTraits { |
85 static const GrResourceKey& GetKey(const GrGpuResource& r) { | 86 static const GrResourceKey& GetKey(const GrGpuResource& r) { |
86 return *r.getContentKey(); | 87 return *r.cacheAccess().getContentKey(); |
87 } | 88 } |
88 | 89 |
89 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } | 90 static uint32_t Hash(const GrResourceKey& key) { return key.getHash(); } |
90 }; | 91 }; |
91 typedef SkTDynamicHash<GrGpuResource, GrResourceKey, ContentHashTraits> Cont
entHash; | 92 typedef SkTDynamicHash<GrGpuResource, GrResourceKey, ContentHashTraits> Cont
entHash; |
92 | 93 |
93 int fCount; | 94 int fCount; |
94 SkTInternalLList<GrGpuResource> fResources; | 95 SkTInternalLList<GrGpuResource> fResources; |
95 // This map holds all resources that can be used as scratch resources. | 96 // This map holds all resources that can be used as scratch resources. |
96 ScratchMap fScratchMap; | 97 ScratchMap fScratchMap; |
97 // This holds all resources that have content keys. | 98 // This holds all resources that have content keys. |
98 ContentHash fContentHash; | 99 ContentHash fContentHash; |
99 }; | 100 }; |
100 | 101 |
101 #endif | 102 #endif |
OLD | NEW |