1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrTargetCommands.h"
#include "GrInOrderDrawBuffer.h"
void GrTargetCommands::reset() {
fCmdBuffer.reset();
}
void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
if (fCmdBuffer.empty()) {
return;
}
GrGpu* gpu = iodb->getGpu();
// Loop over all batches and generate geometry
CmdBuffer::Iter genIter(fCmdBuffer);
while (genIter.next()) {
if (Cmd::kDrawBatch_CmdType == genIter->type()) {
DrawBatch* db = reinterpret_cast<DrawBatch*>(genIter.get());
fBatchTarget.resetNumberOfDraws();
db->fBatch->generateGeometry(&fBatchTarget, db->fState->getPipeline());
db->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws());
}
}
iodb->getVertexAllocPool()->unmap();
iodb->getIndexAllocPool()->unmap();
fBatchTarget.preFlush();
CmdBuffer::Iter iter(fCmdBuffer);
while (iter.next()) {
GrGpuTraceMarker newMarker("", -1);
SkString traceString;
if (iter->isTraced()) {
traceString = iodb->getCmdString(iter->markerID());
newMarker.fMarker = traceString.c_str();
gpu->addGpuTraceMarker(&newMarker);
}
iter->execute(gpu);
if (iter->isTraced()) {
gpu->removeGpuTraceMarker(&newMarker);
}
}
fBatchTarget.postFlush();
}
void GrTargetCommands::StencilPath::execute(GrGpu* gpu) {
GrGpu::StencilPathState state;
state.fRenderTarget = fRenderTarget.get();
state.fScissor = &fScissor;
state.fStencil = &fStencil;
state.fUseHWAA = fUseHWAA;
state.fViewMatrix = &fViewMatrix;
gpu->stencilPath(this->path(), state);
}
void GrTargetCommands::DrawPath::execute(GrGpu* gpu) {
if (!fState->fCompiled) {
gpu->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProcessor, *fState->getPipeline(),
fState->fBatchTracker);
fState->fCompiled = true;
}
DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
&fState->fDesc, &fState->fBatchTracker);
gpu->drawPath(args, this->path(), fStencilSettings);
}
void GrTargetCommands::DrawPaths::execute(GrGpu* gpu) {
if (!fState->fCompiled) {
gpu->buildProgramDesc(&fState->fDesc, *fState->fPrimitiveProcessor, *fState->getPipeline(),
fState->fBatchTracker);
fState->fCompiled = true;
}
DrawArgs args(fState->fPrimitiveProcessor.get(), fState->getPipeline(),
&fState->fDesc, &fState->fBatchTracker);
gpu->drawPaths(args, this->pathRange(),
fIndices, fIndexType,
fTransforms, fTransformType,
fCount, fStencilSettings);
}
void GrTargetCommands::DrawBatch::execute(GrGpu*) {
fBatchTarget->flushNext(fBatch->numberOfDraws());
}
void GrTargetCommands::Clear::execute(GrGpu* gpu) {
if (GrColor_ILLEGAL == fColor) {
gpu->discard(this->renderTarget());
} else {
gpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget());
}
}
void GrTargetCommands::ClearStencilClip::execute(GrGpu* gpu) {
gpu->clearStencilClip(fRect, fInsideClip, this->renderTarget());
}
void GrTargetCommands::CopySurface::execute(GrGpu* gpu) {
gpu->copySurface(this->dst(), this->src(), fSrcRect, fDstPoint);
}
void GrTargetCommands::XferBarrier::execute(GrGpu* gpu) {
gpu->xferBarrier(fBarrierType);
}
|