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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 /** | 48 /** |
49 * Called by the cache to delete the resource when the backend 3D context is
no longer valid. | 49 * Called by the cache to delete the resource when the backend 3D context is
no longer valid. |
50 */ | 50 */ |
51 void abandon() { | 51 void abandon() { |
52 fResource->abandon(); | 52 fResource->abandon(); |
53 if (fResource->isPurgeable()) { | 53 if (fResource->isPurgeable()) { |
54 SkDELETE(fResource); | 54 SkDELETE(fResource); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
| 58 /** Called by the cache to assign a new unique key. */ |
| 59 void setUniqueKey(const GrUniqueKey& key) { fResource->fUniqueKey = key; } |
| 60 |
| 61 /** Called by the cache to make the unique key invalid. */ |
| 62 void removeUniqueKey() { fResource->fUniqueKey.reset(); } |
| 63 |
58 uint32_t timestamp() const { return fResource->fTimestamp; } | 64 uint32_t timestamp() const { return fResource->fTimestamp; } |
59 void setTimestamp(uint32_t ts) { fResource->fTimestamp = ts; } | 65 void setTimestamp(uint32_t ts) { fResource->fTimestamp = ts; } |
60 | 66 |
61 int* accessCacheIndex() const { return &fResource->fCacheArrayIndex; } | 67 int* accessCacheIndex() const { return &fResource->fCacheArrayIndex; } |
62 | 68 |
63 CacheAccess(GrGpuResource* resource) : fResource(resource) {} | 69 CacheAccess(GrGpuResource* resource) : fResource(resource) {} |
64 CacheAccess(const CacheAccess& that) : fResource(that.fResource) {} | 70 CacheAccess(const CacheAccess& that) : fResource(that.fResource) {} |
65 CacheAccess& operator=(const CacheAccess&); // unimpl | 71 CacheAccess& operator=(const CacheAccess&); // unimpl |
66 | 72 |
67 // No taking addresses of this type. | 73 // No taking addresses of this type. |
68 const CacheAccess* operator&() const; | 74 const CacheAccess* operator&() const; |
69 CacheAccess* operator&(); | 75 CacheAccess* operator&(); |
70 | 76 |
71 GrGpuResource* fResource; | 77 GrGpuResource* fResource; |
72 | 78 |
73 friend class GrGpuResource; // to construct/copy this type. | 79 friend class GrGpuResource; // to construct/copy this type. |
74 friend class GrResourceCache; // to use this type | 80 friend class GrResourceCache; // to use this type |
75 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing | 81 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing |
76 }; | 82 }; |
77 | 83 |
78 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 84 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
79 | 85 |
80 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 86 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
81 return CacheAccess(const_cast<GrGpuResource*>(this)); | 87 return CacheAccess(const_cast<GrGpuResource*>(this)); |
82 } | 88 } |
83 | 89 |
84 #endif | 90 #endif |
OLD | NEW |