Index: src/gpu/SkGr.cpp |
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp |
index e81abdbae475c14a3d99a17afed4601b6cad2a53..262d339b6c673763236b66fb8a4e318c7e02fecd 100644 |
--- a/src/gpu/SkGr.cpp |
+++ b/src/gpu/SkGr.cpp |
@@ -372,7 +372,10 @@ bool GrIsBitmapInCache(const GrContext* ctx, |
GrTexture* GrLockAndRefCachedBitmapTexture(GrContext* ctx, |
const SkBitmap& bitmap, |
const GrTextureParams* params) { |
- GrTexture* result = NULL; |
+ GrTexture* result = bitmap.getTexture(); |
+ if (result) { |
+ return SkRef(result); |
+ } |
bool cache = !bitmap.isVolatile(); |
@@ -400,7 +403,9 @@ GrTexture* GrLockAndRefCachedBitmapTexture(GrContext* ctx, |
void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) { |
SkASSERT(texture->getContext()); |
- texture->getContext()->unlockScratchTexture(texture); |
+ if (texture->getCacheEntry()) { |
+ texture->getContext()->unlockScratchTexture(texture); |
+ } |
texture->unref(); |
} |