| 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 |
| 11 #include "SkMatrix.h" | 11 #include "SkMatrix.h" |
| 12 #include "SkNx.h" | |
| 13 | |
| 14 static inline Sk2s from_point(const SkPoint& point) { | |
| 15 return Sk2s::Load(&point.fX); | |
| 16 } | |
| 17 | |
| 18 static inline SkPoint to_point(const Sk2s& x) { | |
| 19 SkPoint point; | |
| 20 x.store(&point.fX); | |
| 21 return point; | |
| 22 } | |
| 23 | |
| 24 static inline Sk2s sk2s_cubic_eval(const Sk2s& A, const Sk2s& B, const Sk2s& C,
const Sk2s& D, | |
| 25 const Sk2s& t) { | |
| 26 return ((A * t + B) * t + C) * t + D; | |
| 27 } | |
| 28 | 12 |
| 29 /** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the | 13 /** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the |
| 30 equation. | 14 equation. |
| 31 */ | 15 */ |
| 32 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); | 16 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); |
| 33 | 17 |
| 34 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
| 35 | 19 |
| 36 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); | 20 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); |
| 37 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); | 21 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); |
| 38 | 22 |
| 39 /** Set pt to the point on the src quadratic specified by t. t must be | 23 /** Set pt to the point on the src quadratic specified by t. t must be |
| 40 0 <= t <= 1.0 | 24 0 <= t <= 1.0 |
| 41 */ | 25 */ |
| 42 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange
nt = NULL); | 26 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange
nt = NULL); |
| 43 | 27 |
| 44 /** | |
| 45 * output is : eval(t) == coeff[0] * t^2 + coeff[1] * t + coeff[2] | |
| 46 */ | |
| 47 void SkQuadToCoeff(const SkPoint pts[3], SkPoint coeff[3]); | |
| 48 | |
| 49 /** | |
| 50 * output is : eval(t) == coeff[0] * t^3 + coeff[1] * t^2 + coeff[2] * t + coef
f[3] | |
| 51 */ | |
| 52 void SkCubicToCoeff(const SkPoint pts[4], SkPoint coeff[4]); | |
| 53 | |
| 54 /** Given a src quadratic bezier, chop it at the specified t value, | 28 /** Given a src quadratic bezier, chop it at the specified t value, |
| 55 where 0 < t < 1, and return the two new quadratics in dst: | 29 where 0 < t < 1, and return the two new quadratics in dst: |
| 56 dst[0..2] and dst[2..4] | 30 dst[0..2] and dst[2..4] |
| 57 */ | 31 */ |
| 58 void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t); | 32 void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t); |
| 59 | 33 |
| 60 /** Given a src quadratic bezier, chop it at the specified t == 1/2, | 34 /** Given a src quadratic bezier, chop it at the specified t == 1/2, |
| 61 The new quads are returned in dst[0..2] and dst[2..4] | 35 The new quads are returned in dst[0..2] and dst[2..4] |
| 62 */ | 36 */ |
| 63 void SkChopQuadAtHalf(const SkPoint src[3], SkPoint dst[5]); | 37 void SkChopQuadAtHalf(const SkPoint src[3], SkPoint dst[5]); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 private: | 304 private: |
| 331 enum { | 305 enum { |
| 332 kQuadCount = 8, // should handle most conics | 306 kQuadCount = 8, // should handle most conics |
| 333 kPointCount = 1 + 2 * kQuadCount, | 307 kPointCount = 1 + 2 * kQuadCount, |
| 334 }; | 308 }; |
| 335 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; | 309 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; |
| 336 int fQuadCount; // #quads for current usage | 310 int fQuadCount; // #quads for current usage |
| 337 }; | 311 }; |
| 338 | 312 |
| 339 #endif | 313 #endif |
| OLD | NEW |