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>
This commit is contained in:
Brian Salomon 2016-12-07 14:31:00 -05:00 committed by Skia Commit-Bot
parent fd87be8ffa
commit 5b7b49f6e1
2 changed files with 21 additions and 28 deletions

View File

@ -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)) {

View File

@ -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*);