diff options
author | 2016-12-07 14:31:00 -0500 | |
---|---|---|
committer | 2016-12-07 19:40:57 +0000 | |
commit | 5b7b49f6e1ec08cbbe2eb43bf95a984e33d50f55 (patch) | |
tree | 69db7314f675b58bc167c6f138625a6d9609cdc9 /src/gpu | |
parent | fd87be8ffadb37a18aa7217dfbafb9500ca11159 (diff) |
Rework GrRenderTargetOpList::setupDstReadIfNecessary.
Move the necessary check to the caller. This removes the GrPipelineBuilder
param which makes this useable with future GrDrawOps that can be recorded without one.
Rename to setupDstTexture(). This only is involved in the texture method of getting the
destination color to the XP.
Change-Id: I1b781da3d42586534470a23a572805ec939cb730
Reviewed-on: https://skia-review.googlesource.com/5645
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 33 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.h | 16 |
2 files changed, 21 insertions, 28 deletions
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 98fdc7fc6a..ce2f3a982c 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -96,26 +96,20 @@ void GrRenderTargetOpList::dump() const { } #endif -bool GrRenderTargetOpList::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder, - GrRenderTarget* rt, - const GrClip& clip, - const GrPipelineOptimizations& optimizations, - GrXferProcessor::DstTexture* dstTexture, - const SkRect& batchBounds) { +void GrRenderTargetOpList::setupDstTexture(GrRenderTarget* rt, + const GrClip& clip, + const SkRect& batchBounds, + GrXferProcessor::DstTexture* dstTexture) { SkRect bounds = batchBounds; bounds.outset(0.5f, 0.5f); - if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), optimizations)) { - return true; - } - if (this->caps()->textureBarrierSupport()) { if (GrTexture* rtTex = rt->asTexture()) { // The render target is a texture, so we can read from it directly in the shader. The XP // will be responsible to detect this situation and request a texture barrier. dstTexture->setTexture(sk_ref_sp(rtTex)); dstTexture->setOffset(0, 0); - return true; + return; } } @@ -127,9 +121,9 @@ bool GrRenderTargetOpList::setupDstReadIfNecessary(const GrPipelineBuilder& pipe if (!copyRect.intersect(drawIBounds)) { #ifdef SK_DEBUG GrCapsDebugf(this->caps(), "Missed an early reject. " - "Bailing on draw from setupDstReadIfNecessary.\n"); + "Bailing on draw from setupDstTexture.\n"); #endif - return false; + return; } // MSAA consideration: When there is support for reading MSAA samples in the shader we could @@ -149,13 +143,12 @@ bool GrRenderTargetOpList::setupDstReadIfNecessary(const GrPipelineBuilder& pipe if (!copy) { SkDebugf("Failed to create temporary copy of destination texture.\n"); - return false; + return; } SkIPoint dstPoint = {0, 0}; this->copySurface(copy.get(), rt, copyRect, dstPoint); dstTexture->setTexture(std::move(copy)); dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); - return true; } void GrRenderTargetOpList::prepareBatches(GrBatchFlushState* flushState) { @@ -337,10 +330,12 @@ void GrRenderTargetOpList::drawBatch(const GrPipelineBuilder& pipelineBuilder, return; } - if (!this->setupDstReadIfNecessary(pipelineBuilder, renderTargetContext->accessRenderTarget(), - clip, args.fOpts, - &args.fDstTexture, batch->bounds())) { - return; + if (pipelineBuilder.willXPNeedDstTexture(*this->caps(), args.fOpts)) { + this->setupDstTexture(renderTargetContext->accessRenderTarget(), clip, batch->bounds(), + &args.fDstTexture); + if (!args.fDstTexture.texture()) { + return; + } } if (!batch->installPipeline(args)) { diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 238a048413..c4c492802b 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -137,15 +137,13 @@ private: GrOp* recordBatch(GrOp*, const SkRect& clippedBounds); void forwardCombine(); - // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required - // but couldn't be made. Otherwise, returns true. This method needs to be protected because it - // needs to be accessed by GLPrograms to setup a correct drawstate - bool setupDstReadIfNecessary(const GrPipelineBuilder&, - GrRenderTarget*, - const GrClip&, - const GrPipelineOptimizations& optimizations, - GrXferProcessor::DstTexture*, - const SkRect& batchBounds); + // Makes a copy of the dst if it is necessary for the draw and returns the texture that should + // be used by GrXferProcessor to access the destination color. If the texture is nullptr then + // a texture copy could not be made. + void setupDstTexture(GrRenderTarget*, + const GrClip&, + const SkRect& batchBounds, + GrXferProcessor::DstTexture*); // Used only via GrRenderTargetContextPriv. void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTarget*); |