void GrGpuResource::release() { SkASSERT(fGpu); this->onRelease(); get_resource_cache(fGpu)->resourceAccess().removeResource(this); fGpu = nullptr; fGpuMemorySize = 0; }
void GrGpuResource::makeUnbudgeted() { if (!this->wasDestroyed() && GrGpuResource::kCached_LifeCycle == fLifeCycle && !fUniqueKey.isValid()) { fLifeCycle = kUncached_LifeCycle; get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this); } }
void GrGpuResource::removeUniqueKey() { if (this->wasDestroyed()) { return; } SkASSERT(fUniqueKey.isValid()); get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this); }
void GrGpuResource::abandon() { SkASSERT(fGpu); this->onAbandon(); get_resource_cache(fGpu)->resourceAccess().removeResource(this); fGpu = NULL; fGpuMemorySize = 0; }
void GrGpuResource::notifyIsPurgeable() const { if (this->wasDestroyed()) { // We've already been removed from the cache. Goodbye cruel world! SkDELETE(this); } else { GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); get_resource_cache(fGpu)->resourceAccess().notifyPurgeable(mutableThis); } }
void GrGpuResource::didChangeGpuMemorySize() const { if (this->wasDestroyed()) { return; } size_t oldSize = fGpuMemorySize; SkASSERT(kInvalidGpuMemorySize != oldSize); fGpuMemorySize = kInvalidGpuMemorySize; get_resource_cache(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize); }
void GrGpuResource::abandon() { if (this->wasDestroyed()) { return; } SkASSERT(fGpu); this->onAbandon(); get_resource_cache(fGpu)->resourceAccess().removeResource(this); fGpu = nullptr; fGpuMemorySize = 0; }
void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const { if (this->wasDestroyed()) { // We've already been removed from the cache. Goodbye cruel world! delete this; return; } // We should have already handled this fully in notifyRefCntIsZero(). SkASSERT(kRef_CntType != lastCntTypeToReachZero); GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); static const uint32_t kFlag = GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag; get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, kFlag); }
void GrGpuResource::setUniqueKey(const GrUniqueKey& key) { SkASSERT(this->internalHasRef()); SkASSERT(key.isValid()); // Wrapped and uncached resources can never have a unique key. if (SkBudgeted::kNo == this->resourcePriv().isBudgeted()) { return; } if (this->wasDestroyed()) { return; } get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key); }
bool GrGpuResource::notifyRefCountIsZero() const { if (this->wasDestroyed()) { // handle this in notifyAllCntsAreZero(). return true; } GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this); uint32_t flags = GrResourceCache::ResourceAccess::kRefCntReachedZero_RefNotificationFlag; if (!this->internalHasPendingIO()) { flags |= GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag; } get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, flags); // There is no need to call our notifyAllCntsAreZero function at this point since we already // told the cache about the state of cnts. return false; }
void GrGpuResource::registerWithCache() { get_resource_cache(fGpu)->resourceAccess().insertResource(this); }
void GrGpuResource::makeBudgeted() { if (!this->wasDestroyed() && GrGpuResource::kUncached_LifeCycle == fLifeCycle) { fLifeCycle = kCached_LifeCycle; get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this); } }
void GrGpuResource::removeScratchKey() { if (!this->wasDestroyed() && fScratchKey.isValid()) { get_resource_cache(fGpu)->resourceAccess().willRemoveScratchKey(this); fScratchKey.reset(); } }
void GrGpuResource::removeUniqueKey() { SkASSERT(fUniqueKey.isValid()); get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this); }