| Index: src/gpu/GrBatchTarget.h
|
| diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h
|
| index b73907746f055fc5b322f1a688742fe4b93efda5..8cd91d37e1412fc6f1cd26e2a4fadf0a1a867ad2 100644
|
| --- a/src/gpu/GrBatchTarget.h
|
| +++ b/src/gpu/GrBatchTarget.h
|
| @@ -9,6 +9,7 @@
|
| #define GrBatchBuffer_DEFINED
|
|
|
| #include "GrPendingProgramElement.h"
|
| +#include "GrPipeline.h"
|
| #include "GrGpu.h"
|
| #include "GrTRecorder.h"
|
|
|
| @@ -17,6 +18,9 @@
|
| * that render their batch.
|
| */
|
|
|
| +class GrIndexBufferAllocPool;
|
| +class GrVertexBufferAllocPool;
|
| +
|
| class GrBatchTarget : public SkNoncopyable {
|
| public:
|
| GrBatchTarget(GrGpu* gpu,
|
| @@ -26,11 +30,13 @@ public:
|
| , fVertexPool(vpool)
|
| , fIndexPool(ipool)
|
| , fFlushBuffer(kFlushBufferInitialSizeInBytes)
|
| - , fIter(fFlushBuffer) {}
|
| + , fIter(fFlushBuffer)
|
| + , fNumberOfDraws(0) {}
|
|
|
| typedef GrDrawTarget::DrawInfo DrawInfo;
|
| void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline) {
|
| GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipeline));
|
| + fNumberOfDraws++;
|
| }
|
|
|
| void draw(const GrDrawTarget::DrawInfo& draw) {
|
| @@ -39,8 +45,28 @@ public:
|
|
|
| // TODO this is temporary until batch is everywhere
|
| //void flush();
|
| + void resetNumberOfDraws() { fNumberOfDraws = 0; }
|
| + int numberOfDraws() const { return fNumberOfDraws; }
|
| void preFlush() { fIter = FlushBuffer::Iter(fFlushBuffer); }
|
| - void flushNext();
|
| + void flushNext(int n) {
|
| + for (; n > 0; n--) {
|
| + SkDEBUGCODE(bool verify =) fIter.next();
|
| + SkASSERT(verify);
|
| + GrProgramDesc desc;
|
| + BufferedFlush* bf = fIter.get();
|
| + const GrPipeline* pipeline = bf->fPipeline;
|
| + const GrPrimitiveProcessor* primProc = bf->fPrimitiveProcessor.get();
|
| + fGpu->buildProgramDesc(&desc, *primProc, *pipeline, bf->fBatchTracker);
|
| +
|
| + GrGpu::DrawArgs args(primProc, pipeline, &desc, &bf->fBatchTracker);
|
| +
|
| + int drawCount = bf->fDraws.count();
|
| + const SkSTArray<1, DrawInfo, true>& draws = bf->fDraws;
|
| + for (int i = 0; i < drawCount; i++) {
|
| + fGpu->draw(args, draws[i]);
|
| + }
|
| + }
|
| + }
|
| void postFlush() { SkASSERT(!fIter.next()); fFlushBuffer.reset(); }
|
|
|
| // TODO This goes away when everything uses batch
|
| @@ -49,6 +75,8 @@ public:
|
| return &fFlushBuffer.back().fBatchTracker;
|
| }
|
|
|
| + const GrDrawTargetCaps& caps() const { return *fGpu->caps(); }
|
| +
|
| GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
|
| GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
|
|
|
| @@ -62,18 +90,16 @@ private:
|
| struct BufferedFlush {
|
| BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline)
|
| : fPrimitiveProcessor(primProc)
|
| - , fPipeline(pipeline)
|
| - , fDraws(kDrawRecorderInitialSizeInBytes) {}
|
| + , fPipeline(pipeline) {}
|
| typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
|
| ProgramPrimitiveProcessor fPrimitiveProcessor;
|
| const GrPipeline* fPipeline;
|
| GrBatchTracker fBatchTracker;
|
| - SkSTArray<4, DrawInfo, true> fDraws;
|
| + SkSTArray<1, DrawInfo, true> fDraws;
|
| };
|
|
|
| enum {
|
| kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush),
|
| - kDrawRecorderInitialSizeInBytes = 8 * sizeof(DrawInfo),
|
| };
|
|
|
| typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer;
|
| @@ -81,6 +107,7 @@ private:
|
| FlushBuffer fFlushBuffer;
|
| // TODO this is temporary
|
| FlushBuffer::Iter fIter;
|
| + int fNumberOfDraws;
|
| };
|
|
|
| #endif
|
|
|