| 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 11 matching lines...) Expand all Loading... |
| 22 * be converted to a content resource. Currently this may only be called onc
e per resource. It | 22 * be converted to a content resource. Currently this may only be called onc
e per resource. It |
| 23 * fails if there is already a resource with the same content key. TODO: mak
e this supplant the | 23 * fails if there is already a resource with the same content key. TODO: mak
e this supplant the |
| 24 * resource that currently is using the content key, allow resources' conten
t keys to change, | 24 * resource that currently is using the content key, allow resources' conten
t keys to change, |
| 25 * and allow removal of a content key to convert a resource back to scratch. | 25 * and allow removal of a content key to convert a resource back to scratch. |
| 26 */ | 26 */ |
| 27 bool setContentKey(const GrResourceKey& contentKey) { | 27 bool setContentKey(const GrResourceKey& contentKey) { |
| 28 return fResource->setContentKey(contentKey); | 28 return fResource->setContentKey(contentKey); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Used by legacy cache to attach a cache entry. This is to be removed soon. |
| 33 */ |
| 34 void setCacheEntry(GrResourceCacheEntry* cacheEntry) { |
| 35 // GrResourceCache never changes the cacheEntry once one has been added. |
| 36 SkASSERT(NULL == cacheEntry || NULL == fResource->fCacheEntry); |
| 37 fResource->fCacheEntry = cacheEntry; |
| 38 } |
| 39 |
| 40 /** |
| 41 * Is the resource in the legacy cache? This is to be removed soon. |
| 42 */ |
| 43 bool isInCache() const { return SkToBool(fResource->fCacheEntry); } |
| 44 |
| 45 /** |
| 46 * Returns the cache entry for the legacy cache. This is to be removed soon. |
| 47 */ |
| 48 GrResourceCacheEntry* getCacheEntry() const { return fResource->fCacheEntry;
} |
| 49 |
| 50 /** |
| 32 * Is the resource currently cached as scratch? This means it has a valid sc
ratch key and does | 51 * Is the resource currently cached as scratch? This means it has a valid sc
ratch key and does |
| 33 * not have a content key. | 52 * not have a content key. |
| 34 */ | 53 */ |
| 35 bool isScratch() const { | 54 bool isScratch() const { |
| 36 SkASSERT(fResource->fScratchKey.isScratch()); | 55 SkASSERT(fResource->fScratchKey.isScratch()); |
| 37 return NULL == this->getContentKey() && !fResource->fScratchKey.isNullSc
ratch(); | 56 return NULL == this->getContentKey() && !fResource->fScratchKey.isNullSc
ratch(); |
| 38 } | 57 } |
| 39 | 58 |
| 40 /** | 59 /** |
| 41 * If this resource can be used as a scratch resource this returns a valid s
cratch key. | 60 * If this resource can be used as a scratch resource this returns a valid s
cratch key. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 friend class GrGpuResource; // to construct/copy this type. | 87 friend class GrGpuResource; // to construct/copy this type. |
| 69 }; | 88 }; |
| 70 | 89 |
| 71 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 90 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
| 72 | 91 |
| 73 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 92 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
| 74 return CacheAccess(const_cast<GrGpuResource*>(this)); | 93 return CacheAccess(const_cast<GrGpuResource*>(this)); |
| 75 } | 94 } |
| 76 | 95 |
| 77 #endif | 96 #endif |
| OLD | NEW |