Chromium Code Reviews| Index: src/gpu/GrGpuResource.cpp |
| diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp |
| index 705cdea4245984f025ae45fd01efc81fb801fe39..72a9a2ad5060c1c25a0d58f760feed1e3159b14e 100644 |
| --- a/src/gpu/GrGpuResource.cpp |
| +++ b/src/gpu/GrGpuResource.cpp |
| @@ -78,6 +78,25 @@ GrContext* GrGpuResource::getContext() { |
| } |
| } |
| +bool GrGpuResource::setCacheEntry(GrResourceCacheEntry* cacheEntry) { |
| + // GrResourceCache never changes the cacheEntry once one has been added. |
| + SkASSERT(NULL == cacheEntry || NULL == fCacheEntry); |
| + |
| + fCacheEntry = cacheEntry; |
| + if (this->wasDestroyed() || NULL == cacheEntry) { |
| + return true; |
| + } |
| + |
|
robertphillips
2014/11/07 20:32:13
Delete this next line ?
bsalomon
2014/11/07 21:48:44
Done.
|
| + fCacheEntry = cacheEntry; |
| + if (!cacheEntry->key().isScratch()) { |
| + if (!get_resource_cache2(fGpu)->didAddContentKey(this)) { |
| + fCacheEntry = NULL; |
| + return false; |
| + } |
| + } |
| + return true; |
| +} |
| + |
| void GrGpuResource::notifyIsPurgable() const { |
| if (fCacheEntry && !this->wasDestroyed()) { |
| get_resource_cache(fGpu)->notifyPurgable(this); |
| @@ -92,6 +111,7 @@ void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { |
| } |
| const GrResourceKey* GrGpuResource::getContentKey() const { |
| + // Currently scratch resources have a cache entry in GrResourceCache with a scratch key. |
| if (fCacheEntry && !fCacheEntry->key().isScratch()) { |
| return &fCacheEntry->key(); |
| } |
| @@ -99,8 +119,8 @@ const GrResourceKey* GrGpuResource::getContentKey() const { |
| } |
| bool GrGpuResource::isScratch() const { |
| - // Currently scratch resources have a cache entry in GrResourceCache with a scratch key. |
| - return NULL != fCacheEntry && fCacheEntry->key().isScratch(); |
| + SkASSERT(fScratchKey.isScratch()); |
| + return NULL == this->getContentKey() && !fScratchKey.isNullScratch(); |
| } |
| uint32_t GrGpuResource::CreateUniqueID() { |