| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 enum { | 119 enum { |
| 120 /** Preferentially returns scratch resources with no pending IO. */ | 120 /** Preferentially returns scratch resources with no pending IO. */ |
| 121 kPreferNoPendingIO_ScratchFlag = 0x1, | 121 kPreferNoPendingIO_ScratchFlag = 0x1, |
| 122 /** Will not return any resources that match but have pending IO. */ | 122 /** Will not return any resources that match but have pending IO. */ |
| 123 kRequireNoPendingIO_ScratchFlag = 0x2, | 123 kRequireNoPendingIO_ScratchFlag = 0x2, |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * Find a resource that matches a scratch key. | 127 * Find a resource that matches a scratch key. |
| 128 */ | 128 */ |
| 129 GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey, uin
t32_t flags = 0); | 129 GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey, |
| 130 size_t resourceSize, |
| 131 uint32_t flags); |
| 130 | 132 |
| 131 #ifdef SK_DEBUG | 133 #ifdef SK_DEBUG |
| 132 // This is not particularly fast and only used for validation, so debug only
. | 134 // This is not particularly fast and only used for validation, so debug only
. |
| 133 int countScratchEntriesForKey(const GrScratchKey& scratchKey) const { | 135 int countScratchEntriesForKey(const GrScratchKey& scratchKey) const { |
| 134 return fScratchMap.countForKey(scratchKey); | 136 return fScratchMap.countForKey(scratchKey); |
| 135 } | 137 } |
| 136 #endif | 138 #endif |
| 137 | 139 |
| 138 /** | 140 /** |
| 139 * Find a resource that matches a unique key. | 141 * Find a resource that matches a unique key. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void didChangeBudgetStatus(GrGpuResource*); | 201 void didChangeBudgetStatus(GrGpuResource*); |
| 200 void refAndMakeResourceMRU(GrGpuResource*); | 202 void refAndMakeResourceMRU(GrGpuResource*); |
| 201 /// @} | 203 /// @} |
| 202 | 204 |
| 203 void resetFlushTimestamps(); | 205 void resetFlushTimestamps(); |
| 204 void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>&
); | 206 void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>&
); |
| 205 void addToNonpurgeableArray(GrGpuResource*); | 207 void addToNonpurgeableArray(GrGpuResource*); |
| 206 void removeFromNonpurgeableArray(GrGpuResource*); | 208 void removeFromNonpurgeableArray(GrGpuResource*); |
| 207 bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCoun
t > fMaxCount; } | 209 bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCoun
t > fMaxCount; } |
| 208 | 210 |
| 211 bool wouldFit(size_t bytes) { |
| 212 return fBudgetedBytes+bytes <= fMaxBytes && fBudgetedCount+1 <= fMaxCoun
t; |
| 213 } |
| 214 |
| 209 uint32_t getNextTimestamp(); | 215 uint32_t getNextTimestamp(); |
| 210 | 216 |
| 211 #ifdef SK_DEBUG | 217 #ifdef SK_DEBUG |
| 212 bool isInCache(const GrGpuResource* r) const; | 218 bool isInCache(const GrGpuResource* r) const; |
| 213 void validate() const; | 219 void validate() const; |
| 214 #else | 220 #else |
| 215 void validate() const {} | 221 void validate() const {} |
| 216 #endif | 222 #endif |
| 217 | 223 |
| 218 class AutoValidate; | 224 class AutoValidate; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 377 |
| 372 friend class GrGpuResource; // To access all the proxy inline methods. | 378 friend class GrGpuResource; // To access all the proxy inline methods. |
| 373 friend class GrResourceCache; // To create this type. | 379 friend class GrResourceCache; // To create this type. |
| 374 }; | 380 }; |
| 375 | 381 |
| 376 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { | 382 inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() { |
| 377 return ResourceAccess(this); | 383 return ResourceAccess(this); |
| 378 } | 384 } |
| 379 | 385 |
| 380 #endif | 386 #endif |
| OLD | NEW |