OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkPathOpsConic_DEFINED |
| 9 #define SkPathOpsConic_DEFINED |
| 10 |
| 11 #include "SkPathOpsPoint.h" |
| 12 #include "SkPathOpsQuad.h" |
| 13 |
| 14 struct SkDConic { |
| 15 static const int kPointCount = 3; |
| 16 static const int kPointLast = kPointCount - 1; |
| 17 static const int kMaxIntersections = 4; |
| 18 |
| 19 SkDQuad fPts; |
| 20 SkScalar fWeight; |
| 21 |
| 22 bool collapsed() const { |
| 23 return fPts.collapsed(); |
| 24 } |
| 25 |
| 26 bool controlsInside() const { |
| 27 return fPts.controlsInside(); |
| 28 } |
| 29 |
| 30 SkDConic flip() const { |
| 31 SkDConic result = {{{fPts[2], fPts[1], fPts[0]}}, fWeight}; |
| 32 return result; |
| 33 } |
| 34 |
| 35 static bool IsCubic() { return false; } |
| 36 |
| 37 const SkDConic& set(const SkPoint pts[kPointCount], SkScalar weight) { |
| 38 fPts.set(pts); |
| 39 fWeight = weight; |
| 40 return *this; |
| 41 } |
| 42 |
| 43 const SkDPoint& operator[](int n) const { return fPts[n]; } |
| 44 SkDPoint& operator[](int n) { return fPts[n]; } |
| 45 |
| 46 static int AddValidTs(double s[], int realRoots, double* t) { |
| 47 return SkDQuad::AddValidTs(s, realRoots, t); |
| 48 } |
| 49 |
| 50 void align(int endIndex, SkDPoint* dstPt) const { |
| 51 fPts.align(endIndex, dstPt); |
| 52 } |
| 53 |
| 54 SkDVector dxdyAtT(double t) const; |
| 55 static int FindExtrema(const double src[], SkScalar weight, double tValue[1]
); |
| 56 |
| 57 bool hullIntersects(const SkDQuad& quad, bool* isLinear) const { |
| 58 return fPts.hullIntersects(quad, isLinear); |
| 59 } |
| 60 |
| 61 bool hullIntersects(const SkDConic& conic, bool* isLinear) const { |
| 62 return fPts.hullIntersects(conic.fPts, isLinear); |
| 63 } |
| 64 |
| 65 bool hullIntersects(const SkDCubic& cubic, bool* isLinear) const; |
| 66 |
| 67 bool isLinear(int startIndex, int endIndex) const { |
| 68 return fPts.isLinear(startIndex, endIndex); |
| 69 } |
| 70 |
| 71 bool monotonicInY() const { |
| 72 return fPts.monotonicInY(); |
| 73 } |
| 74 |
| 75 void otherPts(int oddMan, const SkDPoint* endPt[2]) const { |
| 76 fPts.otherPts(oddMan, endPt); |
| 77 } |
| 78 |
| 79 SkDPoint ptAtT(double t) const; |
| 80 |
| 81 static int RootsReal(double A, double B, double C, double t[2]) { |
| 82 return SkDQuad::RootsReal(A, B, C, t); |
| 83 } |
| 84 |
| 85 static int RootsValidT(const double A, const double B, const double C, doubl
e s[2]) { |
| 86 return SkDQuad::RootsValidT(A, B, C, s); |
| 87 } |
| 88 |
| 89 SkDConic subDivide(double t1, double t2) const; |
| 90 |
| 91 static SkDConic SubDivide(const SkPoint a[kPointCount], SkScalar weight, dou
ble t1, double t2) { |
| 92 SkDConic conic; |
| 93 conic.set(a, weight); |
| 94 return conic.subDivide(t1, t2); |
| 95 } |
| 96 |
| 97 SkDPoint subDivide(const SkDPoint& a, const SkDPoint& c, double t1, double t
2, |
| 98 SkScalar* weight) const; |
| 99 |
| 100 static SkDPoint SubDivide(const SkPoint pts[kPointCount], SkScalar weight, |
| 101 const SkDPoint& a, const SkDPoint& c, |
| 102 double t1, double t2, SkScalar* newWeight) { |
| 103 SkDConic conic; |
| 104 conic.set(pts, weight); |
| 105 return conic.subDivide(a, c, t1, t2, newWeight); |
| 106 } |
| 107 |
| 108 SkDPoint top(double startT, double endT) const; |
| 109 |
| 110 // utilities callable by the user from the debugger when the implementation
code is linked in |
| 111 void dump() const; |
| 112 void dumpID(int id) const; |
| 113 void dumpInner() const; |
| 114 }; |
| 115 |
| 116 |
| 117 #endif |
OLD | NEW |