| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 mutable int32_t fRefCnt; | 186 mutable int32_t fRefCnt; |
| 187 #ifdef SK_TRACE_VK_RESOURCES | 187 #ifdef SK_TRACE_VK_RESOURCES |
| 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 |
| 195 class GrVkRecycledResource : public GrVkResource { |
| 196 public: |
| 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 |
| 199 // if the object is recycled it should be ref'd inside the onRecycle call. |
| 200 void recycle(GrVkGpu* gpu) const { |
| 201 if (this->unique()) { |
| 202 this->onRecycle(gpu); |
| 203 } |
| 204 this->unref(gpu); |
| 205 } |
| 206 |
| 207 private: |
| 208 virtual void onRecycle(GrVkGpu* gpu) const = 0; |
| 209 }; |
| 194 | 210 |
| 195 #endif | 211 #endif |
| OLD | NEW |