Index: src/gpu/SkGrPixelRef.cpp |
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp |
index fed07c43352854b30e5dfeccdaafc2dab891458a..fcf22e350b02aef0ab2b2924775993d7f9c14977 100644 |
--- a/src/gpu/SkGrPixelRef.cpp |
+++ b/src/gpu/SkGrPixelRef.cpp |
@@ -101,7 +101,8 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface) : INHERITED(info) { |
+SkGrPixelRef::SkGrPixelRef(const SkImageInfo& info, GrSurface* surface, |
+ bool transferCacheLock) : INHERITED(info) { |
// For surfaces that are both textures and render targets, the texture owns the |
// render target but not vice versa. So we ref the texture to keep both alive for |
// the lifetime of this pixel ref. |
@@ -109,6 +110,7 @@ |
if (NULL == fSurface) { |
fSurface = SkSafeRef(surface); |
} |
+ fUnlock = transferCacheLock; |
if (fSurface) { |
SkASSERT(info.width() <= fSurface->width()); |
@@ -117,6 +119,13 @@ |
} |
SkGrPixelRef::~SkGrPixelRef() { |
+ if (fUnlock) { |
+ GrContext* context = fSurface->getContext(); |
+ GrTexture* texture = fSurface->asTexture(); |
+ if (context && texture) { |
+ context->unlockScratchTexture(texture); |
+ } |
+ } |
SkSafeUnref(fSurface); |
} |