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 "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (this->wasDestroyed()) { | 102 if (this->wasDestroyed()) { |
103 return; | 103 return; |
104 } | 104 } |
105 | 105 |
106 get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key); | 106 get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key); |
107 } | 107 } |
108 | 108 |
109 void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const { | 109 void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const { |
110 if (this->wasDestroyed()) { | 110 if (this->wasDestroyed()) { |
111 // We've already been removed from the cache. Goodbye cruel world! | 111 // We've already been removed from the cache. Goodbye cruel world! |
112 SkDELETE(this); | 112 delete this; |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 // We should have already handled this fully in notifyRefCntIsZero(). | 116 // We should have already handled this fully in notifyRefCntIsZero(). |
117 SkASSERT(kRef_CntType != lastCntTypeToReachZero); | 117 SkASSERT(kRef_CntType != lastCntTypeToReachZero); |
118 | 118 |
119 GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); | 119 GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); |
120 static const uint32_t kFlag = | 120 static const uint32_t kFlag = |
121 GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag
; | 121 GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag
; |
122 get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis,
kFlag); | 122 get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis,
kFlag); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 uint32_t GrGpuResource::CreateUniqueID() { | 175 uint32_t GrGpuResource::CreateUniqueID() { |
176 static int32_t gUniqueID = SK_InvalidUniqueID; | 176 static int32_t gUniqueID = SK_InvalidUniqueID; |
177 uint32_t id; | 177 uint32_t id; |
178 do { | 178 do { |
179 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 179 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
180 } while (id == SK_InvalidUniqueID); | 180 } while (id == SK_InvalidUniqueID); |
181 return id; | 181 return id; |
182 } | 182 } |
OLD | NEW |