Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: src/gpu/GrContext.cpp

Issue 1258673009: Don't read from unref'ed RT in GrContext::readSurfacePixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 9077bc0d054c86a19ed09036b643688700905a74..6b7f5528954e5161c6f89640f6608f55240ca4c0 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -484,7 +484,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
return false;
}
- GrRenderTarget* rtToRead = src->asRenderTarget();
+ SkAutoTUnref<GrRenderTarget> rtToRead(SkSafeRef(src->asRenderTarget()));
bool didTempDraw = false;
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
GrTextureProvider::ScratchTexMatch match = GrTextureProvider::kApprox_ScratchTexMatch;
@@ -496,7 +496,8 @@ bool GrContext::readSurfacePixels(GrSurface* src,
}
}
SkAutoTUnref<GrTexture> temp;
- temp.reset(this->textureProvider()->refScratchTexture(tempDrawInfo.fTempSurfaceDesc, match));
+ temp.reset(this->textureProvider()->refScratchTexture(tempDrawInfo.fTempSurfaceDesc,
+ match));
if (temp) {
SkMatrix textureMatrix;
textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
@@ -526,7 +527,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
GrDrawContext* drawContext = this->drawContext();
drawContext->drawRect(temp->asRenderTarget(), GrClip::WideOpen(), paint,
SkMatrix::I(), rect, NULL);
- rtToRead = temp->asRenderTarget();
+ rtToRead.reset(SkRef(temp->asRenderTarget()));
left = 0;
top = 0;
didTempDraw = true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698