OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "GrGpuResource.h" | 9 #include "GrGpuResource.h" |
10 #include "GrResourceCache2.h" | 10 #include "GrResourceCache2.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 fContentKey = key; | 98 fContentKey = key; |
99 | 99 |
100 if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) { | 100 if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) { |
101 fContentKey.reset(); | 101 fContentKey.reset(); |
102 return false; | 102 return false; |
103 } | 103 } |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 void GrGpuResource::notifyIsPurgable() const { | 107 void GrGpuResource::notifyIsPurgeable() const { |
108 if (this->wasDestroyed()) { | 108 if (this->wasDestroyed()) { |
109 // We've already been removed from the cache. Goodbye cruel world! | 109 // We've already been removed from the cache. Goodbye cruel world! |
110 SkDELETE(this); | 110 SkDELETE(this); |
111 } else { | 111 } else { |
112 GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); | 112 GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); |
113 get_resource_cache2(fGpu)->resourceAccess().notifyPurgable(mutableThis); | 113 get_resource_cache2(fGpu)->resourceAccess().notifyPurgeable(mutableThis)
; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 void GrGpuResource::setScratchKey(const GrScratchKey& scratchKey) { | 117 void GrGpuResource::setScratchKey(const GrScratchKey& scratchKey) { |
118 SkASSERT(!fScratchKey.isValid()); | 118 SkASSERT(!fScratchKey.isValid()); |
119 SkASSERT(scratchKey.isValid()); | 119 SkASSERT(scratchKey.isValid()); |
120 // Wrapped resources can never have a scratch key. | 120 // Wrapped resources can never have a scratch key. |
121 if (this->isWrapped()) { | 121 if (this->isWrapped()) { |
122 return; | 122 return; |
123 } | 123 } |
(...skipping 22 matching lines...) Expand all Loading... |
146 } | 146 } |
147 | 147 |
148 uint32_t GrGpuResource::CreateUniqueID() { | 148 uint32_t GrGpuResource::CreateUniqueID() { |
149 static int32_t gUniqueID = SK_InvalidUniqueID; | 149 static int32_t gUniqueID = SK_InvalidUniqueID; |
150 uint32_t id; | 150 uint32_t id; |
151 do { | 151 do { |
152 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 152 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
153 } while (id == SK_InvalidUniqueID); | 153 } while (id == SK_InvalidUniqueID); |
154 return id; | 154 return id; |
155 } | 155 } |
OLD | NEW |