Make initBatchTracker private, move towards pipeline on batch
Review URL: https://codereview.chromium.org/1282893002
This commit is contained in:
parent
4977983510
commit
5ac42ea807
@ -34,7 +34,7 @@ void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch,
|
||||
return;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* cmd = fCommands->recordDrawBatch(state, batch);
|
||||
GrTargetCommands::Cmd* cmd = fCommands->recordDrawBatch(state, opts, batch);
|
||||
this->recordTraceMarkersIfNecessary(cmd);
|
||||
}
|
||||
|
||||
@ -190,8 +190,6 @@ GrBufferedDrawTarget::setupPipelineAndShouldDraw(GrBatch* batch,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
batch->initBatchTracker(*opts);
|
||||
|
||||
if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
|
||||
fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
|
||||
this->unallocState(state);
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
bool insideClip,
|
||||
GrRenderTarget* renderTarget);
|
||||
virtual Cmd* recordDiscard(GrRenderTarget*);
|
||||
virtual Cmd* recordDrawBatch(State*, GrBatch*) = 0;
|
||||
virtual Cmd* recordDrawBatch(const State*, const GrPipelineOptimizations&, GrBatch*) = 0;
|
||||
virtual Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -37,8 +37,6 @@ void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch,
|
||||
return;
|
||||
}
|
||||
|
||||
batch->initBatchTracker(opts);
|
||||
|
||||
fBatchTarget.resetNumberOfDraws();
|
||||
|
||||
batch->generateGeometry(&fBatchTarget);
|
||||
|
@ -25,9 +25,11 @@ static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin
|
||||
return isWinding;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(State* state, GrBatch* batch) {
|
||||
GrTargetCommands::Cmd* GrInOrderCommandBuilder::recordDrawBatch(const State* state,
|
||||
const GrPipelineOptimizations& opts,
|
||||
GrBatch* batch) {
|
||||
// Check if there is a Batch Draw we can batch with
|
||||
batch->setPipeline(state->getPipeline());
|
||||
batch->setPipeline(state->getPipeline(), opts);
|
||||
GrBATCH_INFO("In-Recording (%s, %u)\n", batch->name(), batch->uniqueID());
|
||||
if (!this->cmdBuffer()->empty() &&
|
||||
Cmd::kDrawBatch_CmdType == this->cmdBuffer()->back().type()) {
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
GrInOrderCommandBuilder(GrGpu* gpu) : INHERITED(gpu) { }
|
||||
|
||||
Cmd* recordDrawBatch(State*, GrBatch*) override;
|
||||
Cmd* recordDrawBatch(const State*, const GrPipelineOptimizations&, GrBatch*) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -15,7 +15,9 @@ static bool intersect(const Left& a, const Right& b) {
|
||||
a.fTop < b.fBottom && b.fTop < a.fBottom;
|
||||
}
|
||||
|
||||
GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, GrBatch* batch) {
|
||||
GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(const State* state,
|
||||
const GrPipelineOptimizations& opts,
|
||||
GrBatch* batch) {
|
||||
// Check if there is a Batch Draw we can batch with by linearly searching back until we either
|
||||
// 1) check every draw
|
||||
// 2) intersect with something
|
||||
@ -23,7 +25,7 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
|
||||
// Experimentally we have found that most batching occurs within the first 10 comparisons.
|
||||
static const int kMaxLookback = 10;
|
||||
int i = 0;
|
||||
batch->setPipeline(state->getPipeline());
|
||||
batch->setPipeline(state->getPipeline(), opts);
|
||||
GrRenderTarget* rt = state->getPipeline()->getRenderTarget();
|
||||
|
||||
GrBATCH_INFO("Re-Recording (%s, B%u)\n"
|
||||
@ -33,17 +35,17 @@ GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, Gr
|
||||
batch->uniqueID(), rt,
|
||||
batch->bounds().fLeft, batch->bounds().fRight,
|
||||
batch->bounds().fTop, batch->bounds().fBottom);
|
||||
#if GR_BATCH_SPEW
|
||||
SkDebugf("\tColorStages:\n");
|
||||
for (int i = 0; i < state->getPipeline()->numColorFragmentStages(); i++) {
|
||||
SkDebugf("\t\t%s\n", state->getPipeline()->getColorStage(i).processor()->name());
|
||||
if (GR_BATCH_SPEW) {
|
||||
SkDebugf("\tColorStages:\n");
|
||||
for (int i = 0; i < state->getPipeline()->numColorFragmentStages(); i++) {
|
||||
SkDebugf("\t\t%s\n", state->getPipeline()->getColorStage(i).processor()->name());
|
||||
}
|
||||
SkDebugf("\tCoverageStages:\n");
|
||||
for (int i = 0; i < state->getPipeline()->numCoverageFragmentStages(); i++) {
|
||||
SkDebugf("\t\t%s\n", state->getPipeline()->getCoverageStage(i).processor()->name());
|
||||
}
|
||||
SkDebugf("\tXP: %s\n", state->getPipeline()->getXferProcessor()->name());
|
||||
}
|
||||
SkDebugf("\tCoverageStages:\n");
|
||||
for (int i = 0; i < state->getPipeline()->numCoverageFragmentStages(); i++) {
|
||||
SkDebugf("\t\t%s\n", state->getPipeline()->getCoverageStage(i).processor()->name());
|
||||
}
|
||||
SkDebugf("\tXP: %s\n", state->getPipeline()->getXferProcessor()->name());
|
||||
#endif
|
||||
GrBATCH_INFO("\tOutcome:\n");
|
||||
if (!this->cmdBuffer()->empty()) {
|
||||
GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
GrReorderCommandBuilder(GrGpu* gpu) : INHERITED(gpu) {}
|
||||
|
||||
Cmd* recordDrawBatch(State*, GrBatch*) override;
|
||||
Cmd* recordDrawBatch(const State*, const GrPipelineOptimizations&, GrBatch*) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
const GrPathProcessor*,
|
||||
const GrPath*,
|
||||
|
@ -241,7 +241,7 @@ private:
|
||||
};
|
||||
|
||||
struct DrawBatch : public Cmd {
|
||||
DrawBatch(State* state, GrBatch* batch, GrBatchTarget* batchTarget)
|
||||
DrawBatch(const State* state, GrBatch* batch, GrBatchTarget* batchTarget)
|
||||
: Cmd(kDrawBatch_CmdType)
|
||||
, fState(SkRef(state))
|
||||
, fBatch(SkRef(batch))
|
||||
@ -251,8 +251,8 @@ private:
|
||||
|
||||
void execute(GrGpu*) override;
|
||||
|
||||
SkAutoTUnref<State> fState;
|
||||
SkAutoTUnref<GrBatch> fBatch;
|
||||
SkAutoTUnref<const State> fState;
|
||||
SkAutoTUnref<GrBatch> fBatch;
|
||||
|
||||
private:
|
||||
GrBatchTarget* fBatchTarget;
|
||||
|
@ -60,12 +60,6 @@ public:
|
||||
virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
|
||||
virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
|
||||
|
||||
/*
|
||||
* initBatchTracker is a hook for the some additional overrides / optimization possibilities
|
||||
* from the GrXferProcessor.
|
||||
*/
|
||||
virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
|
||||
|
||||
bool combineIfPossible(GrBatch* that) {
|
||||
if (this->classID() != that->classID()) {
|
||||
return false;
|
||||
@ -108,7 +102,11 @@ public:
|
||||
SkDEBUGCODE(bool isUsed() const { return fUsed; })
|
||||
|
||||
const GrPipeline* pipeline() const { return fPipeline; }
|
||||
void setPipeline(const GrPipeline* pipeline) { fPipeline.reset(SkRef(pipeline)); }
|
||||
|
||||
void setPipeline(const GrPipeline* pipeline, const GrPipelineOptimizations& optimizations) {
|
||||
fPipeline.reset(SkRef(pipeline));
|
||||
this->initBatchTracker(optimizations);
|
||||
}
|
||||
|
||||
#if GR_BATCH_SPEW
|
||||
uint32_t uniqueID() const { return fUniqueID; }
|
||||
@ -170,6 +168,13 @@ protected:
|
||||
SkRect fBounds;
|
||||
|
||||
private:
|
||||
/*
|
||||
* initBatchTracker is a hook for the some additional overrides / optimization possibilities
|
||||
* from the GrXferProcessor.
|
||||
*/
|
||||
virtual void initBatchTracker(const GrPipelineOptimizations&) = 0;
|
||||
|
||||
|
||||
static uint32_t GenID(int32_t* idCounter) {
|
||||
// fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
|
||||
// atomic inc returns the old value not the incremented value. So we add
|
||||
|
Loading…
Reference in New Issue
Block a user