Chromium Code Reviews| Index: src/gpu/GrContext.cpp |
| diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
| index a722eed88ac5cac8a663adbe9f7fc14ac1d6315d..6060870ec3fa8c5f972424fac81c4ec820d45e06 100755 |
| --- a/src/gpu/GrContext.cpp |
| +++ b/src/gpu/GrContext.cpp |
| @@ -448,9 +448,8 @@ GrTexture* GrContext::createNewScratchTexture(const GrTextureDesc& desc) { |
| return texture; |
| } |
| -GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, ScratchTexMatch match, |
| - bool calledDuringFlush) { |
| - |
| +GrTexture* GrContext::refScratchTexture(const GrTextureDesc& inDesc, ScratchTexMatch match, |
| + bool calledDuringFlush) { |
| // kNoStencil has no meaning if kRT isn't set. |
| SkASSERT((inDesc.fFlags & kRenderTarget_GrTextureFlagBit) || |
| !(inDesc.fFlags & kNoStencil_GrTextureFlagBit)); |
| @@ -1288,17 +1287,14 @@ bool GrContext::readTexturePixels(GrTexture* texture, |
| // TODO: make this more efficient for cases where we're reading the entire |
| // texture, i.e., use GetTexImage() instead |
| - // create scratch rendertarget and read from that |
| - GrAutoScratchTexture ast; |
| GrTextureDesc desc; |
| desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| desc.fWidth = width; |
| desc.fHeight = height; |
| desc.fConfig = config; |
| desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| - ast.set(this, desc, kExact_ScratchTexMatch); |
| - GrTexture* dst = ast.texture(); |
| - if (dst && (target = dst->asRenderTarget())) { |
| + SkAutoTUnref<GrTexture> dst(this->refScratchTexture(desc, kExact_ScratchTexMatch)); |
| + if (dst) { |
|
robertphillips
2014/10/09 17:19:50
target = dst->asRenderTarget(); ?
bsalomon
2014/10/13 15:42:02
this code was removed.
|
| this->copySurface(target, texture, SkIRect::MakeXYWH(top, left, width, height), |
| SkIPoint::Make(0,0)); |
| return this->readRenderTargetPixels(target, |
| @@ -1372,7 +1368,6 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, |
| // conversions in the draw we set the corresponding bool to false so that we don't reapply it |
| // on the read back pixels. |
| GrTexture* src = target->asTexture(); |
| - GrAutoScratchTexture ast; |
| if (src && (swapRAndB || unpremul || flipY)) { |
| // Make the scratch a render target because we don't have a robust readTexturePixels as of |
| // yet. It calls this function. |
| @@ -1395,8 +1390,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, |
| fGpu->fullReadPixelsIsFasterThanPartial()) { |
| match = kExact_ScratchTexMatch; |
| } |
| - ast.set(this, desc, match); |
| - GrTexture* texture = ast.texture(); |
| + SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, match)); |
| if (texture) { |
| // compute a matrix to perform the draw |
| SkMatrix textureMatrix; |
| @@ -1564,9 +1558,8 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* renderTarget, |
| desc.fWidth = width; |
| desc.fHeight = height; |
| desc.fConfig = writeConfig; |
| - GrAutoScratchTexture ast(this, desc); |
| - GrTexture* texture = ast.texture(); |
| - if (NULL == texture) { |
| + SkAutoTUnref<GrTexture> texture(this->refScratchTexture(desc, kApprox_ScratchTexMatch)); |
| + if (!texture) { |
| return false; |
| } |