Index: src/gpu/GrBatchTarget.cpp |
diff --git a/src/gpu/GrBatchTarget.cpp b/src/gpu/GrBatchTarget.cpp |
index 21658d2a01a19eb31ad7343c32649a29c86a8228..4c24a80c95f1c47cf34262eedf6697da68d3f374 100644 |
--- a/src/gpu/GrBatchTarget.cpp |
+++ b/src/gpu/GrBatchTarget.cpp |
@@ -7,42 +7,49 @@ |
#include "GrBatchTarget.h" |
+#include "GrBatchAtlas.h" |
#include "GrPipeline.h" |
-/* |
-void GrBatchTarget::flush() { |
- FlushBuffer::Iter iter(fFlushBuffer); |
- fVertexPool->unmap(); |
- fIndexPool->unmap(); |
+GrBatchTarget::GrBatchTarget(GrGpu* gpu, |
+ GrVertexBufferAllocPool* vpool, |
+ GrIndexBufferAllocPool* ipool) |
+ : fGpu(gpu) |
+ , fVertexPool(vpool) |
+ , fIndexPool(ipool) |
+ , fFlushBuffer(kFlushBufferInitialSizeInBytes) |
+ , fIter(fFlushBuffer) |
+ , fNumberOfDraws(0) |
+ , fCurrentToken(0) |
+ , fLastFlushedToken(0) |
+ , fInlineUpdatesIndex(0) { |
+} |
- while (iter.next()) { |
- GrProgramDesc desc; |
- BufferedFlush* bf = iter.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); |
- for (int i = 0; i < bf->fDraws.count(); i++) { |
- fGpu->draw(args, bf->fDraws[i]); |
- } |
- } |
- fFlushBuffer.reset(); |
-}*/ |
-/* |
-void GrBatchTarget::flushNext(int n) { |
+void GrBatchTarget::flushNext(int n) { |
for (; n > 0; n--) { |
+ fLastFlushedToken++; |
SkDEBUGCODE(bool verify =) fIter.next(); |
SkASSERT(verify); |
- GrProgramDesc desc; |
+ |
BufferedFlush* bf = fIter.get(); |
+ |
+ // Flush all texture uploads |
+ int uploadCount = fInlineUploads.count(); |
+ while (fInlineUpdatesIndex < uploadCount && |
+ fInlineUploads[fInlineUpdatesIndex]->lastUploadToken() <= fLastFlushedToken) { |
+ fInlineUploads[fInlineUpdatesIndex++]->upload(TextureUploader(fGpu)); |
+ } |
+ |
+ GrProgramDesc desc; |
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); |
- for (int i = 0; i < bf->fDraws.count(); i++) { |
- fGpu->draw(args, bf->fDraws[i]); |
+ |
+ 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]); |
} |
} |
-}*/ |
+} |