28 : fGpu(gpu), fUniqueID(CreateUniqueID()), fLabel(label) {
45 fRefsWrappedObjects =
true;
54void GrGpuResource::release() {
62void GrGpuResource::abandon() {
84 const char*
type,
size_t size)
const {
85 const char* tag =
"Scratch";
87 tag = (fUniqueKey.
tag() !=
nullptr) ? fUniqueKey.
tag() :
"Other";
94 if (this->isPurgeable()) {
104bool GrGpuResource::isPurgeable()
const {
107 return !this->hasRef() &&
108 this->hasNoCommandBufferUsages() &&
112bool GrGpuResource::hasRef()
const {
return this->
internalHasRef(); }
114bool GrGpuResource::hasNoCommandBufferUsages()
const {
120 SkString resourceName(
"skia/gpu_resources/resource_");
141void GrGpuResource::removeUniqueKey() {
158 !this->fRefsWrappedObjects) {
169void GrGpuResource::notifyARefCntIsZero(LastRemovedRef removedRef)
const {
171 if (this->hasNoCommandBufferUsages() && !this->hasRef()) {
183void GrGpuResource::removeScratchKey() {
190void GrGpuResource::makeBudgeted() {
202void GrGpuResource::makeUnbudgeted() {
211 static std::atomic<uint32_t> nextID{1};
214 id = nextID.fetch_add(1, std::memory_order_relaxed);
223 cache->resourceAccess().refResource(fResource);
static GrResourceCache * get_resource_cache(GrGpu *gpu)
static constexpr uint32_t SK_InvalidUniqueID
GrResourceCache * getResourceCache()
GrDirectContextPriv priv()
virtual void computeScratchKey(skgpu::ScratchKey *) const
std::string getLabel() const
size_t gpuMemorySize() const
void dumpMemoryStatisticsPriv(SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
const GrDirectContext * getContext() const
UniqueID uniqueID() const
virtual void dumpMemoryStatistics(SkTraceMemoryDump *traceMemoryDump) const
bool wasDestroyed() const
SkString getResourceName() const
GrGpuResource(GrGpu *, std::string_view label)
virtual const char * getResourceType() const =0
void registerWithCacheWrapped(GrWrapCacheable)
virtual void setMemoryBacking(SkTraceMemoryDump *, const SkString &) const
static uint32_t CreateUniqueID()
void registerWithCache(skgpu::Budgeted)
ResourcePriv resourcePriv()
GrDirectContext * getContext()
bool internalHasNoCommandBufferUsages() const
bool internalHasRef() const
ResourceAccess resourceAccess()
void appendU32(uint32_t value)
const char * c_str() const
virtual void dumpWrappedState(const char *, bool)
virtual void dumpStringValue(const char *, const char *, const char *)
virtual bool shouldDumpWrappedObjects() const
virtual void dumpNumericValue(const char *dumpName, const char *valueName, const char *units, uint64_t value)=0