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 GrResourceCache_DEFINED | 9 #ifndef GrResourceCache_DEFINED |
10 #define GrResourceCache_DEFINED | 10 #define GrResourceCache_DEFINED |
11 | 11 |
12 #include "GrGpuResource.h" | 12 #include "GrGpuResource.h" |
13 #include "GrGpuResourceCacheAccess.h" | 13 #include "GrGpuResourceCacheAccess.h" |
14 #include "GrGpuResourcePriv.h" | 14 #include "GrGpuResourcePriv.h" |
15 #include "GrResourceKey.h" | 15 #include "GrResourceKey.h" |
16 #include "SkMessageBus.h" | 16 #include "SkMessageBus.h" |
17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
18 #include "SkTArray.h" | 18 #include "SkTArray.h" |
19 #include "SkTDPQueue.h" | 19 #include "SkTDPQueue.h" |
20 #include "SkTInternalLList.h" | 20 #include "SkTInternalLList.h" |
21 #include "SkTMultiMap.h" | 21 #include "SkTMultiMap.h" |
22 | 22 |
23 class GrCaps; | 23 class GrCaps; |
24 class SkString; | 24 class SkString; |
| 25 class SkTraceMemoryDump; |
25 | 26 |
26 /** | 27 /** |
27 * Manages the lifetime of all GrGpuResource instances. | 28 * Manages the lifetime of all GrGpuResource instances. |
28 * | 29 * |
29 * Resources may have optionally have two types of keys: | 30 * Resources may have optionally have two types of keys: |
30 * 1) A scratch key. This is for resources whose allocations are cached but
not their contents. | 31 * 1) A scratch key. This is for resources whose allocations are cached but
not their contents. |
31 * Multiple resources can share the same scratch key. This is so a calle
r can have two | 32 * Multiple resources can share the same scratch key. This is so a calle
r can have two |
32 * resource instances with the same properties (e.g. multipass rendering
that ping-pongs | 33 * resource instances with the same properties (e.g. multipass rendering
that ping-pongs |
33 * between two temporary surfaces). The scratch key is set at resource c
reation time and | 34 * between two temporary surfaces). The scratch key is set at resource c
reation time and |
34 * should never change. Resources need not have a scratch key. | 35 * should never change. Resources need not have a scratch key. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 /** | 173 /** |
173 * Set the callback the cache should use when it is still over budget after
a purge. The 'data' | 174 * Set the callback the cache should use when it is still over budget after
a purge. The 'data' |
174 * provided here will be passed back to the callback. Note that the cache wi
ll attempt to purge | 175 * provided here will be passed back to the callback. Note that the cache wi
ll attempt to purge |
175 * any resources newly freed by the callback. | 176 * any resources newly freed by the callback. |
176 */ | 177 */ |
177 void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) { | 178 void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) { |
178 fOverBudgetCB = overBudgetCB; | 179 fOverBudgetCB = overBudgetCB; |
179 fOverBudgetData = data; | 180 fOverBudgetData = data; |
180 } | 181 } |
181 | 182 |
182 void notifyFlushOccurred(); | 183 void notifyFlushOccurred(); |
183 | 184 |
184 #if GR_GPU_STATS | 185 #if GR_GPU_STATS |
185 void dumpStats(SkString*) const; | 186 void dumpStats(SkString*) const; |
186 #endif | 187 #endif |
187 | 188 |
188 // This function is for unit testing and is only defined in test tools. | 189 // This function is for unit testing and is only defined in test tools. |
189 void changeTimestamp(uint32_t newTimestamp); | 190 void changeTimestamp(uint32_t newTimestamp); |
190 | 191 |
| 192 // Enumerates all cached resources and dumps their details to traceMemoryDum
p. |
| 193 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; |
| 194 |
191 private: | 195 private: |
192 /////////////////////////////////////////////////////////////////////////// | 196 /////////////////////////////////////////////////////////////////////////// |
193 /// @name Methods accessible via ResourceAccess | 197 /// @name Methods accessible via ResourceAccess |
194 //// | 198 //// |
195 void insertResource(GrGpuResource*); | 199 void insertResource(GrGpuResource*); |
196 void removeResource(GrGpuResource*); | 200 void removeResource(GrGpuResource*); |
197 void notifyCntReachedZero(GrGpuResource*, uint32_t flags); | 201 void notifyCntReachedZero(GrGpuResource*, uint32_t flags); |
198 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); | 202 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); |
199 void changeUniqueKey(GrGpuResource*, const GrUniqueKey&); | 203 void changeUniqueKey(GrGpuResource*, const GrUniqueKey&); |
200 void removeUniqueKey(GrGpuResource*); | 204 void removeUniqueKey(GrGpuResource*); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 384 |
381 friend class GrGpuResource; // To access all the proxy inline methods. | 385 friend class GrGpuResource; // To access all the proxy inline methods. |
382 friend class GrResourceCache; // To create this type. | 386 friend class GrResourceCache; // To create this type. |
383 }; | 387 }; |
384 | 388 |
385 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { | 389 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { |
386 return ResourceAccess(this); | 390 return ResourceAccess(this); |
387 } | 391 } |
388 | 392 |
389 #endif | 393 #endif |
OLD | NEW |