OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "GrBatchTarget.h" |
| 9 |
| 10 #if 0 |
| 11 #include "GrBatchAtlas.h" |
| 12 #include "GrPipeline.h" |
| 13 |
| 14 GrBatchTarget::GrBatchTarget(GrFoo* foo, GrGpu* gpu, GrRenderTarget* dst) |
| 15 : fGpu1(gpu) |
| 16 , fFoo1(foo) |
| 17 , fRT(dst) |
| 18 , fVertexPool(gpu) |
| 19 , fIndexPool(gpu) |
| 20 , fFlushBuffer(kFlushBufferInitialSizeInBytes) |
| 21 , fIter(fFlushBuffer) |
| 22 , fNumberOfDraws(0) |
| 23 // , fCurrentToken1(0) |
| 24 , fLastFlushedToken(0) |
| 25 , fInlineUpdatesIndex(0) { |
| 26 } |
| 27 |
| 28 void GrBatchTarget::flushNext(int n) { |
| 29 for (; n > 0; n--) { |
| 30 fLastFlushedToken++; |
| 31 SkDEBUGCODE(bool verify =) fIter.next(); |
| 32 SkASSERT(verify); |
| 33 |
| 34 BufferedFlush* bf = fIter.get(); |
| 35 |
| 36 // Flush all texture uploads |
| 37 int uploadCount = fInlineUploads.count(); |
| 38 while (fInlineUpdatesIndex < uploadCount && |
| 39 fInlineUploads[fInlineUpdatesIndex]->lastUploadToken() <= fLastFl
ushedToken) { |
| 40 fInlineUploads[fInlineUpdatesIndex++]->upload(TextureUploader(fGpu1)
); |
| 41 } |
| 42 |
| 43 GrProgramDesc desc; |
| 44 const GrPipeline* pipeline = bf->fPipeline; |
| 45 const GrPrimitiveProcessor* primProc = bf->fPrimitiveProcessor.get(); |
| 46 fGpu1->buildProgramDesc(&desc, *primProc, *pipeline, bf->fBatchTracker); |
| 47 |
| 48 GrGpu::DrawArgs args(primProc, pipeline, &desc, &bf->fBatchTracker); |
| 49 |
| 50 int drawCount = bf->fVertexDraws.count(); |
| 51 const SkSTArray<1, GrVertices, true>& vertexDraws = bf->fVertexDraws; |
| 52 for (int i = 0; i < drawCount; i++) { |
| 53 fGpu1->draw(args, vertexDraws[i]); |
| 54 } |
| 55 } |
| 56 } |
| 57 |
| 58 void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount, |
| 59 const GrVertexBuffer** buffer, int* startVertex) { |
| 60 return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex); |
| 61 } |
| 62 |
| 63 uint16_t* GrBatchTarget::makeIndexSpace(int indexCount, |
| 64 const GrIndexBuffer** buffer, int* start
Index) { |
| 65 return reinterpret_cast<uint16_t*>(fIndexPool.makeSpace(indexCount, buffer,
startIndex)); |
| 66 } |
| 67 |
| 68 #endif |
OLD | NEW |