diff --git a/src/gpu/GrTargetCommands.cpp b/src/gpu/GrTargetCommands.cpp index 24ee32d832..a6d3148141 100644 --- a/src/gpu/GrTargetCommands.cpp +++ b/src/gpu/GrTargetCommands.cpp @@ -35,17 +35,14 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDrawBatch( } // Check if there is a Batch Draw we can batch with - if (Cmd::kDrawBatch_CmdType != fCmdBuffer.back().type() || !fDrawBatch) { - fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget)); - return fDrawBatch; + if (Cmd::kDrawBatch_CmdType == fCmdBuffer.back().type()) { + DrawBatch* previous = static_cast(&fCmdBuffer.back()); + if (previous->fBatch->combineIfPossible(batch)) { + return NULL; + } } - SkASSERT(&fCmdBuffer.back() == fDrawBatch); - if (!fDrawBatch->fBatch->combineIfPossible(batch)) { - fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget)); - } - - return fDrawBatch; + return GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch, &fBatchTarget)); } GrTargetCommands::Cmd* GrTargetCommands::recordStencilPath( @@ -190,7 +187,6 @@ GrTargetCommands::Cmd* GrTargetCommands::recordDiscard(GrInOrderDrawBuffer* iodb void GrTargetCommands::reset() { fCmdBuffer.reset(); fPrevState = NULL; - fDrawBatch = NULL; } void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { @@ -204,7 +200,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { GrGpu* gpu = iodb->getGpu(); -#ifdef USE_BITMAP_TEXTBLOBS // Loop over all batches and generate geometry CmdBuffer::Iter genIter(fCmdBuffer); while (genIter.next()) { @@ -220,7 +215,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { currentState = ss; } } -#endif iodb->getVertexAllocPool()->unmap(); iodb->getIndexAllocPool()->unmap(); @@ -237,7 +231,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { gpu->addGpuTraceMarker(&newMarker); } - // TODO temporary hack if (Cmd::kDrawBatch_CmdType == iter->type()) { DrawBatch* db = reinterpret_cast(iter.get()); fBatchTarget.flushNext(db->fBatch->numberOfDraws()); @@ -249,12 +242,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } if (Cmd::kSetState_CmdType == iter->type()) { -#ifndef USE_BITMAP_TEXTBLOBS - SetState* ss = reinterpret_cast(iter.get()); - - ss->execute(gpu, currentState); - currentState = ss; -#else // TODO this is just until NVPR is in batch SetState* ss = reinterpret_cast(iter.get()); @@ -262,7 +249,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { ss->execute(gpu, currentState); } currentState = ss; -#endif } else { iter->execute(gpu, currentState); @@ -273,17 +259,9 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) { } } - // TODO see copious notes about hack fBatchTarget.postFlush(); } -void GrTargetCommands::Draw::execute(GrGpu* gpu, const SetState* state) { - SkASSERT(state); - DrawArgs args(state->fPrimitiveProcessor.get(), state->getPipeline(), &state->fDesc, - &state->fBatchTracker); - gpu->draw(args, fInfo); -} - void GrTargetCommands::StencilPath::execute(GrGpu* gpu, const SetState*) { GrGpu::StencilPathState state; state.fRenderTarget = fRenderTarget.get(); diff --git a/src/gpu/GrTargetCommands.h b/src/gpu/GrTargetCommands.h index 4ab41dbaf1..42a8ca3d65 100644 --- a/src/gpu/GrTargetCommands.h +++ b/src/gpu/GrTargetCommands.h @@ -19,15 +19,6 @@ #include "SkRect.h" #include "SkTypes.h" -// This is just to get a flag -// TODO remove this when batch is everywhere -#include "GrTextContext.h" -#ifdef USE_BITMAP_TEXTBLOBS -#define CLOSE_BATCH -#else -#define CLOSE_BATCH this->closeBatch(); -#endif - class GrInOrderDrawBuffer; class GrVertexBufferAllocPool; class GrIndexBufferAllocPool; @@ -41,22 +32,20 @@ public: GrIndexBufferAllocPool* indexPool) : fCmdBuffer(kCmdBufferInitialSizeInBytes) , fPrevState(NULL) - , fBatchTarget(gpu, vertexPool, indexPool) - , fDrawBatch(NULL) { + , fBatchTarget(gpu, vertexPool, indexPool) { } class Cmd : ::SkNoncopyable { public: enum CmdType { - kDraw_CmdType = 1, - kStencilPath_CmdType = 2, - kSetState_CmdType = 3, - kClear_CmdType = 4, - kCopySurface_CmdType = 5, - kDrawPath_CmdType = 6, - kDrawPaths_CmdType = 7, - kDrawBatch_CmdType = 8, - kXferBarrier_CmdType = 9, + kStencilPath_CmdType = 1, + kSetState_CmdType = 2, + kClear_CmdType = 3, + kCopySurface_CmdType = 4, + kDrawPath_CmdType = 5, + kDrawPaths_CmdType = 6, + kDrawBatch_CmdType = 7, + kXferBarrier_CmdType = 8, }; Cmd(CmdType type) : fMarkerID(-1), fType(type) {} @@ -154,14 +143,6 @@ private: void recordXferBarrierIfNecessary(GrInOrderDrawBuffer*, const GrDrawTarget::PipelineInfo&); - struct Draw : public Cmd { - Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(info) {} - - void execute(GrGpu*, const SetState*) override; - - GrDrawTarget::DrawInfo fInfo; - }; - struct StencilPath : public Cmd { StencilPath(const GrPath* path, GrRenderTarget* rt) : Cmd(kStencilPath_CmdType) @@ -328,12 +309,6 @@ private: CmdBuffer fCmdBuffer; SetState* fPrevState; GrBatchTarget fBatchTarget; - // TODO hack until batch is everywhere - GrTargetCommands::DrawBatch* fDrawBatch; - - // This will go away when everything uses batch. However, in the short term anything which - // might be put into the GrInOrderDrawBuffer needs to make sure it closes the last batch - void closeBatch(); }; #endif diff --git a/src/gpu/GrTextContext.h b/src/gpu/GrTextContext.h index 9433904094..60714ca4ce 100644 --- a/src/gpu/GrTextContext.h +++ b/src/gpu/GrTextContext.h @@ -23,9 +23,6 @@ class SkDrawFilter; class SkGpuDevice; class SkTextBlob; -// For testing textblobs on GPU. -#define USE_BITMAP_TEXTBLOBS - /* * This class wraps the state for a single text render */