8#ifndef GrRefCnt_DEFINED
9#define GrRefCnt_DEFINED
22template <
typename T, auto Ref, auto Unref>
class gr_sp {
24 static inline T* SafeRef(
T* obj) {
31 static inline void SafeUnref(
T* obj) {
40 constexpr gr_sp() : fPtr(nullptr) {}
41 constexpr gr_sp(std::nullptr_t) : fPtr(nullptr) {}
72 explicit gr_sp(
T* obj) : fPtr(obj) {}
114 this->
reset(that.release());
124 this->
reset(SafeRef(that.get()));
133 explicit operator bool()
const {
return this->
get() !=
nullptr; }
135 T*
get()
const {
return fPtr; }
154 [[nodiscard]]
T* release() {
gr_rp< T > gr_ref_rp(T *obj)
static T * SkSafeRef(T *obj)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
gr_sp & operator=(gr_sp< T, Ref, Unref > &&that)
gr_sp(const gr_sp< T, Ref, Unref > &that)
gr_sp & operator=(sk_sp< T > &&that)
void reset(T *ptr=nullptr)
gr_sp(gr_sp< T, Ref, Unref > &&that)
gr_sp & operator=(const gr_sp< T, Ref, Unref > &that)
gr_sp(const sk_sp< T > &that)
gr_sp(const gr_sp< U, Ref, Unref > &that)
gr_sp & operator=(const sk_sp< T > &that)
gr_sp & operator=(std::nullptr_t)
constexpr gr_sp(std::nullptr_t)