diff options
author | bsalomon <bsalomon@google.com> | 2014-11-14 11:31:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-14 11:31:13 -0800 |
commit | 191bcc008ea6b4cc445e105f6d36cbc057246e29 (patch) | |
tree | 34cb20645ad53ee442e88babfc049fdae6ba2f48 | |
parent | c87dd2ce965cd1bbc8a74abe0c141658a469d7f2 (diff) |
Fix ref-cnting bug in GrContext::readRenderTargetPixels
TBR=egdaniel@google.com
NOTRY=true
Review URL: https://codereview.chromium.org/732713002
-rwxr-xr-x | src/gpu/GrContext.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 3a93404af1..886a68a109 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1428,6 +1428,8 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, return false; } + SkAutoTUnref<GrTexture> tempTexture; + // If the src is a texture and we would have to do conversions after read pixels, we instead // do the conversions by drawing the src to a scratch texture. If we handle any of the // conversions in the draw we set the corresponding bool to false so that we don't reapply it @@ -1454,8 +1456,8 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, fGpu->fullReadPixelsIsFasterThanPartial()) { match = kExact_ScratchTexMatch; } - SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, match)); - if (texture) { + tempTexture.reset(this->refScratchTexture(desc, match)); + if (tempTexture) { // compute a matrix to perform the draw SkMatrix textureMatrix; textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top); @@ -1488,13 +1490,13 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, SkASSERT(fp); drawState->addColorProcessor(fp); - drawState->setRenderTarget(texture->asRenderTarget()); + drawState->setRenderTarget(tempTexture->asRenderTarget()); SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); fDrawBuffer->drawSimpleRect(rect); // we want to read back from the scratch's origin left = 0; top = 0; - target = texture->asRenderTarget(); + target = tempTexture->asRenderTarget(); } this->flushSurfaceWrites(target); } |