Revert of make getContentKey() available in GrGpuResource public interface (patchset #2 id:20001 of https://codereview.chromium.org/886313005/)

Reason for revert:
This causes in one case the linker and in the other the compiler to segfault. On

Test-Ubuntu12-ShuttleA-GTX660-x86_64-Debug/Release

Original issue's description:
> make getContentKey() available in GrGpuResource public interface
>
> TBR=robertphillips@google.com
>
> Committed: https://skia.googlesource.com/skia/+/85ed2db092e75db41b711b9116a8d5b465fc2b0c

TBR=robertphillips@google.com,bsalomon@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/864343005
This commit is contained in:
stephana 2015-02-02 14:52:11 -08:00 committed by Commit bot
parent 85ed2db092
commit 9b440260d5
4 changed files with 16 additions and 15 deletions

View File

@ -188,10 +188,6 @@ public:
*/
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).

View File

@ -33,7 +33,7 @@ public:
* key, and does not have a content key.
*/
bool isScratch() const {
return !fResource->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
return !this->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
this->isBudgeted();
}
@ -50,6 +50,11 @@ public:
*/
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?
*/
@ -60,7 +65,7 @@ public:
*/
bool isBudgeted() const {
bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
SkASSERT(ret || !fResource->getContentKey().isValid());
SkASSERT(ret || !this->getContentKey().isValid());
return ret;
}

View File

@ -132,8 +132,8 @@ void GrResourceCache2::removeResource(GrGpuResource* resource) {
if (resource->cacheAccess().getScratchKey().isValid()) {
fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
}
if (resource->getContentKey().isValid()) {
fContentHash.remove(resource->getContentKey());
if (resource->cacheAccess().getContentKey().isValid()) {
fContentHash.remove(resource->cacheAccess().getContentKey());
}
this->validate();
}
@ -225,9 +225,9 @@ bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) {
SkASSERT(!fPurging);
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
SkASSERT(resource->getContentKey().isValid());
SkASSERT(resource->cacheAccess().getContentKey().isValid());
GrGpuResource* res = fContentHash.find(resource->getContentKey());
GrGpuResource* res = fContentHash.find(resource->cacheAccess().getContentKey());
if (NULL != res) {
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.
bool noKey = !resource->cacheAccess().getScratchKey().isValid() &&
!resource->getContentKey().isValid();
!resource->cacheAccess().getContentKey().isValid();
if (overBudget || noKey) {
release = true;
}
@ -435,18 +435,18 @@ void GrResourceCache2::validate() const {
}
if (resource->cacheAccess().isScratch()) {
SkASSERT(!resource->getContentKey().isValid());
SkASSERT(!resource->cacheAccess().getContentKey().isValid());
++scratch;
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
} else if (resource->cacheAccess().getScratchKey().isValid()) {
SkASSERT(!resource->cacheAccess().isBudgeted() ||
resource->getContentKey().isValid());
resource->cacheAccess().getContentKey().isValid());
++couldBeScratch;
SkASSERT(fScratchMap.countForKey(resource->cacheAccess().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
}
const GrContentKey& contentKey = resource->getContentKey();
const GrContentKey& contentKey = resource->cacheAccess().getContentKey();
if (contentKey.isValid()) {
++content;
SkASSERT(fContentHash.find(contentKey) == resource);

View File

@ -194,7 +194,7 @@ private:
struct ContentHashTraits {
static const GrContentKey& GetKey(const GrGpuResource& r) {
return r.getContentKey();
return r.cacheAccess().getContentKey();
}
static uint32_t Hash(const GrContentKey& key) { return key.hash(); }