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 "SkPathOpsConic.h" |
10 #include "SkPathOpsCubic.h" | 11 #include "SkPathOpsCubic.h" |
11 #include "SkPathOpsLine.h" | 12 #include "SkPathOpsLine.h" |
12 #include "SkPathOpsPoint.h" | 13 #include "SkPathOpsPoint.h" |
13 #include "SkPathOpsQuad.h" | 14 #include "SkPathOpsQuad.h" |
14 | 15 |
15 class SkIntersections { | 16 class SkIntersections { |
16 public: | 17 public: |
17 SkIntersections() | 18 SkIntersections() |
18 : fSwap(0) | 19 : fSwap(0) |
19 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
(...skipping 22 matching lines...) Expand all Loading... |
42 fAllowNear = nearAllowed; | 43 fAllowNear = nearAllowed; |
43 } | 44 } |
44 | 45 |
45 void clearCoincidence(int index) { | 46 void clearCoincidence(int index) { |
46 SkASSERT(index >= 0); | 47 SkASSERT(index >= 0); |
47 int bit = 1 << index; | 48 int bit = 1 << index; |
48 fIsCoincident[0] &= ~bit; | 49 fIsCoincident[0] &= ~bit; |
49 fIsCoincident[1] &= ~bit; | 50 fIsCoincident[1] &= ~bit; |
50 } | 51 } |
51 | 52 |
| 53 int conicHorizontal(const SkPoint a[3], SkScalar weight, SkScalar left, SkSc
alar right, |
| 54 SkScalar y, bool flipped) { |
| 55 SkDConic conic; |
| 56 conic.set(a, weight); |
| 57 fMax = 2; |
| 58 return horizontal(conic, left, right, y, flipped); |
| 59 } |
| 60 |
| 61 int conicVertical(const SkPoint a[3], SkScalar weight, SkScalar top, SkScala
r bottom, |
| 62 SkScalar x, bool flipped) { |
| 63 SkDConic conic; |
| 64 conic.set(a, weight); |
| 65 fMax = 2; |
| 66 return vertical(conic, top, bottom, x, flipped); |
| 67 } |
| 68 |
| 69 int conicLine(const SkPoint a[3], SkScalar weight, const SkPoint b[2]) { |
| 70 SkDConic conic; |
| 71 conic.set(a, weight); |
| 72 SkDLine line; |
| 73 line.set(b); |
| 74 fMax = 3; // 2; permit small coincident segment + non-coincident inters
ection |
| 75 return intersect(conic, line); |
| 76 } |
| 77 |
52 int cubicHorizontal(const SkPoint a[4], SkScalar left, SkScalar right, SkSca
lar y, | 78 int cubicHorizontal(const SkPoint a[4], SkScalar left, SkScalar right, SkSca
lar y, |
53 bool flipped) { | 79 bool flipped) { |
54 SkDCubic cubic; | 80 SkDCubic cubic; |
55 cubic.set(a); | 81 cubic.set(a); |
56 fMax = 3; | 82 fMax = 3; |
57 return horizontal(cubic, left, right, y, flipped); | 83 return horizontal(cubic, left, right, y, flipped); |
58 } | 84 } |
59 | 85 |
60 int cubicVertical(const SkPoint a[4], SkScalar top, SkScalar bottom, SkScala
r x, bool flipped) { | 86 int cubicVertical(const SkPoint a[4], SkScalar top, SkScalar bottom, SkScala
r x, bool flipped) { |
61 SkDCubic cubic; | 87 SkDCubic cubic; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 int cleanUpCoincidence(); | 225 int cleanUpCoincidence(); |
200 int closestTo(double rangeStart, double rangeEnd, const SkDPoint& testPt, do
uble* dist) const; | 226 int closestTo(double rangeStart, double rangeEnd, const SkDPoint& testPt, do
uble* dist) const; |
201 int coincidentUsed() const; | 227 int coincidentUsed() const; |
202 void cubicInsert(double one, double two, const SkDPoint& pt, const SkDCubic&
c1, | 228 void cubicInsert(double one, double two, const SkDPoint& pt, const SkDCubic&
c1, |
203 const SkDCubic& c2); | 229 const SkDCubic& c2); |
204 void flip(); | 230 void flip(); |
205 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); | 231 int horizontal(const SkDLine&, double left, double right, double y, bool fli
pped); |
206 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); | 232 int horizontal(const SkDQuad&, double left, double right, double y, bool fli
pped); |
207 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); | 233 int horizontal(const SkDQuad&, double left, double right, double y, double t
Range[2]); |
208 int horizontal(const SkDCubic&, double y, double tRange[3]); | 234 int horizontal(const SkDCubic&, double y, double tRange[3]); |
| 235 int horizontal(const SkDConic&, double left, double right, double y, bool fl
ipped); |
209 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); | 236 int horizontal(const SkDCubic&, double left, double right, double y, bool fl
ipped); |
210 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); | 237 int horizontal(const SkDCubic&, double left, double right, double y, double
tRange[3]); |
211 // FIXME : does not respect swap | 238 // FIXME : does not respect swap |
212 int insert(double one, double two, const SkDPoint& pt); | 239 int insert(double one, double two, const SkDPoint& pt); |
213 void insertNear(double one, double two, const SkDPoint& pt1, const SkDPoint&
pt2); | 240 void insertNear(double one, double two, const SkDPoint& pt1, const SkDPoint&
pt2); |
214 // start if index == 0 : end if index == 1 | 241 // start if index == 0 : end if index == 1 |
215 int insertCoincident(double one, double two, const SkDPoint& pt); | 242 int insertCoincident(double one, double two, const SkDPoint& pt); |
216 int intersect(const SkDLine&, const SkDLine&); | 243 int intersect(const SkDLine&, const SkDLine&); |
217 int intersect(const SkDQuad&, const SkDLine&); | 244 int intersect(const SkDQuad&, const SkDLine&); |
218 int intersect(const SkDQuad&, const SkDQuad&); | 245 int intersect(const SkDQuad&, const SkDQuad&); |
| 246 int intersect(const SkDConic&, const SkDLine&); |
| 247 int intersect(const SkDConic&, const SkDQuad&); |
| 248 int intersect(const SkDConic&, const SkDConic&); |
219 int intersect(const SkDCubic&, const SkDLine&); | 249 int intersect(const SkDCubic&, const SkDLine&); |
| 250 int intersect(const SkDCubic&, const SkDQuad&); |
| 251 int intersect(const SkDCubic&, const SkDConic&); |
220 int intersect(const SkDCubic&, const SkDCubic&); | 252 int intersect(const SkDCubic&, const SkDCubic&); |
221 int intersectRay(const SkDLine&, const SkDLine&); | 253 int intersectRay(const SkDLine&, const SkDLine&); |
222 int intersectRay(const SkDQuad&, const SkDLine&); | 254 int intersectRay(const SkDQuad&, const SkDLine&); |
| 255 int intersectRay(const SkDConic&, const SkDLine&); |
223 int intersectRay(const SkDCubic&, const SkDLine&); | 256 int intersectRay(const SkDCubic&, const SkDLine&); |
224 void merge(const SkIntersections& , int , const SkIntersections& , int ); | 257 void merge(const SkIntersections& , int , const SkIntersections& , int ); |
225 int mostOutside(double rangeStart, double rangeEnd, const SkDPoint& origin)
const; | 258 int mostOutside(double rangeStart, double rangeEnd, const SkDPoint& origin)
const; |
226 void quickRemoveOne(int index, int replace); | 259 void quickRemoveOne(int index, int replace); |
227 void removeOne(int index); | 260 void removeOne(int index); |
228 void setCoincident(int index); | 261 void setCoincident(int index); |
229 int vertical(const SkDLine&, double top, double bottom, double x, bool flipp
ed); | 262 int vertical(const SkDLine&, double top, double bottom, double x, bool flipp
ed); |
230 int vertical(const SkDQuad&, double top, double bottom, double x, bool flipp
ed); | 263 int vertical(const SkDQuad&, double top, double bottom, double x, bool flipp
ed); |
| 264 int vertical(const SkDConic&, double top, double bottom, double x, bool flip
ped); |
231 int vertical(const SkDCubic&, double top, double bottom, double x, bool flip
ped); | 265 int vertical(const SkDCubic&, double top, double bottom, double x, bool flip
ped); |
232 int verticalCubic(const SkPoint a[4], SkScalar top, SkScalar bottom, SkScala
r x, bool flipped); | 266 int verticalConic(const SkPoint a[3], SkScalar weight, SkScalar top, SkScala
r bottom, |
233 int verticalLine(const SkPoint a[2], SkScalar top, SkScalar bottom, SkScalar
x, bool flipped); | 267 SkScalar x, bool flipped); |
234 int verticalQuad(const SkPoint a[3], SkScalar top, SkScalar bottom, SkScalar
x, bool flipped); | 268 int verticalCubic(const SkPoint a[4], SkScalar weight, SkScalar top, SkScala
r bottom, |
| 269 SkScalar x, bool flipped); |
| 270 int verticalLine(const SkPoint a[2], SkScalar weight, SkScalar top, SkScalar
bottom, |
| 271 SkScalar x, bool flipped); |
| 272 int verticalQuad(const SkPoint a[3], SkScalar weight, SkScalar top, SkScalar
bottom, |
| 273 SkScalar x, bool flipped); |
235 | 274 |
236 int depth() const { | 275 int depth() const { |
237 #ifdef SK_DEBUG | 276 #ifdef SK_DEBUG |
238 return fDepth; | 277 return fDepth; |
239 #else | 278 #else |
240 return 0; | 279 return 0; |
241 #endif | 280 #endif |
242 } | 281 } |
243 | 282 |
244 void dump() const; // implemented for testing only | 283 void dump() const; // implemented for testing only |
(...skipping 12 matching lines...) Expand all Loading... |
257 bool fNearlySame[2]; // true if end points nearly match | 296 bool fNearlySame[2]; // true if end points nearly match |
258 unsigned char fUsed; | 297 unsigned char fUsed; |
259 unsigned char fMax; | 298 unsigned char fMax; |
260 bool fAllowNear; | 299 bool fAllowNear; |
261 bool fSwap; | 300 bool fSwap; |
262 #ifdef SK_DEBUG | 301 #ifdef SK_DEBUG |
263 int fDepth; | 302 int fDepth; |
264 #endif | 303 #endif |
265 }; | 304 }; |
266 | 305 |
267 extern int (SkIntersections::* const CurveVertical[])(const SkPoint[], SkScalar
top, SkScalar bottom, | 306 extern int (SkIntersections::* const CurveVertical[])(const SkPoint[], SkScalar
weight, |
268 SkScalar x, bool flipped); | 307 SkScalar top, SkScalar bottom, SkScalar x, bool flipped); |
269 | 308 |
270 #endif | 309 #endif |
OLD | NEW |