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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 /** | 47 /** |
48 * If the resource is currently cached by a content key, the key is returned
, otherwise NULL. | 48 * If the resource is currently cached by a content key, the key is returned
, otherwise NULL. |
49 */ | 49 */ |
50 const GrResourceKey* getContentKey() const { | 50 const GrResourceKey* getContentKey() const { |
51 if (fResource->fContentKeySet) { | 51 if (fResource->fContentKeySet) { |
52 return &fResource->fContentKey; | 52 return &fResource->fContentKey; |
53 } | 53 } |
54 return NULL; | 54 return NULL; |
55 } | 55 } |
56 | 56 |
| 57 /** |
| 58 * Called by the cache to delete the resource under normal circumstances. |
| 59 */ |
| 60 void release() { |
| 61 fResource->release(); |
| 62 if (fResource->isPurgable()) { |
| 63 SkDELETE(fResource); |
| 64 } |
| 65 } |
| 66 |
| 67 /** |
| 68 * Called by the cache to delete the resource when the backend 3D context is
no longer valid. |
| 69 */ |
| 70 void abandon() { |
| 71 fResource->abandon(); |
| 72 if (fResource->isPurgable()) { |
| 73 SkDELETE(fResource); |
| 74 } |
| 75 } |
| 76 |
57 private: | 77 private: |
58 CacheAccess(GrGpuResource* resource) : fResource(resource) { } | 78 CacheAccess(GrGpuResource* resource) : fResource(resource) { } |
59 CacheAccess(const CacheAccess& that) : fResource(that.fResource) { } | 79 CacheAccess(const CacheAccess& that) : fResource(that.fResource) { } |
60 CacheAccess& operator=(const CacheAccess&); // unimpl | 80 CacheAccess& operator=(const CacheAccess&); // unimpl |
61 | 81 |
62 // No taking addresses of this type. | 82 // No taking addresses of this type. |
63 const CacheAccess* operator&() const; | 83 const CacheAccess* operator&() const; |
64 CacheAccess* operator&(); | 84 CacheAccess* operator&(); |
65 | 85 |
66 GrGpuResource* fResource; | 86 GrGpuResource* fResource; |
67 | 87 |
68 friend class GrGpuResource; // to construct/copy this type. | 88 friend class GrGpuResource; // to construct/copy this type. |
69 }; | 89 }; |
70 | 90 |
71 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 91 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
72 | 92 |
73 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 93 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
74 return CacheAccess(const_cast<GrGpuResource*>(this)); | 94 return CacheAccess(const_cast<GrGpuResource*>(this)); |
75 } | 95 } |
76 | 96 |
77 #endif | 97 #endif |
OLD | NEW |