| 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 "GrColor.h" | 10 #include "GrColor.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 char* savedIndices; | 84 char* savedIndices; |
| 85 float* savedTransforms; | 85 float* savedTransforms; |
| 86 | 86 |
| 87 iodb->appendIndicesAndTransforms(indexValues, indexType, | 87 iodb->appendIndicesAndTransforms(indexValues, indexType, |
| 88 transformValues, transformType, | 88 transformValues, transformType, |
| 89 count, &savedIndices, &savedTransforms); | 89 count, &savedIndices, &savedTransforms); |
| 90 | 90 |
| 91 if (!this->cmdBuffer()->empty() && | 91 if (!this->cmdBuffer()->empty() && |
| 92 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { | 92 Cmd::kDrawPaths_CmdType == this->cmdBuffer()->back().type()) { |
| 93 // The previous command was also DrawPaths. Try to collapse this call in
to the one | 93 // Try to combine this call with the previous DrawPaths. We do this by s
tenciling all the |
| 94 // before. Note that stenciling all the paths at once, then covering, ma
y not be | 94 // paths together and then covering them in a single pass. This is not e
quivalent to two |
| 95 // equivalent to two separate draw calls if there is overlap. Blending w
on't work, | 95 // separate draw calls, so we can only do it if there is no blending (no
overlap would also |
| 96 // and the combined calls may also cancel each other's winding numbers i
n some | 96 // work). Note that it's also possible for overlapping paths to cancel e
ach other's winding |
| 97 // places. For now the winding numbers are only an issue if the fill is
even/odd, | 97 // numbers, and we only partially account for this by not allowing even/
odd paths to be |
| 98 // because DrawPaths is currently only used for glyphs, and glyphs in th
e same | 98 // combined. (Glyphs in the same font tend to wind the same direction so
it works out OK.) |
| 99 // font tend to all wind in the same direction. | |
| 100 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); | 99 DrawPaths* previous = static_cast<DrawPaths*>(&this->cmdBuffer()->back()
); |
| 101 if (pathRange == previous->pathRange() && | 100 if (pathRange == previous->pathRange() && |
| 102 indexType == previous->fIndexType && | 101 indexType == previous->fIndexType && |
| 103 transformType == previous->fTransformType && | 102 transformType == previous->fTransformType && |
| 104 stencilSettings == previous->fStencilSettings && | 103 stencilSettings == previous->fStencilSettings && |
| 105 path_fill_type_is_winding(stencilSettings) && | 104 path_fill_type_is_winding(stencilSettings) && |
| 106 !pipelineInfo.willBlendWithDst(pathProc) && | 105 previous->fState == state && |
| 107 previous->fState == state) { | 106 !pipelineInfo.willColorBlendWithDst(pathProc)) { |
| 108 const int indexBytes = GrPathRange::PathIndexSizeInBytes(indexTy
pe); | 107 |
| 109 const int xformSize = GrPathRendering::PathTransformSize(transfo
rmType); | 108 const int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
| 110 if (&previous->fIndices[previous->fCount*indexBytes] == savedInd
ices && | 109 const int xformSize = GrPathRendering::PathTransformSize(transformTy
pe); |
| 111 (0 == xformSize || | 110 if (&previous->fIndices[previous->fCount * indexBytes] == savedIndic
es && |
| 112 &previous->fTransforms[previous->fCount*xformSize] == saved
Transforms)) { | 111 (0 == xformSize || |
| 113 // Fold this DrawPaths call into the one previous. | 112 &previous->fTransforms[previous->fCount * xformSize] == savedTr
ansforms)) { |
| 114 previous->fCount += count; | 113 // Combine this DrawPaths call with the one previous. |
| 115 return NULL; | 114 previous->fCount += count; |
| 116 } | 115 return NULL; |
| 116 } |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); | 120 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawPaths, (sta
te, pathRange)); |
| 121 dp->fIndices = savedIndices; | 121 dp->fIndices = savedIndices; |
| 122 dp->fIndexType = indexType; | 122 dp->fIndexType = indexType; |
| 123 dp->fTransforms = savedTransforms; | 123 dp->fTransforms = savedTransforms; |
| 124 dp->fTransformType = transformType; | 124 dp->fTransformType = transformType; |
| 125 dp->fCount = count; | 125 dp->fCount = count; |
| 126 dp->fStencilSettings = stencilSettings; | 126 dp->fStencilSettings = stencilSettings; |
| 127 return dp; | 127 return dp; |
| 128 } | 128 } |
| OLD | NEW |