| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 /////////////////////////////////////////////////////////////////////////// | 156 /////////////////////////////////////////////////////////////////////////// |
| 157 /// @name Methods accessible via ResourceAccess | 157 /// @name Methods accessible via ResourceAccess |
| 158 //// | 158 //// |
| 159 void insertResource(GrGpuResource*); | 159 void insertResource(GrGpuResource*); |
| 160 void removeResource(GrGpuResource*); | 160 void removeResource(GrGpuResource*); |
| 161 void notifyPurgable(GrGpuResource*); | 161 void notifyPurgable(GrGpuResource*); |
| 162 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); | 162 void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize); |
| 163 bool didSetContentKey(GrGpuResource*); | 163 bool didSetContentKey(GrGpuResource*); |
| 164 void willRemoveScratchKey(const GrGpuResource*); |
| 164 void didChangeBudgetStatus(GrGpuResource*); | 165 void didChangeBudgetStatus(GrGpuResource*); |
| 165 void makeResourceMRU(GrGpuResource*); | 166 void makeResourceMRU(GrGpuResource*); |
| 166 /// @} | 167 /// @} |
| 167 | 168 |
| 168 void purgeAsNeeded() { | 169 void purgeAsNeeded() { |
| 169 if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes < fMaxByt
es)) { | 170 if (fPurging || (fBudgetedCount <= fMaxCount && fBudgetedBytes < fMaxByt
es)) { |
| 170 return; | 171 return; |
| 171 } | 172 } |
| 172 this->internalPurgeAsNeeded(); | 173 this->internalPurgeAsNeeded(); |
| 173 } | 174 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 /** | 271 /** |
| 271 * Called by GrGpuResources when their content keys change. | 272 * Called by GrGpuResources when their content keys change. |
| 272 * | 273 * |
| 273 * This currently returns a bool and fails when an existing resource has a k
ey that collides | 274 * This currently returns a bool and fails when an existing resource has a k
ey that collides |
| 274 * with the new content key. In the future it will null out the content key
for the existing | 275 * with the new content key. In the future it will null out the content key
for the existing |
| 275 * resource. The failure is a temporary measure taken because duties are spl
it between two | 276 * resource. The failure is a temporary measure taken because duties are spl
it between two |
| 276 * cache objects currently. | 277 * cache objects currently. |
| 277 */ | 278 */ |
| 278 bool didSetContentKey(GrGpuResource* resource) { return fCache->didSetConten
tKey(resource); } | 279 bool didSetContentKey(GrGpuResource* resource) { return fCache->didSetConten
tKey(resource); } |
| 279 | 280 |
| 281 /** |
| 282 * Called by GrGpuResources when the remove their scratch key. |
| 283 */ |
| 284 void willRemoveScratchKey(const GrGpuResource* resource) { |
| 285 fCache->willRemoveScratchKey(resource); |
| 286 } |
| 280 | 287 |
| 281 /** | 288 /** |
| 282 * Called by GrGpuResources when they change from budgeted to unbudgeted or
vice versa. | 289 * Called by GrGpuResources when they change from budgeted to unbudgeted or
vice versa. |
| 283 */ | 290 */ |
| 284 void didChangeBudgetStatus(GrGpuResource* resource) { fCache->didChangeBudge
tStatus(resource); } | 291 void didChangeBudgetStatus(GrGpuResource* resource) { fCache->didChangeBudge
tStatus(resource); } |
| 285 | 292 |
| 286 // No taking addresses of this type. | 293 // No taking addresses of this type. |
| 287 const ResourceAccess* operator&() const; | 294 const ResourceAccess* operator&() const; |
| 288 ResourceAccess* operator&(); | 295 ResourceAccess* operator&(); |
| 289 | 296 |
| 290 GrResourceCache2* fCache; | 297 GrResourceCache2* fCache; |
| 291 | 298 |
| 292 friend class GrGpuResource; // To access all the proxy inline methods. | 299 friend class GrGpuResource; // To access all the proxy inline methods. |
| 293 friend class GrResourceCache2; // To create this type. | 300 friend class GrResourceCache2; // To create this type. |
| 294 }; | 301 }; |
| 295 | 302 |
| 296 inline GrResourceCache2::ResourceAccess GrResourceCache2::resourceAccess() { | 303 inline GrResourceCache2::ResourceAccess GrResourceCache2::resourceAccess() { |
| 297 return ResourceAccess(this); | 304 return ResourceAccess(this); |
| 298 } | 305 } |
| 299 | 306 |
| 300 #endif | 307 #endif |
| OLD | NEW |