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

Unified Diff: src/gpu/GrContext.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/core/SkTMultiMap.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 83ef58f3debb4c6d642068c249d2431d0bba4ee7..6f9395b5c3b3662fc2a45f49f5e4618742732fa8 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -255,20 +255,20 @@ GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) {
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
- GrGpuResource* resource = fResourceCache->find(resourceKey);
+
+ GrGpuResource* resource = this->findAndRefCachedResource(resourceKey);
if (resource) {
- resource->ref();
+ SkASSERT(static_cast<GrSurface*>(resource)->asTexture());
return static_cast<GrSurface*>(resource)->asTexture();
- } else {
- return NULL;
}
+ return NULL;
}
bool GrContext::isTextureInCache(const GrSurfaceDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) const {
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
- return fResourceCache->hasKey(resourceKey);
+ return fResourceCache2->hasContentKey(resourceKey);
}
void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
@@ -280,12 +280,9 @@ void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
fResourceCache->addResource(resourceKey, sb);
}
-GrStencilBuffer* GrContext::findStencilBuffer(int width, int height,
- int sampleCnt) {
- GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width,
- height,
- sampleCnt);
- GrGpuResource* resource = fResourceCache->find(resourceKey);
+GrStencilBuffer* GrContext::findAndRefStencilBuffer(int width, int height, int sampleCnt) {
+ GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, height, sampleCnt);
+ GrGpuResource* resource = this->findAndRefCachedResource(resourceKey);
return static_cast<GrStencilBuffer*>(resource);
}
@@ -1755,8 +1752,10 @@ void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResour
}
GrGpuResource* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKey) {
- GrGpuResource* resource = fResourceCache->find(resourceKey);
- SkSafeRef(resource);
+ GrGpuResource* resource = fResourceCache2->findAndRefContentResource(resourceKey);
+ if (resource) {
+ fResourceCache->makeResourceMRU(resource);
+ }
return resource;
}
« no previous file with comments | « src/core/SkTMultiMap.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698