*/
uint32_t getUniqueID() const { return fUniqueID; }
+ /** Returns the current content key for the resource. It will be invalid if the resource has not
+ been cached by its contents. */
+ const GrContentKey& getContentKey() const { return fContentKey; }
+
/**
* Attach a custom data object to this resource. The data will remain attached
* for the lifetime of this resource (until it is abandoned or released).
* key, and does not have a content key.
*/
bool isScratch() const {
- return !this->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
+ return !fResource->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
this->isBudgeted();
}
void removeScratchKey() const { fResource->removeScratchKey(); }
/**
- * If the resource is currently cached by a content key, the key is returned, otherwise NULL.
- */
- const GrContentKey& getContentKey() const { return fResource->fContentKey; }
-
- /**
* Is the resource object wrapping an externally allocated GPU resource?
*/
bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResource->fLifeCycle; }
*/
bool isBudgeted() const {
bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
- SkASSERT(ret || !this->getContentKey().isValid());
+ SkASSERT(ret || !fResource->getContentKey().isValid());
return ret;
}
if (resource->cacheAccess().getScratchKey().isValid()) {
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
}
- if (resource->cacheAccess().getContentKey().isValid()) {
- fContentHash.remove(resource->cacheAccess().getContentKey());
+ if (resource->getContentKey().isValid()) {
+ fContentHash.remove(resource->getContentKey());
}
this->validate();
}
SkASSERT(!fPurging);
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
- SkASSERT(resource->cacheAccess().getContentKey().isValid());
+ SkASSERT(resource->getContentKey().isValid());
- GrGpuResource* res = fContentHash.find(resource->cacheAccess().getContentKey());
+ GrGpuResource* res = fContentHash.find(resource->getContentKey());
if (NULL != res) {
return false;
}
// Also purge if the resource has neither a valid scratch key nor a content key.
bool noKey = !resource->cacheAccess().getScratchKey().isValid() &&
- !resource->cacheAccess().getContentKey().isValid();
+ !resource->getContentKey().isValid();
if (overBudget || noKey) {
release = true;
}
}
if (resource->cacheAccess().isScratch()) {
- SkASSERT(!resource->cacheAccess().getContentKey().isValid());
+ SkASSERT(!resource->getContentKey().isValid());
++scratch;
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
} else if (resource->cacheAccess().getScratchKey().isValid()) {
SkASSERT(!resource->cacheAccess().isBudgeted() ||
- resource->cacheAccess().getContentKey().isValid());
+ resource->getContentKey().isValid());
++couldBeScratch;
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
}
- const GrContentKey& contentKey = resource->cacheAccess().getContentKey();
+ const GrContentKey& contentKey = resource->getContentKey();
if (contentKey.isValid()) {
++content;
SkASSERT(fContentHash.find(contentKey) == resource);