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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (this->wasDestroyed()) { | 75 if (this->wasDestroyed()) { |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
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 void GrGpuResource::removeContentKey() { |
| 86 SkASSERT(fContentKey.isValid()); |
| 87 get_resource_cache2(fGpu)->resourceAccess().willRemoveContentKey(this); |
| 88 fContentKey.reset(); |
| 89 } |
| 90 |
85 bool GrGpuResource::setContentKey(const GrContentKey& key) { | 91 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. | 92 // Currently this can only be called once and can't be called when the resou
rce is scratch. |
87 SkASSERT(this->internalHasRef()); | 93 SkASSERT(this->internalHasRef()); |
| 94 SkASSERT(key.isValid()); |
88 | 95 |
89 // Wrapped and uncached resources can never have a content key. | 96 // Wrapped and uncached resources can never have a content key. |
90 if (!this->cacheAccess().isBudgeted()) { | 97 if (!this->cacheAccess().isBudgeted()) { |
91 return false; | 98 return false; |
92 } | 99 } |
93 | 100 |
94 if (fContentKey.isValid() || this->wasDestroyed()) { | 101 if (fContentKey.isValid() || this->wasDestroyed()) { |
95 return false; | 102 return false; |
96 } | 103 } |
97 | 104 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 153 } |
147 | 154 |
148 uint32_t GrGpuResource::CreateUniqueID() { | 155 uint32_t GrGpuResource::CreateUniqueID() { |
149 static int32_t gUniqueID = SK_InvalidUniqueID; | 156 static int32_t gUniqueID = SK_InvalidUniqueID; |
150 uint32_t id; | 157 uint32_t id; |
151 do { | 158 do { |
152 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); | 159 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); |
153 } while (id == SK_InvalidUniqueID); | 160 } while (id == SK_InvalidUniqueID); |
154 return id; | 161 return id; |
155 } | 162 } |
OLD | NEW |