Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 98adf1d667df87ac278de9c3225e17f53fdccfcd..b7674c77f6974caf98b51d5db150e02b6112c2ed 100755 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -266,8 +266,12 @@ GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc, |
const GrTextureParams* params) { |
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID); |
GrGpuResource* resource = fResourceCache->find(resourceKey); |
- SkSafeRef(resource); |
- return static_cast<GrTexture*>(resource); |
+ if (resource) { |
+ resource->ref(); |
+ return static_cast<GrSurface*>(resource)->asTexture(); |
+ } else { |
+ return NULL; |
+ } |
} |
bool GrContext::isTextureInCache(const GrSurfaceDesc& desc, |
@@ -481,7 +485,7 @@ GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexM |
GrGpuResource* resource = fResourceCache2->findAndRefScratchResource(key, scratchFlags); |
if (resource) { |
fResourceCache->makeResourceMRU(resource); |
- return static_cast<GrTexture*>(resource); |
+ return static_cast<GrSurface*>(resource)->asTexture(); |
} |
if (kExact_ScratchTexMatch == match) { |