| 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 SkPathOpsQuad_DEFINED | 8 #ifndef SkPathOpsQuad_DEFINED |
| 9 #define SkPathOpsQuad_DEFINED | 9 #define SkPathOpsQuad_DEFINED |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 return v02.dot(v01) > 0 && v02.dot(v12) > 0; | 34 return v02.dot(v01) > 0 && v02.dot(v12) > 0; |
| 35 } | 35 } |
| 36 | 36 |
| 37 SkDQuad flip() const { | 37 SkDQuad flip() const { |
| 38 SkDQuad result = {{fPts[2], fPts[1], fPts[0]}}; | 38 SkDQuad result = {{fPts[2], fPts[1], fPts[0]}}; |
| 39 return result; | 39 return result; |
| 40 } | 40 } |
| 41 | 41 |
| 42 static bool IsCubic() { return false; } | 42 static bool IsCubic() { return false; } |
| 43 | 43 |
| 44 void set(const SkPoint pts[kPointCount]) { | 44 const SkDQuad& set(const SkPoint pts[kPointCount]) { |
| 45 fPts[0] = pts[0]; | 45 fPts[0] = pts[0]; |
| 46 fPts[1] = pts[1]; | 46 fPts[1] = pts[1]; |
| 47 fPts[2] = pts[2]; | 47 fPts[2] = pts[2]; |
| 48 return *this; |
| 48 } | 49 } |
| 49 | 50 |
| 50 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount
); return fPts[n]; } | 51 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount
); return fPts[n]; } |
| 51 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP
ts[n]; } | 52 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP
ts[n]; } |
| 52 | 53 |
| 53 static int AddValidTs(double s[], int realRoots, double* t); | 54 static int AddValidTs(double s[], int realRoots, double* t); |
| 54 void align(int endIndex, SkDPoint* dstPt) const; | 55 void align(int endIndex, SkDPoint* dstPt) const; |
| 55 SkDQuadPair chopAt(double t) const; | 56 SkDQuadPair chopAt(double t) const; |
| 56 SkDVector dxdyAtT(double t) const; | 57 SkDVector dxdyAtT(double t) const; |
| 57 static int FindExtrema(double a, double b, double c, double tValue[1]); | 58 static int FindExtrema(double a, double b, double c, double tValue[1]); |
| 58 bool hullIntersects(const SkDQuad& , bool* isLinear) const; | 59 bool hullIntersects(const SkDQuad& , bool* isLinear) const; |
| 60 bool hullIntersects(const SkDConic& , bool* isLinear) const; |
| 61 bool hullIntersects(const SkDCubic& , bool* isLinear) const; |
| 59 bool isLinear(int startIndex, int endIndex) const; | 62 bool isLinear(int startIndex, int endIndex) const; |
| 60 bool monotonicInY() const; | 63 bool monotonicInY() const; |
| 61 double nearestT(const SkDPoint&) const; | 64 double nearestT(const SkDPoint&) const; |
| 62 void otherPts(int oddMan, const SkDPoint* endPt[2]) const; | 65 void otherPts(int oddMan, const SkDPoint* endPt[2]) const; |
| 63 SkDPoint ptAtT(double t) const; | 66 SkDPoint ptAtT(double t) const; |
| 64 static int RootsReal(double A, double B, double C, double t[2]); | 67 static int RootsReal(double A, double B, double C, double t[2]); |
| 65 static int RootsValidT(const double A, const double B, const double C, doubl
e s[2]); | 68 static int RootsValidT(const double A, const double B, const double C, doubl
e s[2]); |
| 66 static void SetABC(const double* quad, double* a, double* b, double* c); | 69 static void SetABC(const double* quad, double* a, double* b, double* c); |
| 67 SkDQuad subDivide(double t1, double t2) const; | 70 SkDQuad subDivide(double t1, double t2) const; |
| 68 static SkDQuad SubDivide(const SkPoint a[kPointCount], double t1, double t2)
{ | 71 static SkDQuad SubDivide(const SkPoint a[kPointCount], double t1, double t2)
{ |
| 69 SkDQuad quad; | 72 SkDQuad quad; |
| 70 quad.set(a); | 73 quad.set(a); |
| 71 return quad.subDivide(t1, t2); | 74 return quad.subDivide(t1, t2); |
| 72 } | 75 } |
| 73 SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t
2) const; | 76 SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t
2) const; |
| 74 static SkDPoint SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a,
const SkDPoint& c, | 77 static SkDPoint SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a,
const SkDPoint& c, |
| 75 double t1, double t2) { | 78 double t1, double t2) { |
| 76 SkDQuad quad; | 79 SkDQuad quad; |
| 77 quad.set(pts); | 80 quad.set(pts); |
| 78 return quad.subDivide(a, c, t1, t2); | 81 return quad.subDivide(a, c, t1, t2); |
| 79 } | 82 } |
| 83 SkDConic toConic() const; |
| 80 SkDCubic toCubic() const; | 84 SkDCubic toCubic() const; |
| 81 SkDPoint top(double startT, double endT) const; | 85 SkDPoint top(double startT, double endT) const; |
| 82 | 86 |
| 83 // 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 |
| 84 void dump() const; | 88 void dump() const; |
| 85 void dumpID(int id) const; | 89 void dumpID(int id) const; |
| 86 void dumpInner() const; | 90 void dumpInner() const; |
| 87 | 91 |
| 88 private: | 92 private: |
| 89 // static double Tangent(const double* quadratic, double t); // uncalled | 93 // static double Tangent(const double* quadratic, double t); // uncalled |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 #endif | 96 #endif |
| OLD | NEW |