| Index: src/gpu/GrBatchTarget.h
|
| diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h
|
| index ae046c1ee1e2cb44e406d1603187682d9e3330c7..65a2e0aaa036eaaf1cbff470a5a5ca2efb8bee86 100644
|
| --- a/src/gpu/GrBatchTarget.h
|
| +++ b/src/gpu/GrBatchTarget.h
|
| @@ -8,6 +8,7 @@
|
| #ifndef GrBatchBuffer_DEFINED
|
| #define GrBatchBuffer_DEFINED
|
|
|
| +#include "GrBatchAtlas.h"
|
| #include "GrBufferAllocPool.h"
|
| #include "GrPendingProgramElement.h"
|
| #include "GrPipeline.h"
|
| @@ -24,51 +25,53 @@ class GrVertexBufferAllocPool;
|
|
|
| class GrBatchTarget : public SkNoncopyable {
|
| public:
|
| + typedef GrDrawTarget::BatchToken BatchToken;
|
| GrBatchTarget(GrGpu* gpu,
|
| GrVertexBufferAllocPool* vpool,
|
| - GrIndexBufferAllocPool* ipool)
|
| - : fGpu(gpu)
|
| - , fVertexPool(vpool)
|
| - , fIndexPool(ipool)
|
| - , fFlushBuffer(kFlushBufferInitialSizeInBytes)
|
| - , fIter(fFlushBuffer)
|
| - , fNumberOfDraws(0) {}
|
| + GrIndexBufferAllocPool* ipool);
|
|
|
| typedef GrDrawTarget::DrawInfo DrawInfo;
|
| void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline) {
|
| GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipeline));
|
| fNumberOfDraws++;
|
| + fCurrentToken++;
|
| + }
|
| +
|
| + void update(GrPlotUpdater updater) {
|
| + BatchToken updaterToken = updater.lastUploadToken();
|
| + if (this->asapToken() == updaterToken) {
|
| + fAsapUpdates.push_back(updater);
|
| + } else {
|
| + fInlineUpdates.push_back(updater);
|
| + }
|
| }
|
|
|
| void draw(const GrDrawTarget::DrawInfo& draw) {
|
| fFlushBuffer.back().fDraws.push_back(draw);
|
| }
|
|
|
| - // TODO this is temporary until batch is everywhere
|
| - //void flush();
|
| + bool isIssued(BatchToken token) const { return fLastFlushedToken >= token; }
|
| + BatchToken currentToken() const { return fCurrentToken; }
|
| + BatchToken asapToken() const { return fLastFlushedToken + 1; }
|
| +
|
| + // TODO much of this complexity goes away when batch is everywhere
|
| void resetNumberOfDraws() { fNumberOfDraws = 0; }
|
| int numberOfDraws() const { return fNumberOfDraws; }
|
| - void preFlush() { fIter = FlushBuffer::Iter(fFlushBuffer); }
|
| - 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 preFlush() {
|
| + int updateCount = fAsapUpdates.count();
|
| + for (int i = 0; i < updateCount; i++) {
|
| + fAsapUpdates[i].update();
|
| }
|
| + fInlineUpdatesIndex = 0;
|
| + fIter = FlushBuffer::Iter(fFlushBuffer);
|
| + }
|
| + void flushNext(int n);
|
| + void postFlush() {
|
| + SkASSERT(!fIter.next());
|
| + fFlushBuffer.reset();
|
| + fAsapUpdates.reset();
|
| + fInlineUpdates.reset();
|
| }
|
| - void postFlush() { SkASSERT(!fIter.next()); fFlushBuffer.reset(); }
|
|
|
| // TODO This goes away when everything uses batch
|
| GrBatchTracker* currentBatchTracker() {
|
| @@ -81,6 +84,8 @@ public:
|
| GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
|
| GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
|
|
|
| + const static int kVertsPerRect = 4;
|
| + const static int kIndicesPerRect = 6;
|
| const GrIndexBuffer* quadIndexBuffer() const { return fGpu->getQuadIndexBuffer(); }
|
|
|
| // A helper for draws which overallocate and then return data to the pool
|
| @@ -118,6 +123,11 @@ private:
|
| // TODO this is temporary
|
| FlushBuffer::Iter fIter;
|
| int fNumberOfDraws;
|
| + BatchToken fCurrentToken;
|
| + BatchToken fLastFlushedToken; // The next token to be flushed
|
| + SkTArray<GrPlotUpdater, true> fAsapUpdates;
|
| + SkTArray<GrPlotUpdater, true> fInlineUpdates;
|
| + int fInlineUpdatesIndex;
|
| };
|
|
|
| #endif
|
|
|