| 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 GrGpuResourceCacheAccess_DEFINED | 9 #ifndef GrGpuResourceCacheAccess_DEFINED |
| 10 #define GrGpuResourceCacheAccess_DEFINED | 10 #define GrGpuResourceCacheAccess_DEFINED |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 */ | 26 */ |
| 27 bool setContentKey(const GrContentKey& contentKey) { | 27 bool setContentKey(const GrContentKey& contentKey) { |
| 28 return fResource->setContentKey(contentKey); | 28 return fResource->setContentKey(contentKey); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Is the resource currently cached as scratch? This means it is cached, has
a valid scratch | 32 * Is the resource currently cached as scratch? This means it is cached, has
a valid scratch |
| 33 * key, and does not have a content key. | 33 * key, and does not have a content key. |
| 34 */ | 34 */ |
| 35 bool isScratch() const { | 35 bool isScratch() const { |
| 36 return !this->getContentKey().isValid() && fResource->fScratchKey.isVali
d() && | 36 return !fResource->getContentKey().isValid() && fResource->fScratchKey.i
sValid() && |
| 37 this->isBudgeted(); | 37 this->isBudgeted(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * If this resource can be used as a scratch resource this returns a valid s
cratch key. | 41 * If this resource can be used as a scratch resource this returns a valid s
cratch key. |
| 42 * Otherwise it returns a key for which isNullScratch is true. The resource
may currently be | 42 * Otherwise it returns a key for which isNullScratch is true. The resource
may currently be |
| 43 * used as a content resource rather than scratch. Check isScratch(). | 43 * used as a content resource rather than scratch. Check isScratch(). |
| 44 */ | 44 */ |
| 45 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; } | 45 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; } |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * If the resource has a scratch key, the key will be removed. Since scratch
keys are installed | 48 * If the resource has a scratch key, the key will be removed. Since scratch
keys are installed |
| 49 * at resource creation time, this means the resource will never again be us
ed as scratch. | 49 * at resource creation time, this means the resource will never again be us
ed as scratch. |
| 50 */ | 50 */ |
| 51 void removeScratchKey() const { fResource->removeScratchKey(); } | 51 void removeScratchKey() const { fResource->removeScratchKey(); } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * If the resource is currently cached by a content key, the key is returned
, otherwise NULL. | |
| 55 */ | |
| 56 const GrContentKey& getContentKey() const { return fResource->fContentKey; } | |
| 57 | |
| 58 /** | |
| 59 * Is the resource object wrapping an externally allocated GPU resource? | 54 * Is the resource object wrapping an externally allocated GPU resource? |
| 60 */ | 55 */ |
| 61 bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResour
ce->fLifeCycle; } | 56 bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResour
ce->fLifeCycle; } |
| 62 | 57 |
| 63 /** | 58 /** |
| 64 * Does the resource count against the resource budget? | 59 * Does the resource count against the resource budget? |
| 65 */ | 60 */ |
| 66 bool isBudgeted() const { | 61 bool isBudgeted() const { |
| 67 bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle; | 62 bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle; |
| 68 SkASSERT(ret || !this->getContentKey().isValid()); | 63 SkASSERT(ret || !fResource->getContentKey().isValid()); |
| 69 return ret; | 64 return ret; |
| 70 } | 65 } |
| 71 | 66 |
| 72 /** | 67 /** |
| 73 * If the resource is uncached make it cached. Has no effect on resources th
at are wrapped or | 68 * If the resource is uncached make it cached. Has no effect on resources th
at are wrapped or |
| 74 * already cached. | 69 * already cached. |
| 75 */ | 70 */ |
| 76 void makeBudgeted() { fResource->makeBudgeted(); } | 71 void makeBudgeted() { fResource->makeBudgeted(); } |
| 77 | 72 |
| 78 /** | 73 /** |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 friend class GrGpuResource; // to construct/copy this type. | 110 friend class GrGpuResource; // to construct/copy this type. |
| 116 }; | 111 }; |
| 117 | 112 |
| 118 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 113 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
| 119 | 114 |
| 120 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 115 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
| 121 return CacheAccess(const_cast<GrGpuResource*>(this)); | 116 return CacheAccess(const_cast<GrGpuResource*>(this)); |
| 122 } | 117 } |
| 123 | 118 |
| 124 #endif | 119 #endif |
| OLD | NEW |