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 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 #if GR_GPU_STATS | 148 #if GR_GPU_STATS |
149 void printStats() const; | 149 void printStats() const; |
150 #endif | 150 #endif |
151 | 151 |
152 private: | 152 private: |
153 /////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////// |
154 /// @name Methods accessible via ResourceAccess | 154 /// @name Methods accessible via ResourceAccess |
155 //// | 155 //// |
156 void insertResource(GrGpuResource*); | 156 void insertResource(GrGpuResource*); |
157 void removeResource(GrGpuResource*); | 157 void removeResource(GrGpuResource*); |
158 void notifyPurgable(GrGpuResource*); | 158 void notifyPurgeable(GrGpuResource*); |
159 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); | 159 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); |
160 bool didSetContentKey(GrGpuResource*); | 160 bool didSetContentKey(GrGpuResource*); |
161 void willRemoveScratchKey(const GrGpuResource*); | 161 void willRemoveScratchKey(const GrGpuResource*); |
162 void didChangeBudgetStatus(GrGpuResource*); | 162 void didChangeBudgetStatus(GrGpuResource*); |
163 void makeResourceMRU(GrGpuResource*); | 163 void makeResourceMRU(GrGpuResource*); |
164 /// @} | 164 /// @} |
165 | 165 |
166 void purgeAsNeeded() { | 166 void purgeAsNeeded() { |
167 if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBy
tes)) { | 167 if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBy
tes)) { |
168 return; | 168 return; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // our current stats for all resources | 223 // our current stats for all resources |
224 int fCount; | 224 int fCount; |
225 size_t fBytes; | 225 size_t fBytes; |
226 | 226 |
227 // our current stats for resources that count against the budget | 227 // our current stats for resources that count against the budget |
228 int fBudgetedCount; | 228 int fBudgetedCount; |
229 size_t fBudgetedBytes; | 229 size_t fBudgetedBytes; |
230 | 230 |
231 // prevents recursive purging | 231 // prevents recursive purging |
232 bool fPurging; | 232 bool fPurging; |
233 bool fNewlyPurgableResourceWhilePurging; | 233 bool fNewlyPurgeableResourceWhilePurging; |
234 | 234 |
235 PFOverBudgetCB fOverBudgetCB; | 235 PFOverBudgetCB fOverBudgetCB; |
236 void* fOverBudgetData; | 236 void* fOverBudgetData; |
237 | 237 |
238 }; | 238 }; |
239 | 239 |
240 class GrResourceCache2::ResourceAccess { | 240 class GrResourceCache2::ResourceAccess { |
241 private: | 241 private: |
242 ResourceAccess(GrResourceCache2* cache) : fCache(cache) { } | 242 ResourceAccess(GrResourceCache2* cache) : fCache(cache) { } |
243 ResourceAccess(const ResourceAccess& that) : fCache(that.fCache) { } | 243 ResourceAccess(const ResourceAccess& that) : fCache(that.fCache) { } |
244 ResourceAccess& operator=(const ResourceAccess&); // unimpl | 244 ResourceAccess& operator=(const ResourceAccess&); // unimpl |
245 | 245 |
246 /** | 246 /** |
247 * Insert a resource into the cache. | 247 * Insert a resource into the cache. |
248 */ | 248 */ |
249 void insertResource(GrGpuResource* resource) { fCache->insertResource(resour
ce); } | 249 void insertResource(GrGpuResource* resource) { fCache->insertResource(resour
ce); } |
250 | 250 |
251 /** | 251 /** |
252 * Removes a resource from the cache. | 252 * Removes a resource from the cache. |
253 */ | 253 */ |
254 void removeResource(GrGpuResource* resource) { fCache->removeResource(resour
ce); } | 254 void removeResource(GrGpuResource* resource) { fCache->removeResource(resour
ce); } |
255 | 255 |
256 /** | 256 /** |
257 * Called by GrGpuResources when they detects that they are newly purgable. | 257 * Called by GrGpuResources when they detects that they are newly purgeable. |
258 */ | 258 */ |
259 void notifyPurgable(GrGpuResource* resource) { fCache->notifyPurgable(resour
ce); } | 259 void notifyPurgeable(GrGpuResource* resource) { fCache->notifyPurgeable(reso
urce); } |
260 | 260 |
261 /** | 261 /** |
262 * Called by GrGpuResources when their sizes change. | 262 * Called by GrGpuResources when their sizes change. |
263 */ | 263 */ |
264 void didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) { | 264 void didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) { |
265 fCache->didChangeGpuMemorySize(resource, oldSize); | 265 fCache->didChangeGpuMemorySize(resource, oldSize); |
266 } | 266 } |
267 | 267 |
268 /** | 268 /** |
269 * Called by GrGpuResources when their content keys change. | 269 * Called by GrGpuResources when their content keys change. |
(...skipping 25 matching lines...) Expand all Loading... |
295 | 295 |
296 friend class GrGpuResource; // To access all the proxy inline methods. | 296 friend class GrGpuResource; // To access all the proxy inline methods. |
297 friend class GrResourceCache2; // To create this type. | 297 friend class GrResourceCache2; // To create this type. |
298 }; | 298 }; |
299 | 299 |
300 inline GrResourceCache2::ResourceAccess GrResourceCache2::resourceAccess() { | 300 inline GrResourceCache2::ResourceAccess GrResourceCache2::resourceAccess() { |
301 return ResourceAccess(this); | 301 return ResourceAccess(this); |
302 } | 302 } |
303 | 303 |
304 #endif | 304 #endif |
OLD | NEW |