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 "GrTargetCommands.h" |
| 9 |
| 10 #include "GrBatchFlushState.h" |
| 11 #include "GrGpu.h" |
| 12 #include "GrPathRendering.h" |
| 13 #include "batches/GrDrawBatch.h" |
| 14 #include "batches/GrVertexBatch.h" |
| 15 |
| 16 GrBATCH_SPEW(int32_t GrTargetCommands::Cmd::gUniqueID = 0;) |
| 17 |
| 18 void GrTargetCommands::reset() { |
| 19 fCmdBuffer.reset(); |
| 20 } |
| 21 |
| 22 void GrTargetCommands::flush(GrGpu* gpu, GrResourceProvider* resourceProvider) { |
| 23 GrBATCH_INFO("Flushing\n"); |
| 24 if (fCmdBuffer.empty()) { |
| 25 return; |
| 26 } |
| 27 GrBatchFlushState flushState(fFoo, gpu, resourceProvider, fLastFlushToken); |
| 28 // Loop over all batches and generate geometry |
| 29 CmdBuffer::Iter genIter(fCmdBuffer); |
| 30 while (genIter.next()) { |
| 31 if (Cmd::kDrawBatch_CmdType == genIter->type()) { |
| 32 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); |
| 33 db->batch()->prepare(&flushState); |
| 34 } |
| 35 } |
| 36 |
| 37 flushState.preIssueDraws(); |
| 38 |
| 39 CmdBuffer::Iter iter(fCmdBuffer); |
| 40 while (iter.next()) { |
| 41 iter->execute(&flushState); |
| 42 } |
| 43 fLastFlushToken = flushState.lastFlushedToken(); |
| 44 } |
| 45 |
| 46 void GrTargetCommands::DrawPath::execute(GrBatchFlushState* state) { |
| 47 if (!fState->fCompiled) { |
| 48 state->gpu()->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProces
sor, |
| 49 *fState->getPipeline(), fState->fBatchTra
cker); |
| 50 fState->fCompiled = true; |
| 51 } |
| 52 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState
->getPipeline(), |
| 53 &fState->fDesc, &fState->fBatchTracker, &
fStencilSettings); |
| 54 state->gpu()->pathRendering()->drawPath(args, this->path()); |
| 55 } |
| 56 |
| 57 void GrTargetCommands::DrawPaths::execute(GrBatchFlushState* state) { |
| 58 if (!fState->fCompiled) { |
| 59 state->gpu()->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProces
sor, |
| 60 *fState->getPipeline(), fState->fBatchTra
cker); |
| 61 fState->fCompiled = true; |
| 62 } |
| 63 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState
->getPipeline(), |
| 64 &fState->fDesc, &fState->fBatchTracker, &
fStencilSettings); |
| 65 state->gpu()->pathRendering()->drawPaths(args, this->pathRange(), fIndices,
fIndexType, |
| 66 fTransforms, fTransformType, fCount
); |
| 67 } |
| 68 |
| 69 void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) { |
| 70 fBatch->draw(state); |
| 71 } |
OLD | NEW |