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 | 12 |
13 /** 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 |
14 equation. | 14 equation. |
15 */ | 15 */ |
16 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); | 16 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]); |
17 | 17 |
18 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
20 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); | 20 SkPoint SkEvalQuadAt(const SkPoint src[3], SkScalar t); |
21 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); | 21 SkPoint SkEvalQuadTangentAt(const SkPoint src[3], SkScalar t); |
22 void SkChopQuadAt2(const SkPoint src[3], SkPoint dst[5], SkScalar t); | |
23 | 22 |
24 /** 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 |
25 0 <= t <= 1.0 | 24 0 <= t <= 1.0 |
26 */ | 25 */ |
27 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); |
28 | 27 |
29 /** 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, |
30 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: |
31 dst[0..2] and dst[2..4] | 30 dst[0..2] and dst[2..4] |
32 */ | 31 */ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 0 <= t <= 1.0 | 87 0 <= t <= 1.0 |
89 */ | 88 */ |
90 void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* locOrNull, | 89 void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* locOrNull, |
91 SkVector* tangentOrNull, SkVector* curvatureOrNull); | 90 SkVector* tangentOrNull, SkVector* curvatureOrNull); |
92 | 91 |
93 /** Given a src cubic bezier, chop it at the specified t value, | 92 /** Given a src cubic bezier, chop it at the specified t value, |
94 where 0 < t < 1, and return the two new cubics in dst: | 93 where 0 < t < 1, and return the two new cubics in dst: |
95 dst[0..3] and dst[3..6] | 94 dst[0..3] and dst[3..6] |
96 */ | 95 */ |
97 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t); | 96 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t); |
98 void SkChopCubicAt2(const SkPoint src[4], SkPoint dst[7], SkScalar t); | |
99 | 97 |
100 /** Given a src cubic bezier, chop it at the specified t values, | 98 /** Given a src cubic bezier, chop it at the specified t values, |
101 where 0 < t < 1, and return the new cubics in dst: | 99 where 0 < t < 1, and return the new cubics in dst: |
102 dst[0..3],dst[3..6],...,dst[3*t_count..3*(t_count+1)] | 100 dst[0..3],dst[3..6],...,dst[3*t_count..3*(t_count+1)] |
103 */ | 101 */ |
104 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[], const SkScalar t[], | 102 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[], const SkScalar t[], |
105 int t_count); | 103 int t_count); |
106 | 104 |
107 /** Given a src cubic bezier, chop it at the specified t == 1/2, | 105 /** Given a src cubic bezier, chop it at the specified t == 1/2, |
108 The new cubics are returned in dst[0..3] and dst[3..6] | 106 The new cubics are returned in dst[0..3] and dst[3..6] |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 private: | 305 private: |
308 enum { | 306 enum { |
309 kQuadCount = 8, // should handle most conics | 307 kQuadCount = 8, // should handle most conics |
310 kPointCount = 1 + 2 * kQuadCount, | 308 kPointCount = 1 + 2 * kQuadCount, |
311 }; | 309 }; |
312 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; | 310 SkAutoSTMalloc<kPointCount, SkPoint> fStorage; |
313 int fQuadCount; // #quads for current usage | 311 int fQuadCount; // #quads for current usage |
314 }; | 312 }; |
315 | 313 |
316 #endif | 314 #endif |
OLD | NEW |