OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVkResource_DEFINED | 8 #ifndef GrVkResource_DEFINED |
9 #define GrVkResource_DEFINED | 9 #define GrVkResource_DEFINED |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 uint32_t fKey; | 188 uint32_t fKey; |
189 #endif | 189 #endif |
190 | 190 |
191 typedef SkNoncopyable INHERITED; | 191 typedef SkNoncopyable INHERITED; |
192 }; | 192 }; |
193 | 193 |
194 // This subclass allows for recycling | 194 // This subclass allows for recycling |
195 class GrVkRecycledResource : public GrVkResource { | 195 class GrVkRecycledResource : public GrVkResource { |
196 public: | 196 public: |
197 // When recycle is called and there is only one ref left on the resource, we
will signal that | 197 // When recycle is called and there is only one ref left on the resource, we
will signal that |
198 // the resource can be recycled for reuse. This function will always unref t
he object. Thus | 198 // the resource can be recycled for reuse. If the sublass (or whoever is man
aging this resource) |
199 // if the object is recycled it should be ref'd inside the onRecycle call. | 199 // decides not to recycle the objects, it is their responsibility to call un
ref on the object. |
200 void recycle(GrVkGpu* gpu) const { | 200 void recycle(GrVkGpu* gpu) const { |
201 if (this->unique()) { | 201 if (this->unique()) { |
202 this->onRecycle(gpu); | 202 this->onRecycle(gpu); |
| 203 } else { |
| 204 this->unref(gpu); |
203 } | 205 } |
204 this->unref(gpu); | |
205 } | 206 } |
206 | 207 |
207 private: | 208 private: |
208 virtual void onRecycle(GrVkGpu* gpu) const = 0; | 209 virtual void onRecycle(GrVkGpu* gpu) const = 0; |
209 }; | 210 }; |
210 | 211 |
211 #endif | 212 #endif |
OLD | NEW |