Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: src/gpu/GrTargetCommands.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTargetCommands.h ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrBufferedDrawTarget.h" 10 #include "GrBatchFlushState.h"
11 11 #include "GrGpu.h"
12 #include "GrPathRendering.h"
12 #include "batches/GrDrawBatch.h" 13 #include "batches/GrDrawBatch.h"
13 #include "batches/GrVertexBatch.h" 14 #include "batches/GrVertexBatch.h"
14 15
15 GrBATCH_SPEW(int32_t GrTargetCommands::Cmd::gUniqueID = 0;) 16 GrBATCH_SPEW(int32_t GrTargetCommands::Cmd::gUniqueID = 0;)
16 17
17 void GrTargetCommands::reset() { 18 void GrTargetCommands::reset() {
18 fCmdBuffer.reset(); 19 fCmdBuffer.reset();
19 fBatchTarget.reset();
20 } 20 }
21 21
22 void GrTargetCommands::flush(GrBufferedDrawTarget* bufferedDrawTarget) { 22 void GrTargetCommands::flush(GrGpu* gpu, GrResourceProvider* resourceProvider) {
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 27 GrBatchFlushState flushState(gpu, resourceProvider, fLastFlushToken);
28 GrGpu* gpu = bufferedDrawTarget->getGpu();
29
30 // Loop over all batches and generate geometry 28 // Loop over all batches and generate geometry
31 CmdBuffer::Iter genIter(fCmdBuffer); 29 CmdBuffer::Iter genIter(fCmdBuffer);
32 while (genIter.next()) { 30 while (genIter.next()) {
33 if (Cmd::kDrawBatch_CmdType == genIter->type()) { 31 if (Cmd::kDrawBatch_CmdType == genIter->type()) {
34 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get()); 32 DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get());
35 fBatchTarget.resetNumberOfDraws();
36 // TODO: encapsulate the specialization of GrVertexBatch in GrVertex Batch so that we can 33 // TODO: encapsulate the specialization of GrVertexBatch in GrVertex Batch so that we can
37 // remove this cast. Currently all GrDrawBatches are in fact GrVerte xBatch. 34 // remove this cast. Currently all GrDrawBatches are in fact GrVerte xBatch.
38 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(db->batch() ); 35 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(db->batch() );
39 36
40 vertexBatch->generateGeometry(&fBatchTarget); 37 vertexBatch->prepareDraws(&flushState);
41 vertexBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
42 } 38 }
43 } 39 }
44 40
45 fBatchTarget.preFlush(); 41 flushState.preIssueDraws();
46 42
47 CmdBuffer::Iter iter(fCmdBuffer); 43 CmdBuffer::Iter iter(fCmdBuffer);
48
49 while (iter.next()) { 44 while (iter.next()) {
50 iter->execute(gpu); 45 iter->execute(&flushState);
51 } 46 }
52 47 fLastFlushToken = flushState.lastFlushedToken();
53 fBatchTarget.postFlush();
54 } 48 }
55 49
56 void GrTargetCommands::StencilPath::execute(GrGpu* gpu) { 50 void GrTargetCommands::StencilPath::execute(GrBatchFlushState* state) {
57 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewM atrix, &fScissor, 51 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewM atrix, &fScissor,
58 &fStencil); 52 &fStencil);
59 gpu->pathRendering()->stencilPath(args, this->path()); 53 state->gpu()->pathRendering()->stencilPath(args, this->path());
60 } 54 }
61 55
62 void GrTargetCommands::DrawPath::execute(GrGpu* gpu) { 56 void GrTargetCommands::DrawPath::execute(GrBatchFlushState* state) {
63 if (!fState->fCompiled) { 57 if (!fState->fCompiled) {
64 gpu->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProcessor, *fSt ate->getPipeline(), 58 state->gpu()->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProces sor,
65 fState->fBatchTracker); 59 *fState->getPipeline(), fState->fBatchTra cker);
66 fState->fCompiled = true; 60 fState->fCompiled = true;
67 } 61 }
68 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState ->getPipeline(), 62 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState ->getPipeline(),
69 &fState->fDesc, &fState->fBatchTracker, & fStencilSettings); 63 &fState->fDesc, &fState->fBatchTracker, & fStencilSettings);
70 gpu->pathRendering()->drawPath(args, this->path()); 64 state->gpu()->pathRendering()->drawPath(args, this->path());
71 } 65 }
72 66
73 void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) { 67 void GrTargetCommands::DrawPaths::execute(GrBatchFlushState* state) {
74 if (!fState->fCompiled) { 68 if (!fState->fCompiled) {
75 gpu->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProcessor, *fSt ate->getPipeline(), 69 state->gpu()->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProces sor,
76 fState->fBatchTracker); 70 *fState->getPipeline(), fState->fBatchTra cker);
77 fState->fCompiled = true; 71 fState->fCompiled = true;
78 } 72 }
79 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState ->getPipeline(), 73 GrPathRendering::DrawPathArgs args(fState->fPrimitiveProcessor.get(), fState ->getPipeline(),
80 &fState->fDesc, &fState->fBatchTracker, & fStencilSettings); 74 &fState->fDesc, &fState->fBatchTracker, & fStencilSettings);
81 gpu->pathRendering()->drawPaths(args, this->pathRange(), fIndices, fIndexTyp e, fTransforms, 75 state->gpu()->pathRendering()->drawPaths(args, this->pathRange(), fIndices, fIndexType,
82 fTransformType, fCount); 76 fTransforms, fTransformType, fCount );
83 } 77 }
84 78
85 void GrTargetCommands::DrawBatch::execute(GrGpu* gpu) { 79 void GrTargetCommands::DrawBatch::execute(GrBatchFlushState* state) {
86 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can 80 // TODO: encapsulate the specialization of GrVertexBatch in GrVertexBatch so that we can
87 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch. 81 // remove this cast. Currently all GrDrawBatches are in fact GrVertexBatch.
88 const GrVertexBatch* vertexBatch = static_cast<const GrVertexBatch*>(fBatch. get()); 82 GrVertexBatch* vertexBatch = static_cast<GrVertexBatch*>(fBatch.get());
89 fBatchTarget->flushNext(vertexBatch->numberOfDraws()); 83 vertexBatch->issueDraws(state);
90 } 84 }
91 85
92 void GrTargetCommands::Clear::execute(GrGpu* gpu) { 86
87 void GrTargetCommands::Clear::execute(GrBatchFlushState* state) {
93 if (GrColor_ILLEGAL == fColor) { 88 if (GrColor_ILLEGAL == fColor) {
94 gpu->discard(this->renderTarget()); 89 state->gpu()->discard(this->renderTarget());
95 } else { 90 } else {
96 gpu->clear(fRect, fColor, this->renderTarget()); 91 state->gpu()->clear(fRect, fColor, this->renderTarget());
97 } 92 }
98 } 93 }
99 94
100 void GrTargetCommands::ClearStencilClip::execute(GrGpu* gpu) { 95 void GrTargetCommands::ClearStencilClip::execute(GrBatchFlushState* state) {
101 gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget()); 96 state->gpu()->clearStencilClip(fRect, fInsideClip, this->renderTarget());
102 } 97 }
103 98
104 void GrTargetCommands::CopySurface::execute(GrGpu* gpu) { 99 void GrTargetCommands::CopySurface::execute(GrBatchFlushState* state) {
105 gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint); 100 state->gpu()->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint);
106 } 101 }
OLDNEW
« no previous file with comments | « src/gpu/GrTargetCommands.h ('k') | src/gpu/GrTessellatingPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698