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 #ifndef SkIntersections_DEFINE | 7 #ifndef SkIntersections_DEFINE |
8 #define SkIntersections_DEFINE | 8 #define SkIntersections_DEFINE |
9 | 9 |
10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 int insertSwap(double one, double two, const SkDPoint& pt) { | 91 int insertSwap(double one, double two, const SkDPoint& pt) { |
92 if (fSwap) { | 92 if (fSwap) { |
93 return insert(two, one, pt); | 93 return insert(two, one, pt); |
94 } else { | 94 } else { |
95 return insert(one, two, pt); | 95 return insert(one, two, pt); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
| 99 int insertSwap(double one, double two, double x, double y) { |
| 100 if (fSwap) { |
| 101 return insert(two, one, x, y); |
| 102 } else { |
| 103 return insert(one, two, x, y); |
| 104 } |
| 105 } |
| 106 |
99 bool isCoincident(int index) { | 107 bool isCoincident(int index) { |
100 return (fIsCoincident[0] & 1 << index) != 0; | 108 return (fIsCoincident[0] & 1 << index) != 0; |
101 } | 109 } |
102 | 110 |
103 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, | 111 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, |
104 bool flipped) { | 112 bool flipped) { |
105 SkDLine line; | 113 SkDLine line; |
106 line.set(a); | 114 line.set(a); |
107 return horizontal(line, left, right, y, flipped); | 115 return horizontal(line, left, right, y, flipped); |
108 } | 116 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void flip(); | 197 void flip(); |
190 int horizontal(const SkDLine&, double y); | 198 int horizontal(const SkDLine&, double y); |
191 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); | 199 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); |
192 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); | 200 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); |
193 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); | 201 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); |
194 int horizontal(const SkDCubic&, double y, double tRange[3]); | 202 int horizontal(const SkDCubic&, double y, double tRange[3]); |
195 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); | 203 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); |
196 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); | 204 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); |
197 // FIXME : does not respect swap | 205 // FIXME : does not respect swap |
198 int insert(double one, double two, const SkDPoint& pt); | 206 int insert(double one, double two, const SkDPoint& pt); |
| 207 int insert(double one, double two, double x, double y); |
199 // start if index == 0 : end if index == 1 | 208 // start if index == 0 : end if index == 1 |
200 void insertCoincident(double one, double two, const SkDPoint& pt); | 209 void insertCoincident(double one, double two, const SkDPoint& pt); |
201 void insertCoincidentPair(double s1, double e1, double s2, double e2, | 210 void insertCoincidentPair(double s1, double e1, double s2, double e2, |
202 const SkDPoint& startPt, const SkDPoint& endPt); | 211 const SkDPoint& startPt, const SkDPoint& endPt); |
203 int intersect(const SkDLine&, const SkDLine&); | 212 int intersect(const SkDLine&, const SkDLine&); |
204 int intersect(const SkDQuad&, const SkDLine&); | 213 int intersect(const SkDQuad&, const SkDLine&); |
205 int intersect(const SkDQuad&, const SkDQuad&); | 214 int intersect(const SkDQuad&, const SkDQuad&); |
206 int intersect(const SkDCubic&); // return true if cubic self-intersects | 215 int intersect(const SkDCubic&); // return true if cubic self-intersects |
207 int intersect(const SkDCubic&, const SkDLine&); | 216 int intersect(const SkDCubic&, const SkDLine&); |
208 int intersect(const SkDCubic&, const SkDQuad&); | 217 int intersect(const SkDCubic&, const SkDQuad&); |
(...skipping 17 matching lines...) Expand all Loading... |
226 #ifdef SK_DEBUG | 235 #ifdef SK_DEBUG |
227 return fDepth; | 236 return fDepth; |
228 #else | 237 #else |
229 return 0; | 238 return 0; |
230 #endif | 239 #endif |
231 } | 240 } |
232 | 241 |
233 private: | 242 private: |
234 int computePoints(const SkDLine& line, int used); | 243 int computePoints(const SkDLine& line, int used); |
235 // used by addCoincident to remove ordinary intersections in range | 244 // used by addCoincident to remove ordinary intersections in range |
236 void remove(double one, double two, const SkDPoint& startPt, const SkDPoint&
endPt); | 245 // void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
t& endPt); |
237 | 246 |
238 SkDPoint fPt[9]; | 247 SkDPoint fPt[9]; |
239 double fT[2][9]; | 248 double fT[2][9]; |
240 uint16_t fIsCoincident[2]; // bit arrays, one bit set for each coincident T | 249 uint16_t fIsCoincident[2]; // bit arrays, one bit set for each coincident T |
241 unsigned char fUsed; | 250 unsigned char fUsed; |
242 bool fSwap; | 251 bool fSwap; |
243 #ifdef SK_DEBUG | 252 #ifdef SK_DEBUG |
244 int fDepth; | 253 int fDepth; |
245 #endif | 254 #endif |
246 }; | 255 }; |
247 | 256 |
248 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); | 257 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); |
249 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, | 258 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, |
250 SkScalar x, bool flipped); | 259 SkScalar x, bool flipped); |
251 | 260 |
252 #endif | 261 #endif |
OLD | NEW |