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 "GrInOrderCommandBuilder.h" | 8 #include "GrInOrderCommandBuilder.h" |
9 | 9 |
| 10 #include "GrBufferedDrawTarget.h" |
| 11 |
10 #include "GrColor.h" | 12 #include "GrColor.h" |
11 #include "GrInOrderDrawBuffer.h" | |
12 #include "SkPoint.h" | 13 #include "SkPoint.h" |
13 | 14 |
14 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin
gs) { | 15 static bool path_fill_type_is_winding(const GrStencilSettings& pathStencilSettin
gs) { |
15 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa
ce; | 16 static const GrStencilSettings::Face pathFace = GrStencilSettings::kFront_Fa
ce; |
16 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace); | 17 bool isWinding = kInvert_StencilOp != pathStencilSettings.passOp(pathFace); |
17 if (isWinding) { | 18 if (isWinding) { |
18 // Double check that it is in fact winding. | 19 // Double check that it is in fact winding. |
19 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.passOp(pathFace)); | 20 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.passOp(pathFace)); |
20 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.failOp(pathFace)); | 21 SkASSERT(kIncClamp_StencilOp == pathStencilSettings.failOp(pathFace)); |
21 SkASSERT(0x1 != pathStencilSettings.writeMask(pathFace)); | 22 SkASSERT(0x1 != pathStencilSettings.writeMask(pathFace)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const GrPathProcessor* pathProc, | 61 const GrPathProcessor* pathProc, |
61 const GrPath* path, | 62 const GrPath* path, |
62 const GrStencilSettings& stencilSettings
) { | 63 const GrStencilSettings& stencilSettings
) { |
63 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPath, (state
, path)); | 64 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPath, (state
, path)); |
64 dp->fStencilSettings = stencilSettings; | 65 dp->fStencilSettings = stencilSettings; |
65 return dp; | 66 return dp; |
66 } | 67 } |
67 | 68 |
68 GrTargetCommands::Cmd* | 69 GrTargetCommands::Cmd* |
69 GrInOrderCommandBuilder::recordDrawPaths(State* state, | 70 GrInOrderCommandBuilder::recordDrawPaths(State* state, |
70 GrInOrderDrawBuffer* iodb, | 71 GrBufferedDrawTarget* bufferedDrawTarge
t, |
71 const GrPathProcessor* pathProc, | 72 const GrPathProcessor* pathProc, |
72 const GrPathRange* pathRange, | 73 const GrPathRange* pathRange, |
73 const void* indexValues, | 74 const void* indexValues, |
74 GrDrawTarget::PathIndexType indexType, | 75 GrDrawTarget::PathIndexType indexType, |
75 const float transformValues[], | 76 const float transformValues[], |
76 GrDrawTarget::PathTransformType transfo
rmType, | 77 GrDrawTarget::PathTransformType transfo
rmType, |
77 int count, | 78 int count, |
78 const GrStencilSettings& stencilSetting
s, | 79 const GrStencilSettings& stencilSetting
s, |
79 const GrDrawTarget::PipelineInfo& pipel
ineInfo) { | 80 const GrDrawTarget::PipelineInfo& pipel
ineInfo) { |
80 SkASSERT(pathRange); | 81 SkASSERT(pathRange); |
81 SkASSERT(indexValues); | 82 SkASSERT(indexValues); |
82 SkASSERT(transformValues); | 83 SkASSERT(transformValues); |
83 | 84 |
84 char* savedIndices; | 85 char* savedIndices; |
85 float* savedTransforms; | 86 float* savedTransforms; |
86 | 87 |
87 iodb->appendIndicesAndTransforms(indexValues, indexType, | 88 bufferedDrawTarget->appendIndicesAndTransforms(indexValues, indexType, |
88 transformValues, transformType, | 89 transformValues, transformTyp
e, |
89 count, &savedIndices, &savedTransforms); | 90 count, &savedIndices, &savedT
ransforms); |
90 | 91 |
91 if (!this->cmdBuffer()->empty() && | 92 if (!this->cmdBuffer()->empty() && |
92 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { | 93 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { |
93 // Try to combine this call with the previous DrawPaths. We do this by s
tenciling all the | 94 // Try to combine this call with the previous DrawPaths. We do this by s
tenciling all the |
94 // paths together and then covering them in a single pass. This is not e
quivalent to two | 95 // paths together and then covering them in a single pass. This is not e
quivalent to two |
95 // separate draw calls, so we can only do it if there is no blending (no
overlap would also | 96 // separate draw calls, so we can only do it if there is no blending (no
overlap would also |
96 // work). Note that it's also possible for overlapping paths to cancel e
ach other's winding | 97 // work). Note that it's also possible for overlapping paths to cancel e
ach other's winding |
97 // numbers, and we only partially account for this by not allowing even/
odd paths to be | 98 // numbers, and we only partially account for this by not allowing even/
odd paths to be |
98 // combined. (Glyphs in the same font tend to wind the same direction so
it works out OK.) | 99 // combined. (Glyphs in the same font tend to wind the same direction so
it works out OK.) |
99 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); | 100 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 120 |
120 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); | 121 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); |
121 dp->fIndices = savedIndices; | 122 dp->fIndices = savedIndices; |
122 dp->fIndexType = indexType; | 123 dp->fIndexType = indexType; |
123 dp->fTransforms = savedTransforms; | 124 dp->fTransforms = savedTransforms; |
124 dp->fTransformType = transformType; | 125 dp->fTransformType = transformType; |
125 dp->fCount = count; | 126 dp->fCount = count; |
126 dp->fStencilSettings = stencilSettings; | 127 dp->fStencilSettings = stencilSettings; |
127 return dp; | 128 return dp; |
128 } | 129 } |
OLD | NEW |