OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 SkCurveMeasure_DEFINED | 8 #ifndef SkCurveMeasure_DEFINED |
9 #define SkCurveMeasure_DEFINED | 9 #define SkCurveMeasure_DEFINED |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 SkSegType fSegType; | 37 SkSegType fSegType; |
38 | 38 |
39 // precomputed coefficients for derivatives in Horner form | 39 // precomputed coefficients for derivatives in Horner form |
40 Sk8f xCoeff[3]; | 40 Sk8f xCoeff[3]; |
41 Sk8f yCoeff[3]; | 41 Sk8f yCoeff[3]; |
42 }; | 42 }; |
43 | 43 |
44 class SkCurveMeasure { | 44 class SkCurveMeasure { |
45 public: | 45 public: |
46 SkCurveMeasure() {} | 46 SkCurveMeasure() {} |
| 47 |
| 48 // Almost exactly the same as in SkPath::Iter: |
| 49 // kLine_SegType -> 2 points: start end |
| 50 // kQuad_SegType -> 3 points: start control end |
| 51 // kCubic_SegType -> 4 points: start control1 control2 end |
| 52 // kConic_SegType -> 4 points: start control end (w, w) |
| 53 // |
| 54 // i.e. the only difference is that the conic's last point is a point |
| 55 // consisting of the w value twice |
47 SkCurveMeasure(const SkPoint* pts, SkSegType segType); | 56 SkCurveMeasure(const SkPoint* pts, SkSegType segType); |
48 | 57 |
49 SkScalar getTime(SkScalar targetLength); | 58 SkScalar getTime(SkScalar targetLength); |
50 void getPosTanTime(SkScalar distance, SkPoint* pos, SkVector* tan, SkScalar*
time); | 59 void getPosTanTime(SkScalar distance, SkPoint* pos, SkVector* tan, SkScalar*
time); |
51 SkScalar getLength(); | 60 SkScalar getLength(); |
52 | 61 |
53 private: | 62 private: |
54 SkPoint evaluateQuad(SkScalar t); | |
55 SkVector evaluateQuadDerivative(SkScalar t); | |
56 //SkPoint evaluate_cubic(SkScalar t); | |
57 //SkVector evaluate_cubic_derivative(SkScalar t); | |
58 //SkPoint evaluate_conic(SkScalar t); | |
59 //SkVector evaluate_conic_derivative(SkScalar t); | |
60 | |
61 const SkScalar kTolerance = 0.0001f; | 63 const SkScalar kTolerance = 0.0001f; |
62 const int kNewtonIters = 5; | 64 const int kNewtonIters = 5; |
63 const int kBisectIters = 5; | 65 const int kBisectIters = 5; |
64 | 66 |
65 SkSegType fSegType; | 67 SkSegType fSegType; |
66 SkPoint fPts[4]; | 68 SkPoint fPts[4]; |
67 SkScalar fLength = -1.0f; | 69 SkScalar fLength = -1.0f; |
68 ArcLengthIntegrator fIntegrator; | 70 ArcLengthIntegrator fIntegrator; |
69 | 71 |
70 // for debug purposes | 72 // for debug purposes |
71 int fIters; | 73 int fIters; |
72 }; | 74 }; |
73 | 75 |
74 #endif // SkCurveMeasure_DEFINED | 76 #endif // SkCurveMeasure_DEFINED |
OLD | NEW |