| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 * If the resource is cached make it uncached. Has no effect on resources th
at are wrapped or | 79 * If the resource is cached make it uncached. Has no effect on resources th
at are wrapped or |
| 80 * already uncached. Furthermore, resources with content keys cannot be made
unbudgeted. | 80 * already uncached. Furthermore, resources with content keys cannot be made
unbudgeted. |
| 81 */ | 81 */ |
| 82 void makeUnbudgeted() { fResource->makeUnbudgeted(); } | 82 void makeUnbudgeted() { fResource->makeUnbudgeted(); } |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Called by the cache to delete the resource under normal circumstances. | 85 * Called by the cache to delete the resource under normal circumstances. |
| 86 */ | 86 */ |
| 87 void release() { | 87 void release() { |
| 88 fResource->release(); | 88 fResource->release(); |
| 89 if (fResource->isPurgable()) { | 89 if (fResource->isPurgeable()) { |
| 90 SkDELETE(fResource); | 90 SkDELETE(fResource); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Called by the cache to delete the resource when the backend 3D context is
no longer valid. | 95 * Called by the cache to delete the resource when the backend 3D context is
no longer valid. |
| 96 */ | 96 */ |
| 97 void abandon() { | 97 void abandon() { |
| 98 fResource->abandon(); | 98 fResource->abandon(); |
| 99 if (fResource->isPurgable()) { | 99 if (fResource->isPurgeable()) { |
| 100 SkDELETE(fResource); | 100 SkDELETE(fResource); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 CacheAccess(GrGpuResource* resource) : fResource(resource) { } | 105 CacheAccess(GrGpuResource* resource) : fResource(resource) { } |
| 106 CacheAccess(const CacheAccess& that) : fResource(that.fResource) { } | 106 CacheAccess(const CacheAccess& that) : fResource(that.fResource) { } |
| 107 CacheAccess& operator=(const CacheAccess&); // unimpl | 107 CacheAccess& operator=(const CacheAccess&); // unimpl |
| 108 | 108 |
| 109 // No taking addresses of this type. | 109 // No taking addresses of this type. |
| 110 const CacheAccess* operator&() const; | 110 const CacheAccess* operator&() const; |
| 111 CacheAccess* operator&(); | 111 CacheAccess* operator&(); |
| 112 | 112 |
| 113 GrGpuResource* fResource; | 113 GrGpuResource* fResource; |
| 114 | 114 |
| 115 friend class GrGpuResource; // to construct/copy this type. | 115 friend class GrGpuResource; // to construct/copy this type. |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 118 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
| 119 | 119 |
| 120 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 120 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
| 121 return CacheAccess(const_cast<GrGpuResource*>(this)); | 121 return CacheAccess(const_cast<GrGpuResource*>(this)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 #endif | 124 #endif |
| OLD | NEW |