| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 SkASSERT(fUniqueKey.isValid()); | 113 SkASSERT(fUniqueKey.isValid()); |
| 114 get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this); | 114 get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void GrGpuResource::setUniqueKey(const GrUniqueKey& key) { | 117 void GrGpuResource::setUniqueKey(const GrUniqueKey& key) { |
| 118 SkASSERT(this->internalHasRef()); | 118 SkASSERT(this->internalHasRef()); |
| 119 SkASSERT(key.isValid()); | 119 SkASSERT(key.isValid()); |
| 120 | 120 |
| 121 // Wrapped and uncached resources can never have a unique key. | 121 // Wrapped and uncached resources can never have a unique key. |
| 122 if (SkBudgeted::kNo == this->resourcePriv().isBudgeted()) { | 122 if (!this->resourcePriv().isBudgeted()) { |
| 123 return; | 123 return; |
| 124 } | 124 } |
| 125 | 125 |
| 126 if (this->wasDestroyed()) { | 126 if (this->wasDestroyed()) { |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key); | 130 get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key); |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 uint32_t GrGpuResource::CreateUniqueID() { | 200 uint32_t GrGpuResource::CreateUniqueID() { |
| 201 static int32_t gUniqueID = SK_InvalidUniqueID; | 201 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 202 uint32_t id; | 202 uint32_t id; |
| 203 do { | 203 do { |
| 204 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 204 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 205 } while (id == SK_InvalidUniqueID); | 205 } while (id == SK_InvalidUniqueID); |
| 206 return id; | 206 return id; |
| 207 } | 207 } |
| OLD | NEW |