| 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 | 9 |
| 10 #include "GrGpuResource.h" | 10 #include "GrGpuResource.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 SkASSERT(fScratchKey.isNullScratch()); | 121 SkASSERT(fScratchKey.isNullScratch()); |
| 122 SkASSERT(scratchKey.isScratch()); | 122 SkASSERT(scratchKey.isScratch()); |
| 123 SkASSERT(!scratchKey.isNullScratch()); | 123 SkASSERT(!scratchKey.isNullScratch()); |
| 124 // Wrapped resources can never have a key. | 124 // Wrapped resources can never have a key. |
| 125 if (this->isWrapped()) { | 125 if (this->isWrapped()) { |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 fScratchKey = scratchKey; | 128 fScratchKey = scratchKey; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void GrGpuResource::removeScratchKey() { |
| 132 if (!this->wasDestroyed() && !fScratchKey.isNullScratch()) { |
| 133 get_resource_cache2(fGpu)->resourceAccess().willRemoveScratchKey(this); |
| 134 fScratchKey = GrResourceKey::NullScratchKey(); |
| 135 } |
| 136 } |
| 137 |
| 131 uint32_t GrGpuResource::CreateUniqueID() { | 138 uint32_t GrGpuResource::CreateUniqueID() { |
| 132 static int32_t gUniqueID = SK_InvalidUniqueID; | 139 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 133 uint32_t id; | 140 uint32_t id; |
| 134 do { | 141 do { |
| 135 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 142 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 136 } while (id == SK_InvalidUniqueID); | 143 } while (id == SK_InvalidUniqueID); |
| 137 return id; | 144 return id; |
| 138 } | 145 } |
| 139 | 146 |
| 140 void GrGpuResource::setBudgeted(bool countsAgainstBudget) { | 147 void GrGpuResource::setBudgeted(bool countsAgainstBudget) { |
| 141 // Wrapped resources never count against the budget, nothing to do. No point
in changing the | 148 // Wrapped resources never count against the budget, nothing to do. No point
in changing the |
| 142 // budgeting of destroyed resources. | 149 // budgeting of destroyed resources. |
| 143 if (this->isWrapped() || this->wasDestroyed()) { | 150 if (this->isWrapped() || this->wasDestroyed()) { |
| 144 return; | 151 return; |
| 145 } | 152 } |
| 146 | 153 |
| 147 uint32_t oldFlags = fFlags; | 154 uint32_t oldFlags = fFlags; |
| 148 if (countsAgainstBudget) { | 155 if (countsAgainstBudget) { |
| 149 fFlags |= kBudgeted_Flag; | 156 fFlags |= kBudgeted_Flag; |
| 150 } else { | 157 } else { |
| 151 fFlags &= ~kBudgeted_Flag; | 158 fFlags &= ~kBudgeted_Flag; |
| 152 } | 159 } |
| 153 if (fFlags != oldFlags) { | 160 if (fFlags != oldFlags) { |
| 154 get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this); | 161 get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this); |
| 155 } | 162 } |
| 156 } | 163 } |
| OLD | NEW |