| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 size_t oldSize = fGpuMemorySize; | 79 size_t oldSize = fGpuMemorySize; |
| 80 SkASSERT(kInvalidGpuMemorySize != oldSize); | 80 SkASSERT(kInvalidGpuMemorySize != oldSize); |
| 81 fGpuMemorySize = kInvalidGpuMemorySize; | 81 fGpuMemorySize = kInvalidGpuMemorySize; |
| 82 get_resource_cache2(fGpu)->resourceAccess().didChangeGpuMemorySize(this, old
Size); | 82 get_resource_cache2(fGpu)->resourceAccess().didChangeGpuMemorySize(this, old
Size); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool GrGpuResource::setContentKey(const GrContentKey& key) { | 85 bool GrGpuResource::setContentKey(const GrContentKey& key) { |
| 86 // Currently this can only be called once and can't be called when the resou
rce is scratch. | 86 // Currently this can only be called once and can't be called when the resou
rce is scratch. |
| 87 SkASSERT(this->internalHasRef()); | 87 SkASSERT(this->internalHasRef()); |
| 88 | 88 |
| 89 // Wrapped resources can never have a key. | 89 // Wrapped and uncached resources can never have a content key. |
| 90 if (this->isWrapped()) { | 90 if (!this->cacheAccess().isBudgeted()) { |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| 94 if (fContentKey.isValid() || this->wasDestroyed()) { | 94 if (fContentKey.isValid() || this->wasDestroyed()) { |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 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)) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 void GrGpuResource::makeBudgeted() { | 134 void GrGpuResource::makeBudgeted() { |
| 135 if (GrGpuResource::kUncached_LifeCycle == fLifeCycle) { | 135 if (GrGpuResource::kUncached_LifeCycle == fLifeCycle) { |
| 136 fLifeCycle = kCached_LifeCycle; | 136 fLifeCycle = kCached_LifeCycle; |
| 137 get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this); | 137 get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 void GrGpuResource::makeUnbudgeted() { |
| 142 if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fContentKey.isValid()
) { |
| 143 fLifeCycle = kUncached_LifeCycle; |
| 144 get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this); |
| 145 } |
| 146 } |
| 147 |
| 141 uint32_t GrGpuResource::CreateUniqueID() { | 148 uint32_t GrGpuResource::CreateUniqueID() { |
| 142 static int32_t gUniqueID = SK_InvalidUniqueID; | 149 static int32_t gUniqueID = SK_InvalidUniqueID; |
| 143 uint32_t id; | 150 uint32_t id; |
| 144 do { | 151 do { |
| 145 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 152 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
| 146 } while (id == SK_InvalidUniqueID); | 153 } while (id == SK_InvalidUniqueID); |
| 147 return id; | 154 return id; |
| 148 } | 155 } |
| OLD | NEW |