OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrBufferedDrawTarget.h" | 8 #include "GrBufferedDrawTarget.h" |
9 | 9 |
10 // We will use the reordering buffer, unless we have NVPR. | 10 // We will use the reordering buffer, unless we have NVPR. |
11 // TODO move NVPR to batch so we can reorder | 11 // TODO move NVPR to batch so we can reorder |
12 static inline bool allow_reordering(const GrCaps* caps) { | 12 static inline bool allow_reordering(const GrCaps* caps) { |
13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo
rt(); | 13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo
rt(); |
14 } | 14 } |
15 | 15 |
16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) | 16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) |
17 : INHERITED(context) | 17 : INHERITED(context) |
18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con
text->caps()))) | 18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con
text->caps()))) |
19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) | 19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) |
20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) | 20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) |
21 , fPipelineBuffer(kPipelineBufferMinReserve) | 21 , fPipelineBuffer(kPipelineBufferMinReserve) |
22 , fDrawID(0) { | 22 , fDrawID(0) { |
23 } | 23 } |
24 | 24 |
25 GrBufferedDrawTarget::~GrBufferedDrawTarget() { | 25 GrBufferedDrawTarget::~GrBufferedDrawTarget() { |
26 this->reset(); | 26 this->reset(); |
27 } | 27 } |
28 | 28 |
29 void GrBufferedDrawTarget::onDrawBatch(GrDrawBatch* batch) { | 29 void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) { |
30 fCommands->recordDrawBatch(batch, *this->caps()); | 30 fCommands->recordDrawBatch(batch, *this->caps()); |
31 } | 31 } |
32 | 32 |
33 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde
r, | 33 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde
r, |
34 const GrPathProcessor* pathProc, | 34 const GrPathProcessor* pathProc, |
35 const GrPath* path, | 35 const GrPath* path, |
36 const GrScissorState& scissorState, | 36 const GrScissorState& scissorState, |
37 const GrStencilSettings& stencilSetting
s) { | 37 const GrStencilSettings& stencilSetting
s) { |
38 fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState,
stencilSettings); | 38 fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState,
stencilSettings); |
39 } | 39 } |
(...skipping 22 matching lines...) Expand all Loading... |
62 GrPipelineOptimizations opts; | 62 GrPipelineOptimizations opts; |
63 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf
o, &opts); | 63 StateForPathDraw* state = this->createStateForPathDraw(pathProc, pipelineInf
o, &opts); |
64 if (!state) { | 64 if (!state) { |
65 return; | 65 return; |
66 } | 66 } |
67 fCommands->recordDrawPaths(state, this, pathProc, pathRange, indices, indexT
ype, | 67 fCommands->recordDrawPaths(state, this, pathProc, pathRange, indices, indexT
ype, |
68 transformValues, transformType, count, stencilSet
tings, | 68 transformValues, transformType, count, stencilSet
tings, |
69 opts); | 69 opts); |
70 } | 70 } |
71 | 71 |
72 void GrBufferedDrawTarget::onClear(const SkIRect& rect, GrColor color, | |
73 GrRenderTarget* renderTarget) { | |
74 fCommands->recordClear(rect, color, renderTarget); | |
75 } | |
76 | |
77 void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect, | 72 void GrBufferedDrawTarget::clearStencilClip(const SkIRect& rect, |
78 bool insideClip, | 73 bool insideClip, |
79 GrRenderTarget* renderTarget) { | 74 GrRenderTarget* renderTarget) { |
80 fCommands->recordClearStencilClip(rect, insideClip, renderTarget); | 75 fCommands->recordClearStencilClip(rect, insideClip, renderTarget); |
81 } | 76 } |
82 | 77 |
83 void GrBufferedDrawTarget::discard(GrRenderTarget* renderTarget) { | |
84 if (!this->caps()->discardRenderTargetSupport()) { | |
85 return; | |
86 } | |
87 fCommands->recordDiscard(renderTarget); | |
88 } | |
89 | |
90 void GrBufferedDrawTarget::onReset() { | 78 void GrBufferedDrawTarget::onReset() { |
91 fCommands->reset(); | 79 fCommands->reset(); |
92 fPathIndexBuffer.rewind(); | 80 fPathIndexBuffer.rewind(); |
93 fPathTransformBuffer.rewind(); | 81 fPathTransformBuffer.rewind(); |
94 | 82 |
95 fPrevState.reset(NULL); | 83 fPrevState.reset(NULL); |
96 // Note, fPrevState points into fPipelineBuffer's allocation, so we have to
reset first. | 84 // Note, fPrevState points into fPipelineBuffer's allocation, so we have to
reset first. |
97 // Furthermore, we have to reset fCommands before fPipelineBuffer too. | 85 // Furthermore, we have to reset fCommands before fPipelineBuffer too. |
98 if (fDrawID % kPipelineBufferHighWaterMark) { | 86 if (fDrawID % kPipelineBufferHighWaterMark) { |
99 fPipelineBuffer.rewind(); | 87 fPipelineBuffer.rewind(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 *state->fPrimitiveProcesso
r, | 119 *state->fPrimitiveProcesso
r, |
132 state->fBatchTracker) && | 120 state->fBatchTracker) && |
133 GrPipeline::AreEqual(*fPrevState->getPipeline(), *state->getPipeline(),
false)) { | 121 GrPipeline::AreEqual(*fPrevState->getPipeline(), *state->getPipeline(),
false)) { |
134 this->unallocState(state); | 122 this->unallocState(state); |
135 } else { | 123 } else { |
136 fPrevState.reset(state); | 124 fPrevState.reset(state); |
137 } | 125 } |
138 | 126 |
139 return fPrevState; | 127 return fPrevState; |
140 } | 128 } |
OLD | NEW |