Make the SkGrPixelRef be responsible for unlocking device's scratch texture in the cache
Review URL: https://codereview.appspot.com/6498046/
git-svn-id: http://skia.googlecode.com/svn/trunk@5313 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index 05c3f02..b7a0765 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -88,7 +88,7 @@
///////////////////////////////////////////////////////////////////////////////
-SkGrPixelRef::SkGrPixelRef(GrSurface* surface) {
+SkGrPixelRef::SkGrPixelRef(GrSurface* surface, bool transferCacheLock) {
// TODO: figure out if this is responsible for Chrome canvas errors
#if 0
// The GrTexture has a ref to the GrRenderTarget but not vice versa.
@@ -101,11 +101,18 @@
if (NULL == fSurface) {
fSurface = surface;
}
-
+ fUnlock = transferCacheLock;
GrSafeRef(surface);
}
SkGrPixelRef::~SkGrPixelRef() {
+ if (fUnlock) {
+ GrContext* context = fSurface->getContext();
+ GrTexture* texture= fSurface->asTexture();
+ if (NULL != context && NULL != texture) {
+ context->unlockTexture(texture);
+ }
+ }
GrSafeUnref(fSurface);
}