OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrTargetCommands.h" | 8 #include "GrTargetCommands.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 GrBATCH_INFO("Flushing\n"); | 23 GrBATCH_INFO("Flushing\n"); |
24 if (fCmdBuffer.empty()) { | 24 if (fCmdBuffer.empty()) { |
25 return; | 25 return; |
26 } | 26 } |
27 GrBatchFlushState flushState(gpu, resourceProvider, fLastFlushToken); | 27 GrBatchFlushState flushState(gpu, resourceProvider, fLastFlushToken); |
28 // Loop over all batches and generate geometry | 28 // Loop over all batches and generate geometry |
29 CmdBuffer::Iter genIter(fCmdBuffer); | 29 CmdBuffer::Iter genIter(fCmdBuffer); |
30 while (genIter.next()) { | 30 while (genIter.next()) { |
31 if (Cmd::kDrawBatch_CmdType == genIter->type()) { | 31 if (Cmd::kDrawBatch_CmdType == genIter->type()) { |
32 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); | 32 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); |
33 // TODO: encapsulate the specialization of GrVertexBatch in GrVertex
Batch so that we can | 33 db->batch()->prepare(&flushState); |
34 // remove this cast. Currently all GrDrawBatches are in fact GrVerte
xBatch. | |
35 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(db->batch()
); | |
36 | |
37 vertexBatch->prepareDraws(&flushState); | |
38 } | 34 } |
39 } | 35 } |
40 | 36 |
41 flushState.preIssueDraws(); | 37 flushState.preIssueDraws(); |
42 | 38 |
43 CmdBuffer::Iter iter(fCmdBuffer); | 39 CmdBuffer::Iter iter(fCmdBuffer); |
44 while (iter.next()) { | 40 while (iter.next()) { |
45 iter->execute(&flushState); | 41 iter->execute(&flushState); |
46 } | 42 } |
47 fLastFlushToken = flushState.lastFlushedToken(); | 43 fLastFlushToken = flushState.lastFlushedToken(); |
(...skipping 22 matching lines...) Expand all Loading... |
70 *fState->getPipeline(), fState->fBatchTra
cker); | 66 *fState->getPipeline(), fState->fBatchTra
cker); |
71 fState->fCompiled = true; | 67 fState->fCompiled = true; |
72 } | 68 } |
73 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState
->getPipeline(), | 69 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState
->getPipeline(), |
74 &fState->fDesc, &fState->fBatchTracker, &
fStencilSettings); | 70 &fState->fDesc, &fState->fBatchTracker, &
fStencilSettings); |
75 state->gpu()->pathRendering()->drawPaths(args, this->pathRange(), fIndices,
fIndexType, | 71 state->gpu()->pathRendering()->drawPaths(args, this->pathRange(), fIndices,
fIndexType, |
76 fTransforms, fTransformType, fCount
); | 72 fTransforms, fTransformType, fCount
); |
77 } | 73 } |
78 | 74 |
79 void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) { | 75 void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) { |
80 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so
that we can | 76 fBatch->draw(state); |
81 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. | |
82 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(fBatch.get()); | |
83 vertexBatch->issueDraws(state); | |
84 } | |
85 | |
86 | |
87 void GrTargetCommands::Clear::execute(GrBatchFlushState* state) { | |
88 if (GrColor_ILLEGAL == fColor) { | |
89 state->gpu()->discard(this->renderTarget()); | |
90 } else { | |
91 state->gpu()->clear(fRect, fColor, this->renderTarget()); | |
92 } | |
93 } | 77 } |
94 | 78 |
95 void GrTargetCommands::ClearStencilClip::execute(GrBatchFlushState* state) { | 79 void GrTargetCommands::ClearStencilClip::execute(GrBatchFlushState* state) { |
96 state->gpu()->clearStencilClip(fRect, fInsideClip, this->renderTarget()); | 80 state->gpu()->clearStencilClip(fRect, fInsideClip, this->renderTarget()); |
97 } | 81 } |
98 | 82 |
99 void GrTargetCommands::CopySurface::execute(GrBatchFlushState* state) { | 83 void GrTargetCommands::CopySurface::execute(GrBatchFlushState* state) { |
100 state->gpu()->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); | 84 state->gpu()->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); |
101 } | 85 } |
OLD | NEW |