8#ifndef GrManagedResource_DEFINED
9#define GrManagedResource_DEFINED
21#define SK_TRACE_MANAGED_RESOURCES
42#ifdef SK_TRACE_MANAGED_RESOURCES
75 static std::atomic<uint32_t> fKeyCounter;
81#ifdef SK_TRACE_MANAGED_RESOURCES
82 fKey = fKeyCounter.fetch_add(+1, std::memory_order_relaxed);
83 GetTrace()->add(
this);
91 auto count = this->getRefCnt();
99 int32_t getRefCnt()
const {
return fRefCnt.load(); }
109 return 1 == fRefCnt.load(std::memory_order_acquire);
117 SkDEBUGCODE(
int newRefCount = )fRefCnt.fetch_add(+1, std::memory_order_relaxed);
128 int newRefCount = fRefCnt.fetch_add(-1, std::memory_order_acq_rel);
130 if (newRefCount == 1) {
133 this->internal_dispose();
145 void validate()
const {
150#ifdef SK_TRACE_MANAGED_RESOURCES
153 virtual void dumpInfo()
const = 0;
157#ifdef SK_TRACE_MANAGED_RESOURCES
158 static Trace* GetTrace() {
172 void internal_dispose()
const {
174#ifdef SK_TRACE_MANAGED_RESOURCES
175 GetTrace()->remove(
this);
185 mutable std::atomic<int32_t> fRefCnt;
186#ifdef SK_TRACE_MANAGED_RESOURCES
#define SkASSERTF(cond, fmt,...)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
virtual ~GrManagedResource()
virtual void freeGPUData() const =0
virtual void onRecycle() const =0
void setRelease(sk_sp< GrSurface::RefCntedReleaseProc > releaseHelper)
sk_sp< GrSurface::RefCntedReleaseProc > fReleaseHelper
void invokeReleaseProc() const
~GrTextureResource() override
void reset(T *ptr=nullptr)
static uint32_t Hash(uint32_t key)