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" | 10 #include "GrBufferedDrawTarget.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 GrInOrderCommandBuilder::recordDrawPaths(State* state, | 71 GrInOrderCommandBuilder::recordDrawPaths(State* state, |
72 GrBufferedDrawTarget* bufferedDrawTarge
t, | 72 GrBufferedDrawTarget* bufferedDrawTarge
t, |
73 const GrPathProcessor* pathProc, | 73 const GrPathProcessor* pathProc, |
74 const GrPathRange* pathRange, | 74 const GrPathRange* pathRange, |
75 const void* indexValues, | 75 const void* indexValues, |
76 GrDrawTarget::PathIndexType indexType, | 76 GrDrawTarget::PathIndexType indexType, |
77 const float transformValues[], | 77 const float transformValues[], |
78 GrDrawTarget::PathTransformType transfo
rmType, | 78 GrDrawTarget::PathTransformType transfo
rmType, |
79 int count, | 79 int count, |
80 const GrStencilSettings& stencilSetting
s, | 80 const GrStencilSettings& stencilSetting
s, |
81 const GrDrawTarget::PipelineInfo& pipel
ineInfo) { | 81 const GrPipelineOptimizations& opts) { |
82 SkASSERT(pathRange); | 82 SkASSERT(pathRange); |
83 SkASSERT(indexValues); | 83 SkASSERT(indexValues); |
84 SkASSERT(transformValues); | 84 SkASSERT(transformValues); |
85 | 85 |
86 char* savedIndices; | 86 char* savedIndices; |
87 float* savedTransforms; | 87 float* savedTransforms; |
88 | 88 |
89 bufferedDrawTarget->appendIndicesAndTransforms(indexValues, indexType, | 89 bufferedDrawTarget->appendIndicesAndTransforms(indexValues, indexType, |
90 transformValues, transformTyp
e, | 90 transformValues, transformTyp
e, |
91 count, &savedIndices, &savedT
ransforms); | 91 count, &savedIndices, &savedT
ransforms); |
92 | 92 |
93 if (!this->cmdBuffer()->empty() && | 93 if (!this->cmdBuffer()->empty() && |
94 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { | 94 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { |
95 // Try to combine this call with the previous DrawPaths. We do this by s
tenciling all the | 95 // Try to combine this call with the previous DrawPaths. We do this by s
tenciling all the |
96 // paths together and then covering them in a single pass. This is not e
quivalent to two | 96 // paths together and then covering them in a single pass. This is not e
quivalent to two |
97 // separate draw calls, so we can only do it if there is no blending (no
overlap would also | 97 // separate draw calls, so we can only do it if there is no blending (no
overlap would also |
98 // work). Note that it's also possible for overlapping paths to cancel e
ach other's winding | 98 // work). Note that it's also possible for overlapping paths to cancel e
ach other's winding |
99 // numbers, and we only partially account for this by not allowing even/
odd paths to be | 99 // numbers, and we only partially account for this by not allowing even/
odd paths to be |
100 // combined. (Glyphs in the same font tend to wind the same direction so
it works out OK.) | 100 // combined. (Glyphs in the same font tend to wind the same direction so
it works out OK.) |
101 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); | 101 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); |
102 if (pathRange == previous->pathRange() && | 102 if (pathRange == previous->pathRange() && |
103 indexType == previous->fIndexType && | 103 indexType == previous->fIndexType && |
104 transformType == previous->fTransformType && | 104 transformType == previous->fTransformType && |
105 stencilSettings == previous->fStencilSettings && | 105 stencilSettings == previous->fStencilSettings && |
106 path_fill_type_is_winding(stencilSettings) && | 106 path_fill_type_is_winding(stencilSettings) && |
107 previous->fState == state && | 107 previous->fState == state && |
108 !pipelineInfo.willColorBlendWithDst(pathProc)) { | 108 !opts.willColorBlendWithDst()) { |
109 | 109 |
110 const int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 110 const int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
111 const int xformSize = GrPathRendering::PathTransformSize(transformTy
pe); | 111 const int xformSize = GrPathRendering::PathTransformSize(transformTy
pe); |
112 if (&previous->fIndices[previous->fCount * indexBytes] == savedIndic
es && | 112 if (&previous->fIndices[previous->fCount * indexBytes] == savedIndic
es && |
113 (0 == xformSize || | 113 (0 == xformSize || |
114 &previous->fTransforms[previous->fCount * xformSize] == savedTr
ansforms)) { | 114 &previous->fTransforms[previous->fCount * xformSize] == savedTr
ansforms)) { |
115 // Combine this DrawPaths call with the one previous. | 115 // Combine this DrawPaths call with the one previous. |
116 previous->fCount += count; | 116 previous->fCount += count; |
117 return NULL; | 117 return NULL; |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); | 122 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); |
123 dp->fIndices = savedIndices; | 123 dp->fIndices = savedIndices; |
124 dp->fIndexType = indexType; | 124 dp->fIndexType = indexType; |
125 dp->fTransforms = savedTransforms; | 125 dp->fTransforms = savedTransforms; |
126 dp->fTransformType = transformType; | 126 dp->fTransformType = transformType; |
127 dp->fCount = count; | 127 dp->fCount = count; |
128 dp->fStencilSettings = stencilSettings; | 128 dp->fStencilSettings = stencilSettings; |
129 return dp; | 129 return dp; |
130 } | 130 } |
OLD | NEW |