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;
}
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
desc.fConfig = rt->config();
}
-
desc.fWidth = copyRect.width();
desc.fHeight = copyRect.height();
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);
}
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;
}
///////////////////////////////////////////////////////////////////////////////
-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;
}
///////////////////////////////////////////////////////////////////////////////
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<GrBatch>, 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