| 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 |
| 11 #include "SkPathMeasurePriv.h" |
| 11 #include "SkPoint.h" | 12 #include "SkPoint.h" |
| 12 #include "SkNx.h" | 13 #include "SkNx.h" |
| 13 | 14 |
| 14 // These are weights and abscissae for gaussian quadrature with weight function | 15 // These are weights and abscissae for gaussian quadrature with weight function |
| 15 // w(x) = 1 | 16 // w(x) = 1 |
| 16 static SkScalar weights8[8] = {0.3626837833783620f, 0.3626837833783620f, | 17 static SkScalar weights8[8] = {0.3626837833783620f, 0.3626837833783620f, |
| 17 0.3137066458778873f, 0.3137066458778873f, | 18 0.3137066458778873f, 0.3137066458778873f, |
| 18 0.2223810344533745f, 0.2223810344533745f, | 19 0.2223810344533745f, 0.2223810344533745f, |
| 19 0.1012285362903763f, 0.1012285362903763f}; | 20 0.1012285362903763f, 0.1012285362903763f}; |
| 20 static SkScalar absc8[8] = {-0.1834346424956498f, 0.1834346424956498f, | 21 static SkScalar absc8[8] = {-0.1834346424956498f, 0.1834346424956498f, |
| 21 -0.5255324099163290f, 0.5255324099163290f, | 22 -0.5255324099163290f, 0.5255324099163290f, |
| 22 -0.7966664774136267f, 0.7966664774136267f, | 23 -0.7966664774136267f, 0.7966664774136267f, |
| 23 -0.9602898564975363f, 0.9602898564975363f}; | 24 -0.9602898564975363f, 0.9602898564975363f}; |
| 24 | 25 |
| 25 static Sk8f weights = Sk8f::Load(weights8); | 26 static Sk8f weights = Sk8f::Load(weights8); |
| 26 static Sk8f absc = 0.5f*(Sk8f::Load(absc8) + 1.0f); | 27 static Sk8f absc = 0.5f*(Sk8f::Load(absc8) + 1.0f); |
| 27 | 28 |
| 28 | 29 |
| 29 // this is the same enum as in SkPathMeasure but it doesn't have a name there | |
| 30 enum SkSegType { | |
| 31 kLine_SegType, | |
| 32 kQuad_SegType, | |
| 33 kCubic_SegType, | |
| 34 kConic_SegType, | |
| 35 }; | |
| 36 | |
| 37 class ArcLengthIntegrator { | 30 class ArcLengthIntegrator { |
| 38 public: | 31 public: |
| 39 ArcLengthIntegrator() {} | 32 ArcLengthIntegrator() {} |
| 40 ArcLengthIntegrator(const SkPoint* pts, SkSegType segType); | 33 ArcLengthIntegrator(const SkPoint* pts, SkSegType segType); |
| 41 SkScalar computeLength(SkScalar t); | 34 SkScalar computeLength(SkScalar t); |
| 42 | 35 |
| 43 private: | 36 private: |
| 44 SkSegType fSegType; | 37 SkSegType fSegType; |
| 45 | 38 |
| 46 // precomputed coefficients for derivatives in Horner form | 39 // precomputed coefficients for derivatives in Horner form |
| (...skipping 25 matching lines...) Expand all Loading... |
| 72 SkSegType fSegType; | 65 SkSegType fSegType; |
| 73 SkPoint fPts[4]; | 66 SkPoint fPts[4]; |
| 74 SkScalar fLength = -1.0f; | 67 SkScalar fLength = -1.0f; |
| 75 ArcLengthIntegrator fIntegrator; | 68 ArcLengthIntegrator fIntegrator; |
| 76 | 69 |
| 77 // for debug purposes | 70 // for debug purposes |
| 78 int fIters; | 71 int fIters; |
| 79 }; | 72 }; |
| 80 | 73 |
| 81 #endif // SkCurveMeasure_DEFINED | 74 #endif // SkCurveMeasure_DEFINED |
| OLD | NEW |