| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 static bool IsCubic() { return true; } | 51 static bool IsCubic() { return true; } |
| 52 | 52 |
| 53 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount
); return fPts[n]; } | 53 const SkDPoint& operator[](int n) const { SkASSERT(n >= 0 && n < kPointCount
); return fPts[n]; } |
| 54 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP
ts[n]; } | 54 SkDPoint& operator[](int n) { SkASSERT(n >= 0 && n < kPointCount); return fP
ts[n]; } |
| 55 | 55 |
| 56 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; | 56 void align(int endIndex, int ctrlIndex, SkDPoint* dstPt) const; |
| 57 double binarySearch(double min, double max, double axisIntercept, SearchAxis
xAxis) const; | 57 double binarySearch(double min, double max, double axisIntercept, SearchAxis
xAxis) const; |
| 58 double calcPrecision() const; | 58 double calcPrecision() const; |
| 59 SkDCubicPair chopAt(double t) const; | 59 SkDCubicPair chopAt(double t) const; |
| 60 bool clockwise(const SkDCubic& whole, bool* swap) const; | |
| 61 static bool Clockwise(const SkPoint* pts, double startT, double endT, bool*
swap); | |
| 62 static void Coefficients(const double* cubic, double* A, double* B, double*
C, double* D); | 60 static void Coefficients(const double* cubic, double* A, double* B, double*
C, double* D); |
| 63 static bool ComplexBreak(const SkPoint pts[4], SkScalar* t, CubicType* cubic
Type); | 61 static bool ComplexBreak(const SkPoint pts[4], SkScalar* t, CubicType* cubic
Type); |
| 64 int convexHull(char order[kPointCount]) const; | 62 int convexHull(char order[kPointCount]) const; |
| 65 | 63 |
| 66 void debugInit() { | 64 void debugInit() { |
| 67 sk_bzero(fPts, sizeof(fPts)); | 65 sk_bzero(fPts, sizeof(fPts)); |
| 68 } | 66 } |
| 69 | 67 |
| 70 void dump() const; // callable from the debugger when the implementation co
de is linked in | 68 void dump() const; // callable from the debugger when the implementation co
de is linked in |
| 71 void dumpID(int id) const; | 69 void dumpID(int id) const; |
| 72 void dumpInner() const; | 70 void dumpInner() const; |
| 73 SkDVector dxdyAtT(double t) const; | 71 SkDVector dxdyAtT(double t) const; |
| 74 bool endsAreExtremaInXOrY() const; | 72 bool endsAreExtremaInXOrY() const; |
| 75 static int FindExtrema(const double src[], double tValue[2]); | 73 static int FindExtrema(const double src[], double tValue[2]); |
| 76 int findInflections(double tValues[2]) const; | 74 int findInflections(double tValues[2]) const; |
| 77 | 75 |
| 78 static int FindInflections(const SkPoint a[kPointCount], double tValues[2])
{ | 76 static int FindInflections(const SkPoint a[kPointCount], double tValues[2])
{ |
| 79 SkDCubic cubic; | 77 SkDCubic cubic; |
| 80 cubic.set(a); | 78 return cubic.set(a).findInflections(tValues); |
| 81 return cubic.findInflections(tValues); | |
| 82 } | 79 } |
| 83 | 80 |
| 84 int findMaxCurvature(double tValues[]) const; | 81 int findMaxCurvature(double tValues[]) const; |
| 85 bool hullIntersects(const SkDCubic& c2, bool* isLinear) const; | 82 bool hullIntersects(const SkDCubic& c2, bool* isLinear) const; |
| 86 bool hullIntersects(const SkDConic& c, bool* isLinear) const; | 83 bool hullIntersects(const SkDConic& c, bool* isLinear) const; |
| 87 bool hullIntersects(const SkDQuad& c2, bool* isLinear) const; | 84 bool hullIntersects(const SkDQuad& c2, bool* isLinear) const; |
| 88 bool hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const; | 85 bool hullIntersects(const SkDPoint* pts, int ptCount, bool* isLinear) const; |
| 89 bool isLinear(int startIndex, int endIndex) const; | 86 bool isLinear(int startIndex, int endIndex) const; |
| 90 bool monotonicInX() const; | 87 bool monotonicInX() const; |
| 91 bool monotonicInY() const; | 88 bool monotonicInY() const; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 fPts[1] = pts[1]; | 110 fPts[1] = pts[1]; |
| 114 fPts[2] = pts[2]; | 111 fPts[2] = pts[2]; |
| 115 fPts[3] = pts[3]; | 112 fPts[3] = pts[3]; |
| 116 return *this; | 113 return *this; |
| 117 } | 114 } |
| 118 | 115 |
| 119 SkDCubic subDivide(double t1, double t2) const; | 116 SkDCubic subDivide(double t1, double t2) const; |
| 120 | 117 |
| 121 static SkDCubic SubDivide(const SkPoint a[kPointCount], double t1, double t2
) { | 118 static SkDCubic SubDivide(const SkPoint a[kPointCount], double t1, double t2
) { |
| 122 SkDCubic cubic; | 119 SkDCubic cubic; |
| 123 cubic.set(a); | 120 return cubic.set(a).subDivide(t1, t2); |
| 124 return cubic.subDivide(t1, t2); | |
| 125 } | 121 } |
| 126 | 122 |
| 127 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S
kDPoint p[2]) const; | 123 void subDivide(const SkDPoint& a, const SkDPoint& d, double t1, double t2, S
kDPoint p[2]) const; |
| 128 | 124 |
| 129 static void SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, con
st SkDPoint& d, double t1, | 125 static void SubDivide(const SkPoint pts[kPointCount], const SkDPoint& a, con
st SkDPoint& d, double t1, |
| 130 double t2, SkDPoint p[2]) { | 126 double t2, SkDPoint p[2]) { |
| 131 SkDCubic cubic; | 127 SkDCubic cubic; |
| 132 cubic.set(pts); | 128 cubic.set(pts).subDivide(a, d, t1, t2, p); |
| 133 cubic.subDivide(a, d, t1, t2, p); | |
| 134 } | 129 } |
| 135 | 130 |
| 131 double top(const SkDCubic& dCurve, double startT, double endT, SkDPoint*topP
t) const; |
| 136 SkDQuad toQuad() const; | 132 SkDQuad toQuad() const; |
| 137 | 133 |
| 138 static const int gPrecisionUnit; | 134 static const int gPrecisionUnit; |
| 139 | 135 |
| 140 SkDPoint fPts[kPointCount]; | 136 SkDPoint fPts[kPointCount]; |
| 141 }; | 137 }; |
| 142 | 138 |
| 143 /* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask | 139 /* Given the set [0, 1, 2, 3], and two of the four members, compute an XOR mask |
| 144 that computes the other two. Note that: | 140 that computes the other two. Note that: |
| 145 | 141 |
| 146 one ^ two == 3 for (0, 3), (1, 2) | 142 one ^ two == 3 for (0, 3), (1, 2) |
| 147 one ^ two < 3 for (0, 1), (0, 2), (1, 3), (2, 3) | 143 one ^ two < 3 for (0, 1), (0, 2), (1, 3), (2, 3) |
| 148 3 - (one ^ two) is either 0, 1, or 2 | 144 3 - (one ^ two) is either 0, 1, or 2 |
| 149 1 >> (3 - (one ^ two)) is either 0 or 1 | 145 1 >> (3 - (one ^ two)) is either 0 or 1 |
| 150 thus: | 146 thus: |
| 151 returned == 2 for (0, 3), (1, 2) | 147 returned == 2 for (0, 3), (1, 2) |
| 152 returned == 3 for (0, 1), (0, 2), (1, 3), (2, 3) | 148 returned == 3 for (0, 1), (0, 2), (1, 3), (2, 3) |
| 153 given that: | 149 given that: |
| 154 (0, 3) ^ 2 -> (2, 1) (1, 2) ^ 2 -> (3, 0) | 150 (0, 3) ^ 2 -> (2, 1) (1, 2) ^ 2 -> (3, 0) |
| 155 (0, 1) ^ 3 -> (3, 2) (0, 2) ^ 3 -> (3, 1) (1, 3) ^ 3 -> (2, 0) (2, 3) ^ 3
-> (1, 0) | 151 (0, 1) ^ 3 -> (3, 2) (0, 2) ^ 3 -> (3, 1) (1, 3) ^ 3 -> (2, 0) (2, 3) ^ 3
-> (1, 0) |
| 156 */ | 152 */ |
| 157 inline int other_two(int one, int two) { | 153 inline int other_two(int one, int two) { |
| 158 return 1 >> (3 - (one ^ two)) ^ 3; | 154 return 1 >> (3 - (one ^ two)) ^ 3; |
| 159 } | 155 } |
| 160 | 156 |
| 161 #endif | 157 #endif |
| OLD | NEW |