make getContentKey() available in GrGpuResource public interface
TBR=robertphillips@google.com Review URL: https://codereview.chromium.org/886313005
This commit is contained in:
parent
e67164d9b3
commit
85ed2db092
@ -188,6 +188,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint32_t getUniqueID() const { return fUniqueID; }
|
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
|
* 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).
|
* for the lifetime of this resource (until it is abandoned or released).
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
* key, and does not have a content key.
|
* key, and does not have a content key.
|
||||||
*/
|
*/
|
||||||
bool isScratch() const {
|
bool isScratch() const {
|
||||||
return !this->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
|
return !fResource->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
|
||||||
this->isBudgeted();
|
this->isBudgeted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,11 +50,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void removeScratchKey() const { fResource->removeScratchKey(); }
|
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?
|
* Is the resource object wrapping an externally allocated GPU resource?
|
||||||
*/
|
*/
|
||||||
@ -65,7 +60,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isBudgeted() const {
|
bool isBudgeted() const {
|
||||||
bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
|
bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
|
||||||
SkASSERT(ret || !this->getContentKey().isValid());
|
SkASSERT(ret || !fResource->getContentKey().isValid());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ void GrResourceCache2::removeResource(GrGpuResource* resource) {
|
|||||||
if (resource->cacheAccess().getScratchKey().isValid()) {
|
if (resource->cacheAccess().getScratchKey().isValid()) {
|
||||||
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
|
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
|
||||||
}
|
}
|
||||||
if (resource->cacheAccess().getContentKey().isValid()) {
|
if (resource->getContentKey().isValid()) {
|
||||||
fContentHash.remove(resource->cacheAccess().getContentKey());
|
fContentHash.remove(resource->getContentKey());
|
||||||
}
|
}
|
||||||
this->validate();
|
this->validate();
|
||||||
}
|
}
|
||||||
@ -225,9 +225,9 @@ bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) {
|
|||||||
SkASSERT(!fPurging);
|
SkASSERT(!fPurging);
|
||||||
SkASSERT(resource);
|
SkASSERT(resource);
|
||||||
SkASSERT(this->isInCache(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) {
|
if (NULL != res) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ void GrResourceCache2::notifyPurgeable(GrGpuResource* resource) {
|
|||||||
|
|
||||||
// Also purge if the resource has neither a valid scratch key nor a content key.
|
// Also purge if the resource has neither a valid scratch key nor a content key.
|
||||||
bool noKey = !resource->cacheAccess().getScratchKey().isValid() &&
|
bool noKey = !resource->cacheAccess().getScratchKey().isValid() &&
|
||||||
!resource->cacheAccess().getContentKey().isValid();
|
!resource->getContentKey().isValid();
|
||||||
if (overBudget || noKey) {
|
if (overBudget || noKey) {
|
||||||
release = true;
|
release = true;
|
||||||
}
|
}
|
||||||
@ -435,18 +435,18 @@ void GrResourceCache2::validate() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resource->cacheAccess().isScratch()) {
|
if (resource->cacheAccess().isScratch()) {
|
||||||
SkASSERT(!resource->cacheAccess().getContentKey().isValid());
|
SkASSERT(!resource->getContentKey().isValid());
|
||||||
++scratch;
|
++scratch;
|
||||||
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
|
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
|
||||||
SkASSERT(!resource->cacheAccess().isWrapped());
|
SkASSERT(!resource->cacheAccess().isWrapped());
|
||||||
} else if (resource->cacheAccess().getScratchKey().isValid()) {
|
} else if (resource->cacheAccess().getScratchKey().isValid()) {
|
||||||
SkASSERT(!resource->cacheAccess().isBudgeted() ||
|
SkASSERT(!resource->cacheAccess().isBudgeted() ||
|
||||||
resource->cacheAccess().getContentKey().isValid());
|
resource->getContentKey().isValid());
|
||||||
++couldBeScratch;
|
++couldBeScratch;
|
||||||
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
|
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
|
||||||
SkASSERT(!resource->cacheAccess().isWrapped());
|
SkASSERT(!resource->cacheAccess().isWrapped());
|
||||||
}
|
}
|
||||||
const GrContentKey& contentKey = resource->cacheAccess().getContentKey();
|
const GrContentKey& contentKey = resource->getContentKey();
|
||||||
if (contentKey.isValid()) {
|
if (contentKey.isValid()) {
|
||||||
++content;
|
++content;
|
||||||
SkASSERT(fContentHash.find(contentKey) == resource);
|
SkASSERT(fContentHash.find(contentKey) == resource);
|
||||||
|
@ -194,7 +194,7 @@ private:
|
|||||||
|
|
||||||
struct ContentHashTraits {
|
struct ContentHashTraits {
|
||||||
static const GrContentKey& GetKey(const GrGpuResource& r) {
|
static const GrContentKey& GetKey(const GrGpuResource& r) {
|
||||||
return r.cacheAccess().getContentKey();
|
return r.getContentKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t Hash(const GrContentKey& key) { return key.hash(); }
|
static uint32_t Hash(const GrContentKey& key) { return key.hash(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user