Don't readback and reupload texture-backed bitmaps
Review URL: https://codereview.chromium.org/635573004
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index e81abdb..262d339 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -372,7 +372,10 @@
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 @@
void GrUnlockAndUnrefCachedBitmapTexture(GrTexture* texture) {
SkASSERT(texture->getContext());
- texture->getContext()->unlockScratchTexture(texture);
+ if (texture->getCacheEntry()) {
+ texture->getContext()->unlockScratchTexture(texture);
+ }
texture->unref();
}