| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkPathOpsCubic_DEFINED | 8 #ifndef SkPathOpsCubic_DEFINED |
| 9 #define SkPathOpsCubic_DEFINED | 9 #define SkPathOpsCubic_DEFINED |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 fPts[1] = pts[1]; | 26 fPts[1] = pts[1]; |
| 27 fPts[2] = pts[2]; | 27 fPts[2] = pts[2]; |
| 28 fPts[3] = pts[3]; | 28 fPts[3] = pts[3]; |
| 29 } | 29 } |
| 30 | 30 |
| 31 static const int gPrecisionUnit; | 31 static const int gPrecisionUnit; |
| 32 | 32 |
| 33 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return
fPts[n]; } | 33 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < 4); return
fPts[n]; } |
| 34 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; } | 34 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < 4); return fPts[n]; } |
| 35 | 35 |
| 36 static int AddValidTs(double allRoots[3], int realRoots, double validRoots[3
]); |
| 36 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; | 37 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; |
| 38 double binarySearch(double step, double t, double axisIntercept, bool yAxis)
const; |
| 37 double calcPrecision() const; | 39 double calcPrecision() const; |
| 38 SkDCubicPair chopAt(double t) const; | 40 SkDCubicPair chopAt(double t) const; |
| 39 bool clockwise() const; | 41 bool clockwise() const; |
| 40 static void Coefficients(const double* cubic, double* A, double* B, double*
C, double* D); | 42 static void Coefficients(const double* cubic, double* A, double* B, double*
C, double* D); |
| 41 bool controlsContainedByEnds() const; | 43 bool controlsContainedByEnds() const; |
| 42 SkDVector dxdyAtT(double t) const; | 44 SkDVector dxdyAtT(double t) const; |
| 43 bool endsAreExtremaInXOrY() const; | 45 bool endsAreExtremaInXOrY() const; |
| 44 static int FindExtrema(double a, double b, double c, double d, double tValue
[2]); | 46 static int FindExtrema(double a, double b, double c, double d, double tValue
[2]); |
| 45 int findInflections(double tValues[]) const; | 47 int findInflections(double tValues[]) const; |
| 46 | 48 |
| 47 static int FindInflections(const SkPoint a[4], double tValues[]) { | 49 static int FindInflections(const SkPoint a[4], double tValues[]) { |
| 48 SkDCubic cubic; | 50 SkDCubic cubic; |
| 49 cubic.set(a); | 51 cubic.set(a); |
| 50 return cubic.findInflections(tValues); | 52 return cubic.findInflections(tValues); |
| 51 } | 53 } |
| 52 | 54 |
| 53 int findMaxCurvature(double tValues[]) const; | 55 int findMaxCurvature(double tValues[]) const; |
| 54 bool isLinear(int startIndex, int endIndex) const; | 56 bool isLinear(int startIndex, int endIndex) const; |
| 55 bool monotonicInY() const; | 57 bool monotonicInY() const; |
| 56 SkDPoint ptAtT(double t) const; | 58 SkDPoint ptAtT(double t) const; |
| 57 static int RootsReal(double A, double B, double C, double D, double t[3]); | 59 static int RootsReal(double A, double B, double C, double D, double t[3]); |
| 58 static int RootsValidT(const double A, const double B, const double C, doubl
e D, double s[3]); | 60 static int RootsValidT(const double A, const double B, const double C, doubl
e D, double s[3]); |
| 61 static int RootsValidT(const double A, const double B, const double C, doubl
e D, double s[3], |
| 62 int* sCount, double t[3]); |
| 63 void searchRoots(double allRoots[3], int realRoots, double* t, double axisIn
tercept, |
| 64 bool yAxis) const; |
| 59 bool serpentine() const; | 65 bool serpentine() const; |
| 60 SkDCubic subDivide(double t1, double t2) const; | 66 SkDCubic subDivide(double t1, double t2) const; |
| 61 | 67 |
| 62 static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) { | 68 static SkDCubic SubDivide(const SkPoint a[4], double t1, double t2) { |
| 63 SkDCubic cubic; | 69 SkDCubic cubic; |
| 64 cubic.set(a); | 70 cubic.set(a); |
| 65 return cubic.subDivide(t1, t2); | 71 return cubic.subDivide(t1, t2); |
| 66 } | 72 } |
| 67 | 73 |
| 68 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S
kDPoint p[2]) const; | 74 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S
kDPoint p[2]) const; |
| 69 | 75 |
| 70 static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoin
t& d, double t1, | 76 static void SubDivide(const SkPoint pts[4], const SkDPoint& a, const SkDPoin
t& d, double t1, |
| 71 double t2, SkDPoint p[2]) { | 77 double t2, SkDPoint p[2]) { |
| 72 SkDCubic cubic; | 78 SkDCubic cubic; |
| 73 cubic.set(pts); | 79 cubic.set(pts); |
| 74 cubic.subDivide(a, d, t1, t2, p); | 80 cubic.subDivide(a, d, t1, t2, p); |
| 75 } | 81 } |
| 76 | 82 |
| 77 SkDPoint top(double startT, double endT) const; | 83 SkDPoint top(double startT, double endT) const; |
| 78 void toQuadraticTs(double precision, SkTArray<double, true>* ts) const; | 84 void toQuadraticTs(double precision, SkTArray<double, true>* ts) const; |
| 79 SkDQuad toQuad() const; | 85 SkDQuad toQuad() const; |
| 80 | 86 |
| 81 // utilities callable by the user from the debugger when the implementation
code is linked in | 87 // utilities callable by the user from the debugger when the implementation
code is linked in |
| 82 void dump() const; | 88 void dump() const; |
| 83 void dumpNumber() const; | 89 void dumpNumber() const; |
| 84 }; | 90 }; |
| 85 | 91 |
| 86 #endif | 92 #endif |
| OLD | NEW |