From: bsalomon Date: Thu, 10 Sep 2015 18:10:50 +0000 (-0700) Subject: Simplify installation of pipeling into GrDrawBatch in GrDrawTarget X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~917 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad792c1f39922a49c1e798311f47a9b3431eff32;p=platform%2Fupstream%2FlibSkiaSharp.git Simplify installation of pipeling into GrDrawBatch in GrDrawTarget R=joshualitt@google.com Review URL: https://codereview.chromium.org/1333943002 --- diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 84f1e92..85a9af4 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -51,7 +51,10 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, GrXferProcessor::DstTexture* dstTexture, - const SkRect* drawBounds) { + const SkRect& batchBounds) { + SkRect bounds = batchBounds; + bounds.outset(0.5f, 0.5f); + if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coveragePOI)) { return true; } @@ -71,20 +74,14 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil SkIRect copyRect; pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); - if (drawBounds) { - SkIRect drawIBounds; - drawBounds->roundOut(&drawIBounds); - if (!copyRect.intersect(drawIBounds)) { -#ifdef SK_DEBUG - GrCapsDebugf(fCaps, "Missed an early reject. " - "Bailing on draw from setupDstReadIfNecessary.\n"); -#endif - return false; - } - } else { + SkIRect drawIBounds; + bounds.roundOut(&drawIBounds); + if (!copyRect.intersect(drawIBounds)) { #ifdef SK_DEBUG - //SkDebugf("No dev bounds when dst copy is made.\n"); + GrCapsDebugf(fCaps, "Missed an early reject. " + "Bailing on draw from setupDstReadIfNecessary.\n"); #endif + return false; } // MSAA consideration: When there is support for reading MSAA samples in the shader we could @@ -96,7 +93,6 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil desc.fConfig = rt->config(); } - desc.fWidth = copyRect.width(); desc.fHeight = copyRect.height(); @@ -154,20 +150,11 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat return; } - // Batch bounds are tight, so for dev copies - // TODO move this into setupDstReadIfNecessary when paths are in batch - SkRect bounds = batch->bounds(); - bounds.outset(0.5f, 0.5f); - - GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, batch, &bounds, - this); - - if (!pipelineInfo.valid()) { - return; - } - if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { + GrPipeline::CreateArgs args; + if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) { return; } + this->recordBatch(batch); } @@ -282,13 +269,8 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); batch->setStencilSettings(stencilSettings); - GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, batch, - &batch->bounds(), this); - - if (!pipelineInfo.valid()) { - return; - } - if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { + GrPipeline::CreateArgs args; + if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) { return; } @@ -451,20 +433,26 @@ void GrDrawTarget::recordBatch(GrBatch* batch) { /////////////////////////////////////////////////////////////////////////////// -GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilder, - const GrScissorState* scissor, - const GrDrawBatch* batch, - const SkRect* devBounds, - GrDrawTarget* target) { - fArgs.fPipelineBuilder = pipelineBuilder; - fArgs.fCaps = target->caps(); - fArgs.fScissor = scissor; - fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(batch); - fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(batch); - if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPOI, - fArgs.fCoveragePOI, &fArgs.fDstTexture, devBounds)) { - fArgs.fPipelineBuilder = nullptr; +bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, + const GrScissorState* scissor, + GrDrawBatch* batch) { + GrPipeline::CreateArgs args; + args.fPipelineBuilder = pipelineBuilder; + args.fCaps = this->caps(); + args.fScissor = scissor; + args.fColorPOI = pipelineBuilder->colorProcInfo(batch); + args.fCoveragePOI = pipelineBuilder->coverageProcInfo(batch); + if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fColorPOI, + args.fCoveragePOI, &args.fDstTexture, + batch->bounds())) { + return false; } + + if (!batch->installPipeline(args)) { + return false; + } + + return true; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 059c1b3..63d6378 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -177,40 +177,28 @@ public: bool programUnitTest(GrContext* owner, int maxStages); - struct PipelineInfo { - PipelineInfo(const GrPipelineBuilder* pipelineBuilder, const GrScissorState* scissor, - const GrDrawBatch* batch, const SkRect* devBounds, - GrDrawTarget* target); - - bool valid() const { return SkToBool(fArgs.fPipelineBuilder); } - - const GrPipeline::CreateArgs& pipelineCreateArgs() const { - SkASSERT(this->valid()); - return fArgs; - } - - private: - GrPipeline::CreateArgs fArgs; - }; - protected: GrGpu* getGpu() { return fGpu; } const GrGpu* getGpu() const { return fGpu; } - // 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&, - const GrProcOptInfo& colorPOI, - const GrProcOptInfo& coveragePOI, - GrXferProcessor::DstTexture*, - const SkRect* drawBounds); - void recordBatch(GrBatch*); private: SkSTArray<256, SkAutoTUnref, true> fBatches; + bool installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, + const GrScissorState* scissor, + GrDrawBatch* batch); + + // 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&, + const GrProcOptInfo& colorPOI, + const GrProcOptInfo& coveragePOI, + GrXferProcessor::DstTexture*, + const SkRect& batchBounds); + void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatchBase* batch, GrPathRendering::FillType fill); // Check to see if this set of draw commands has been sent out