Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: src/gpu/GrGpuResource.cpp

Issue 707493002: Use GrResourceCache2 to service content key lookups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move #ifdef SK_SUPPORT_GPU Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpuResource.cpp
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 705cdea4245984f025ae45fd01efc81fb801fe39..b77acffc68c69599a8f58ac910b86c7134832aae 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -78,6 +78,24 @@ 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;
+ }
+
+ 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 +110,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 +118,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() {
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698