| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGpuResourceCacheAccess_DEFINED | 8 #ifndef GrGpuResourceCacheAccess_DEFINED |
| 9 #define GrGpuResourceCacheAccess_DEFINED | 9 #define GrGpuResourceCacheAccess_DEFINED |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 /** Called by the cache to assign a new unique key. */ | 52 /** Called by the cache to assign a new unique key. */ |
| 53 void setUniqueKey(const GrUniqueKey& key) { fResource->fUniqueKey = key; } | 53 void setUniqueKey(const GrUniqueKey& key) { fResource->fUniqueKey = key; } |
| 54 | 54 |
| 55 /** Called by the cache to make the unique key invalid. */ | 55 /** Called by the cache to make the unique key invalid. */ |
| 56 void removeUniqueKey() { fResource->fUniqueKey.reset(); } | 56 void removeUniqueKey() { fResource->fUniqueKey.reset(); } |
| 57 | 57 |
| 58 uint32_t timestamp() const { return fResource->fTimestamp; } | 58 uint32_t timestamp() const { return fResource->fTimestamp; } |
| 59 void setTimestamp(uint32_t ts) { fResource->fTimestamp = ts; } | 59 void setTimestamp(uint32_t ts) { fResource->fTimestamp = ts; } |
| 60 | 60 |
| 61 /** Called by the cache to record when this became purgeable. */ |
| 62 void setFlushCntWhenResourceBecamePurgeable(uint32_t cnt) { |
| 63 SkASSERT(fResource->isPurgeable()); |
| 64 fResource->fExternalFlushCntWhenBecamePurgeable = cnt; |
| 65 } |
| 66 /** |
| 67 * Called by the cache to determine whether this resource has been puregable
for more than |
| 68 * a threshold number of external flushes. |
| 69 */ |
| 70 uint32_t flushCntWhenResourceBecamePurgeable() { |
| 71 SkASSERT(fResource->isPurgeable()); |
| 72 return fResource->fExternalFlushCntWhenBecamePurgeable; |
| 73 } |
| 74 |
| 61 int* accessCacheIndex() const { return &fResource->fCacheArrayIndex; } | 75 int* accessCacheIndex() const { return &fResource->fCacheArrayIndex; } |
| 62 | 76 |
| 63 CacheAccess(GrGpuResource* resource) : fResource(resource) {} | 77 CacheAccess(GrGpuResource* resource) : fResource(resource) {} |
| 64 CacheAccess(const CacheAccess& that) : fResource(that.fResource) {} | 78 CacheAccess(const CacheAccess& that) : fResource(that.fResource) {} |
| 65 CacheAccess& operator=(const CacheAccess&); // unimpl | 79 CacheAccess& operator=(const CacheAccess&); // unimpl |
| 66 | 80 |
| 67 // No taking addresses of this type. | 81 // No taking addresses of this type. |
| 68 const CacheAccess* operator&() const; | 82 const CacheAccess* operator&() const; |
| 69 CacheAccess* operator&(); | 83 CacheAccess* operator&(); |
| 70 | 84 |
| 71 GrGpuResource* fResource; | 85 GrGpuResource* fResource; |
| 72 | 86 |
| 73 friend class GrGpuResource; // to construct/copy this type. | 87 friend class GrGpuResource; // to construct/copy this type. |
| 74 friend class GrResourceCache; // to use this type | 88 friend class GrResourceCache; // to use this type |
| 75 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing | 89 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing |
| 76 }; | 90 }; |
| 77 | 91 |
| 78 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 92 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
| 79 | 93 |
| 80 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 94 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
| 81 return CacheAccess(const_cast<GrGpuResource*>(this)); | 95 return CacheAccess(const_cast<GrGpuResource*>(this)); |
| 82 } | 96 } |
| 83 | 97 |
| 84 #endif | 98 #endif |
| OLD | NEW |