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 #ifndef GrPathUtils_DEFINED | 8 #ifndef GrPathUtils_DEFINED |
9 #define GrPathUtils_DEFINED | 9 #define GrPathUtils_DEFINED |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 SkScalar tolScale, | 122 SkScalar tolScale, |
123 bool constrainWithinTangents, | 123 bool constrainWithinTangents, |
124 SkPathPriv::FirstDirection dir, | 124 SkPathPriv::FirstDirection dir, |
125 SkTArray<SkPoint, true>* quads); | 125 SkTArray<SkPoint, true>* quads); |
126 | 126 |
127 // Chops the cubic bezier passed in by src, at the double point (intersectio
n point) | 127 // Chops the cubic bezier passed in by src, at the double point (intersectio
n point) |
128 // if the curve is a cubic loop. If it is a loop, there will be two parametr
ic values for | 128 // if the curve is a cubic loop. If it is a loop, there will be two parametr
ic values for |
129 // the double point: ls and ms. We chop the cubic at these values if they ar
e between 0 and 1. | 129 // the double point: ls and ms. We chop the cubic at these values if they ar
e between 0 and 1. |
130 // Return value: | 130 // Return value: |
131 // Value of 3: ls and ms are both between (0,1), and dst will contain the th
ree cubics, | 131 // Value of 3: ls and ms are both between (0,1), and dst will contain the th
ree cubics, |
132 // dst[0..3], dst[3..6], and dst[6..9] if dst is not NULL | 132 // dst[0..3], dst[3..6], and dst[6..9] if dst is not nullptr |
133 // Value of 2: Only one of ls and ms are between (0,1), and dst will contain
the two cubics, | 133 // Value of 2: Only one of ls and ms are between (0,1), and dst will contain
the two cubics, |
134 // dst[0..3] and dst[3..6] if dst is not NULL | 134 // dst[0..3] and dst[3..6] if dst is not nullptr |
135 // Value of 1: Neither ls or ms are between (0,1), and dst will contain the
one original cubic, | 135 // Value of 1: Neither ls or ms are between (0,1), and dst will contain the
one original cubic, |
136 // dst[0..3] if dst is not NULL | 136 // dst[0..3] if dst is not nullptr |
137 // | 137 // |
138 // Optional KLM Calculation: | 138 // Optional KLM Calculation: |
139 // The function can also return the KLM linear functionals for the chopped c
ubic implicit form | 139 // The function can also return the KLM linear functionals for the chopped c
ubic implicit form |
140 // of K^3 - LM. | 140 // of K^3 - LM. |
141 // It will calculate a single set of KLM values that can be shared by all su
b cubics, except | 141 // It will calculate a single set of KLM values that can be shared by all su
b cubics, except |
142 // for the subsection that is "the loop" the K and L values need to be negat
ed. | 142 // for the subsection that is "the loop" the K and L values need to be negat
ed. |
143 // Output: | 143 // Output: |
144 // klm: Holds the values for the linear functionals as: | 144 // klm: Holds the values for the linear functionals as: |
145 // K = (klm[0], klm[1], klm[2]) | 145 // K = (klm[0], klm[1], klm[2]) |
146 // L = (klm[3], klm[4], klm[5]) | 146 // L = (klm[3], klm[4], klm[5]) |
147 // M = (klm[6], klm[7], klm[8]) | 147 // M = (klm[6], klm[7], klm[8]) |
148 // klm_rev: These values are flags for the corresponding sub cubic saying wh
ether or not | 148 // klm_rev: These values are flags for the corresponding sub cubic saying wh
ether or not |
149 // the K and L values need to be flipped. A value of -1.f means fli
p K and L and | 149 // the K and L values need to be flipped. A value of -1.f means fli
p K and L and |
150 // a value of 1.f means do nothing. | 150 // a value of 1.f means do nothing. |
151 // *****DO NOT FLIP M, JUST K AND L***** | 151 // *****DO NOT FLIP M, JUST K AND L***** |
152 // | 152 // |
153 // Notice that the klm lines are calculated in the same space as the input c
ontrol points. | 153 // Notice that the klm lines are calculated in the same space as the input c
ontrol points. |
154 // If you transform the points the lines will also need to be transformed. T
his can be done | 154 // If you transform the points the lines will also need to be transformed. T
his can be done |
155 // by mapping the lines with the inverse-transpose of the matrix used to map
the points. | 155 // by mapping the lines with the inverse-transpose of the matrix used to map
the points. |
156 int chopCubicAtLoopIntersection(const SkPoint src[4], SkPoint dst[10] = NULL
, | 156 int chopCubicAtLoopIntersection(const SkPoint src[4], SkPoint dst[10] = null
ptr, |
157 SkScalar klm[9] = NULL, SkScalar klm_rev[3]
= NULL); | 157 SkScalar klm[9] = nullptr, SkScalar klm_rev[
3] = nullptr); |
158 | 158 |
159 // Input is p which holds the 4 control points of a non-rational cubic Bezie
r curve. | 159 // Input is p which holds the 4 control points of a non-rational cubic Bezie
r curve. |
160 // Output is the coefficients of the three linear functionals K, L, & M whic
h | 160 // Output is the coefficients of the three linear functionals K, L, & M whic
h |
161 // represent the implicit form of the cubic as f(x,y,w) = K^3 - LM. The w te
rm | 161 // represent the implicit form of the cubic as f(x,y,w) = K^3 - LM. The w te
rm |
162 // will always be 1. The output is stored in the array klm, where the values
are: | 162 // will always be 1. The output is stored in the array klm, where the values
are: |
163 // K = (klm[0], klm[1], klm[2]) | 163 // K = (klm[0], klm[1], klm[2]) |
164 // L = (klm[3], klm[4], klm[5]) | 164 // L = (klm[3], klm[4], klm[5]) |
165 // M = (klm[6], klm[7], klm[8]) | 165 // M = (klm[6], klm[7], klm[8]) |
166 // | 166 // |
167 // Notice that the klm lines are calculated in the same space as the input c
ontrol points. | 167 // Notice that the klm lines are calculated in the same space as the input c
ontrol points. |
168 // If you transform the points the lines will also need to be transformed. T
his can be done | 168 // If you transform the points the lines will also need to be transformed. T
his can be done |
169 // by mapping the lines with the inverse-transpose of the matrix used to map
the points. | 169 // by mapping the lines with the inverse-transpose of the matrix used to map
the points. |
170 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]); | 170 void getCubicKLM(const SkPoint p[4], SkScalar klm[9]); |
171 | 171 |
172 // When tessellating curved paths into linear segments, this defines the max
imum distance | 172 // When tessellating curved paths into linear segments, this defines the max
imum distance |
173 // in screen space which a segment may deviate from the mathmatically correc
t value. | 173 // in screen space which a segment may deviate from the mathmatically correc
t value. |
174 // Above this value, the segment will be subdivided. | 174 // Above this value, the segment will be subdivided. |
175 // This value was chosen to approximate the supersampling accuracy of the ra
ster path (16 | 175 // This value was chosen to approximate the supersampling accuracy of the ra
ster path (16 |
176 // samples, or one quarter pixel). | 176 // samples, or one quarter pixel). |
177 static const SkScalar kDefaultTolerance = SkDoubleToScalar(0.25); | 177 static const SkScalar kDefaultTolerance = SkDoubleToScalar(0.25); |
178 }; | 178 }; |
179 #endif | 179 #endif |
OLD | NEW |