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 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 * 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 |
176 * any resources newly freed by the callback. | 176 * any resources newly freed by the callback. |
177 */ | 177 */ |
178 void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) { | 178 void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) { |
179 fOverBudgetCB = overBudgetCB; | 179 fOverBudgetCB = overBudgetCB; |
180 fOverBudgetData = data; | 180 fOverBudgetData = data; |
181 } | 181 } |
182 | 182 |
183 void notifyFlushOccurred(); | 183 void notifyFlushOccurred(); |
184 | 184 |
185 #if GR_GPU_STATS | 185 #if GR_CACHE_STATS |
| 186 struct Stats { |
| 187 int fTotal; |
| 188 int fNumPurgeable; |
| 189 int fNumNonPurgeable; |
| 190 |
| 191 int fScratch; |
| 192 int fExternal; |
| 193 int fBorrowed; |
| 194 int fAdopted; |
| 195 size_t fUnbudgetedSize; |
| 196 |
| 197 Stats() { this->reset(); } |
| 198 |
| 199 void reset() { |
| 200 fTotal = 0; |
| 201 fNumPurgeable = 0; |
| 202 fNumNonPurgeable = 0; |
| 203 fScratch = 0; |
| 204 fExternal = 0; |
| 205 fBorrowed = 0; |
| 206 fAdopted = 0; |
| 207 fUnbudgetedSize = 0; |
| 208 } |
| 209 |
| 210 void update(GrGpuResource* resource) { |
| 211 if (resource->cacheAccess().isScratch()) { |
| 212 ++fScratch; |
| 213 } |
| 214 if (resource->cacheAccess().isExternal()) { |
| 215 ++fExternal; |
| 216 } |
| 217 if (resource->cacheAccess().isBorrowed()) { |
| 218 ++fBorrowed; |
| 219 } |
| 220 if (resource->cacheAccess().isAdopted()) { |
| 221 ++fAdopted; |
| 222 } |
| 223 if (!resource->resourcePriv().isBudgeted()) { |
| 224 fUnbudgetedSize += resource->gpuMemorySize(); |
| 225 } |
| 226 } |
| 227 }; |
| 228 |
| 229 void getStats(Stats*) const; |
| 230 |
186 void dumpStats(SkString*) const; | 231 void dumpStats(SkString*) const; |
187 #endif | 232 #endif |
188 | 233 |
189 // This function is for unit testing and is only defined in test tools. | 234 // This function is for unit testing and is only defined in test tools. |
190 void changeTimestamp(uint32_t newTimestamp); | 235 void changeTimestamp(uint32_t newTimestamp); |
191 | 236 |
192 // Enumerates all cached resources and dumps their details to traceMemoryDum
p. | 237 // Enumerates all cached resources and dumps their details to traceMemoryDum
p. |
193 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; | 238 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; |
194 | 239 |
195 private: | 240 private: |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 429 |
385 friend class GrGpuResource; // To access all the proxy inline methods. | 430 friend class GrGpuResource; // To access all the proxy inline methods. |
386 friend class GrResourceCache; // To create this type. | 431 friend class GrResourceCache; // To create this type. |
387 }; | 432 }; |
388 | 433 |
389 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { | 434 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { |
390 return ResourceAccess(this); | 435 return ResourceAccess(this); |
391 } | 436 } |
392 | 437 |
393 #endif | 438 #endif |
OLD | NEW |