Fix texture ref/unref bug in GrContext::createResizedTexture
https://codereview.appspot.com/6500107/
git-svn-id: http://skia.googlecode.com/svn/trunk@5502 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b9314c8..9e2e014 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -280,17 +280,18 @@
void* srcData,
size_t rowBytes,
bool needsFiltering) {
- SkAutoTUnref<GrTexture> clampedTexture(this->findTexture(desc, cacheData, NULL));
-
+ GrTexture* clampedTexture = this->findTexture(desc, cacheData, NULL);
if (NULL == clampedTexture) {
- clampedTexture.reset(
- this->createTexture(NULL, desc, cacheData, srcData, rowBytes));
+ clampedTexture = this->createTexture(NULL, desc, cacheData, srcData, rowBytes);
GrAssert(NULL != clampedTexture);
if (NULL == clampedTexture) {
return NULL;
}
}
+
+ clampedTexture->ref();
+
GrTextureDesc rtDesc = desc;
rtDesc.fFlags = rtDesc.fFlags |
kRenderTarget_GrTextureFlagBit |
@@ -352,6 +353,7 @@
GrAssert(NULL != texture);
}
+ clampedTexture->unref();
return texture;
}