joshualitt | d15e4e4 | 2015-01-26 13:30:10 -0800 | [diff] [blame] | 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 | #include "GrBufferAllocPool.h" |
| 11 | #include "GrPipeline.h" |
| 12 | |
| 13 | void GrBatchTarget::flush() { |
| 14 | FlushBuffer::Iter iter(fFlushBuffer); |
| 15 | fVertexPool->unmap(); |
| 16 | fIndexPool->unmap(); |
| 17 | |
| 18 | while (iter.next()) { |
| 19 | GrProgramDesc desc; |
| 20 | BufferedFlush* bf = iter.get(); |
| 21 | const GrPipeline* pipeline = bf->fPipeline; |
| 22 | const GrPrimitiveProcessor* primProc = bf->fPrimitiveProcessor.get(); |
| 23 | fGpu->buildProgramDesc(&desc, *primProc, *pipeline, pipeline->descInfo(), |
| 24 | bf->fBatchTracker); |
| 25 | |
| 26 | GrGpu::DrawArgs args(primProc, pipeline, &desc, &bf->fBatchTracker); |
| 27 | for (int i = 0; i < bf->fDraws.count(); i++) { |
| 28 | fGpu->draw(args, bf->fDraws[i]); |
| 29 | } |
| 30 | } |
| 31 | fFlushBuffer.reset(); |
| 32 | } |