OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 SkGeometry_DEFINED | 8 #ifndef SkGeometry_DEFINED |
9 #define SkGeometry_DEFINED | 9 #define SkGeometry_DEFINED |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); | 32 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); |
33 | 33 |
34 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
35 | 35 |
36 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); | 36 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); |
37 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); | 37 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); |
38 | 38 |
39 /** Set pt to the point on the src quadratic specified by t. t must be | 39 /** Set pt to the point on the src quadratic specified by t. t must be |
40 0 <= t <= 1.0 | 40 0 <= t <= 1.0 |
41 */ | 41 */ |
42 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange
nt = NULL); | 42 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange
nt = nullptr); |
43 | 43 |
44 /** | 44 /** |
45 * output is : eval(t) == coeff[0] * t^2 + coeff[1] * t + coeff[2] | 45 * output is : eval(t) == coeff[0] * t^2 + coeff[1] * t + coeff[2] |
46 */ | 46 */ |
47 void SkQuadToCoeff(const SkPoint pts[3], SkPoint coeff[3]); | 47 void SkQuadToCoeff(const SkPoint pts[3], SkPoint coeff[3]); |
48 | 48 |
49 /** | 49 /** |
50 * output is : eval(t) == coeff[0] * t^3 + coeff[1] * t^2 + coeff[2] * t + coef
f[3] | 50 * output is : eval(t) == coeff[0] * t^3 + coeff[1] * t^2 + coeff[2] * t + coef
f[3] |
51 */ | 51 */ |
52 void SkCubicToCoeff(const SkPoint pts[4], SkPoint coeff[4]); | 52 void SkCubicToCoeff(const SkPoint pts[4], SkPoint coeff[4]); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[2]); | 157 int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[2]); |
158 | 158 |
159 /** Return 1 for no chop, 2 for having chopped the cubic at a single | 159 /** Return 1 for no chop, 2 for having chopped the cubic at a single |
160 inflection point, 3 for having chopped at 2 inflection points. | 160 inflection point, 3 for having chopped at 2 inflection points. |
161 dst will hold the resulting 1, 2, or 3 cubics. | 161 dst will hold the resulting 1, 2, or 3 cubics. |
162 */ | 162 */ |
163 int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10]); | 163 int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10]); |
164 | 164 |
165 int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3]); | 165 int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3]); |
166 int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], | 166 int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], |
167 SkScalar tValues[3] = NULL); | 167 SkScalar tValues[3] = nullptr); |
168 | 168 |
169 bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar y, SkPoint dst[7]); | 169 bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar y, SkPoint dst[7]); |
170 bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar x, SkPoint dst[7]); | 170 bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar x, SkPoint dst[7]); |
171 | 171 |
172 enum SkCubicType { | 172 enum SkCubicType { |
173 kSerpentine_SkCubicType, | 173 kSerpentine_SkCubicType, |
174 kCusp_SkCubicType, | 174 kCusp_SkCubicType, |
175 kLoop_SkCubicType, | 175 kLoop_SkCubicType, |
176 kQuadratic_SkCubicType, | 176 kQuadratic_SkCubicType, |
177 kLine_SkCubicType, | 177 kLine_SkCubicType, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 fW = w; | 232 fW = w; |
233 } | 233 } |
234 | 234 |
235 /** | 235 /** |
236 * Given a t-value [0...1] return its position and/or tangent. | 236 * Given a t-value [0...1] return its position and/or tangent. |
237 * If pos is not null, return its position at the t-value. | 237 * If pos is not null, return its position at the t-value. |
238 * If tangent is not null, return its tangent at the t-value. NOTE the | 238 * If tangent is not null, return its tangent at the t-value. NOTE the |
239 * tangent value's length is arbitrary, and only its direction should | 239 * tangent value's length is arbitrary, and only its direction should |
240 * be used. | 240 * be used. |
241 */ | 241 */ |
242 void evalAt(SkScalar t, SkPoint* pos, SkVector* tangent = NULL) const; | 242 void evalAt(SkScalar t, SkPoint* pos, SkVector* tangent = nullptr) const; |
243 void chopAt(SkScalar t, SkConic dst[2]) const; | 243 void chopAt(SkScalar t, SkConic dst[2]) const; |
244 void chop(SkConic dst[2]) const; | 244 void chop(SkConic dst[2]) const; |
245 | 245 |
246 SkPoint evalAt(SkScalar t) const; | 246 SkPoint evalAt(SkScalar t) const; |
247 SkVector evalTangentAt(SkScalar t) const; | 247 SkVector evalTangentAt(SkScalar t) const; |
248 | 248 |
249 void computeAsQuadError(SkVector* err) const; | 249 void computeAsQuadError(SkVector* err) const; |
250 bool asQuadTol(SkScalar tol) const; | 250 bool asQuadTol(SkScalar tol) const; |
251 | 251 |
252 /** | 252 /** |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 private: | 328 private: |
329 enum { | 329 enum { |
330 kQuadCount = 8, // should handle most conics | 330 kQuadCount = 8, // should handle most conics |
331 kPointCount = 1 + 2 * kQuadCount, | 331 kPointCount = 1 + 2 * kQuadCount, |
332 }; | 332 }; |
333 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; | 333 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; |
334 int fQuadCount; // #quads for current usage | 334 int fQuadCount; // #quads for current usage |
335 }; | 335 }; |
336 | 336 |
337 #endif | 337 #endif |
OLD | NEW |