| 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 |
| 11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
| 12 #include "SkTDynamicHash.h" | 12 #include "SkTDynamicHash.h" |
| 13 #include "SkRandom.h" | 13 #include "SkRandom.h" |
| 14 | 14 |
| 15 class GrVkGpu; | 15 class GrVkGpu; |
| 16 | 16 |
| 17 // uncomment to enable tracing of resource refs | 17 // uncomment to enable tracing of resource refs |
| 18 //#ifdef SK_DEBUG | 18 #ifdef SK_DEBUG |
| 19 //#define SK_TRACE_VK_RESOURCES | 19 #define SK_TRACE_VK_RESOURCES |
| 20 //#endif | 20 #endif |
| 21 | 21 |
| 22 /** \class GrVkResource | 22 /** \class GrVkResource |
| 23 | 23 |
| 24 GrVkResource is the base class for Vulkan resources that may be shared by mult
iple | 24 GrVkResource is the base class for Vulkan resources that may be shared by mult
iple |
| 25 objects. When an existing owner wants to share a reference, it calls ref(). | 25 objects. When an existing owner wants to share a reference, it calls ref(). |
| 26 When an owner wants to release its reference, it calls unref(). When the | 26 When an owner wants to release its reference, it calls unref(). When the |
| 27 shared object's reference count goes to zero as the result of an unref() | 27 shared object's reference count goes to zero as the result of an unref() |
| 28 call, its (virtual) destructor is called. It is an error for the | 28 call, its (virtual) destructor is called. It is an error for the |
| 29 destructor to be called explicitly (or via the object going out of scope on | 29 destructor to be called explicitly (or via the object going out of scope on |
| 30 the stack or calling delete) if getRefCnt() > 1. | 30 the stack or calling delete) if getRefCnt() > 1. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 this->internal_dispose(); | 114 this->internal_dispose(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 #ifdef SK_DEBUG | 118 #ifdef SK_DEBUG |
| 119 void validate() const { | 119 void validate() const { |
| 120 SkASSERT(fRefCnt > 0); | 120 SkASSERT(fRefCnt > 0); |
| 121 } | 121 } |
| 122 #endif | 122 #endif |
| 123 | 123 |
| 124 #ifdef SK_TRACE_VK_RESOURCES |
| 125 /** Output a human-readable dump of this resource's information |
| 126 */ |
| 127 virtual void dumpInfo() const = 0; |
| 128 #endif |
| 129 |
| 124 private: | 130 private: |
| 125 /** Must be implemented by any subclasses. | 131 /** Must be implemented by any subclasses. |
| 126 * Deletes any Vk data associated with this resource | 132 * Deletes any Vk data associated with this resource |
| 127 */ | 133 */ |
| 128 virtual void freeGPUData(const GrVkGpu* gpu) const = 0; | 134 virtual void freeGPUData(const GrVkGpu* gpu) const = 0; |
| 129 | 135 |
| 130 /** Must be overridden by subclasses that themselves store GrVkResources. | 136 /** Must be overridden by subclasses that themselves store GrVkResources. |
| 131 * Will unrefAndAbandon those resources without deleting the underlying Vk
data | 137 * Will unrefAndAbandon those resources without deleting the underlying Vk
data |
| 132 */ | 138 */ |
| 133 virtual void abandonSubResources() const {} | 139 virtual void abandonSubResources() const {} |
| (...skipping 27 matching lines...) Expand all Loading... |
| 161 mutable int32_t fRefCnt; | 167 mutable int32_t fRefCnt; |
| 162 #ifdef SK_TRACE_VK_RESOURCES | 168 #ifdef SK_TRACE_VK_RESOURCES |
| 163 uint32_t fKey; | 169 uint32_t fKey; |
| 164 #endif | 170 #endif |
| 165 | 171 |
| 166 typedef SkNoncopyable INHERITED; | 172 typedef SkNoncopyable INHERITED; |
| 167 }; | 173 }; |
| 168 | 174 |
| 169 | 175 |
| 170 #endif | 176 #endif |
| OLD | NEW |