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" |
11 #include "SkPathOpsLine.h" | 11 #include "SkPathOpsLine.h" |
12 #include "SkPathOpsPoint.h" | 12 #include "SkPathOpsPoint.h" |
13 #include "SkPathOpsQuad.h" | 13 #include "SkPathOpsQuad.h" |
14 | 14 |
15 class SkIntersections { | 15 class SkIntersections { |
16 public: | 16 public: |
17 SkIntersections() | 17 SkIntersections() |
18 : fSwap(0) | 18 : fSwap(0) |
19 #ifdef SK_DEBUG | 19 #ifdef SK_DEBUG |
20 , fDepth(0) | 20 , fDepth(0) |
21 #endif | 21 #endif |
22 { | 22 { |
23 sk_bzero(fPt, sizeof(fPt)); | 23 sk_bzero(fPt, sizeof(fPt)); |
24 sk_bzero(fT, sizeof(fT)); | 24 sk_bzero(fT, sizeof(fT)); |
25 sk_bzero(fIsCoincident, sizeof(fIsCoincident)); | 25 sk_bzero(fIsCoincident, sizeof(fIsCoincident)); |
26 sk_bzero(&fIsNear, sizeof(fIsNear)); | |
27 reset(); | 26 reset(); |
28 fMax = 0; // require that the caller set the max | 27 fMax = 0; // require that the caller set the max |
29 } | 28 } |
30 | 29 |
31 class TArray { | 30 class TArray { |
32 public: | 31 public: |
33 explicit TArray(const double ts[9]) : fTArray(ts) {} | 32 explicit TArray(const double ts[9]) : fTArray(ts) {} |
34 double operator[](int n) const { | 33 double operator[](int n) const { |
35 return fTArray[n]; | 34 return fTArray[n]; |
36 } | 35 } |
37 const double* fTArray; | 36 const double* fTArray; |
38 }; | 37 }; |
39 TArray operator[](int n) const { return TArray(fT[n]); } | 38 TArray operator[](int n) const { return TArray(fT[n]); } |
40 | 39 |
41 void set(const SkIntersections& i) { | 40 void set(const SkIntersections& i) { |
42 memcpy(fPt, i.fPt, sizeof(fPt)); | 41 memcpy(fPt, i.fPt, sizeof(fPt)); |
43 memcpy(fT, i.fT, sizeof(fT)); | 42 memcpy(fT, i.fT, sizeof(fT)); |
44 memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); | 43 memcpy(fIsCoincident, i.fIsCoincident, sizeof(fIsCoincident)); |
45 memcpy(&fIsNear, &i.fIsNear, sizeof(fIsNear)); | |
46 fUsed = i.fUsed; | 44 fUsed = i.fUsed; |
47 fMax = i.fMax; | 45 fMax = i.fMax; |
48 fSwap = i.fSwap; | 46 fSwap = i.fSwap; |
49 SkDEBUGCODE(fDepth = i.fDepth); | 47 SkDEBUGCODE(fDepth = i.fDepth); |
50 } | 48 } |
51 | 49 |
52 void allowNear(bool nearAllowed) { | 50 void allowNear(bool nearAllowed) { |
53 fAllowNear = nearAllowed; | 51 fAllowNear = nearAllowed; |
54 } | 52 } |
55 | 53 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return insert(two, one, pt); | 110 return insert(two, one, pt); |
113 } else { | 111 } else { |
114 return insert(one, two, pt); | 112 return insert(one, two, pt); |
115 } | 113 } |
116 } | 114 } |
117 | 115 |
118 bool isCoincident(int index) { | 116 bool isCoincident(int index) { |
119 return (fIsCoincident[0] & 1 << index) != 0; | 117 return (fIsCoincident[0] & 1 << index) != 0; |
120 } | 118 } |
121 | 119 |
122 bool isNear(int index) { | |
123 return (fIsNear & 1 << index) != 0; | |
124 } | |
125 | |
126 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, | 120 int lineHorizontal(const SkPoint a[2], SkScalar left, SkScalar right, SkScal
ar y, |
127 bool flipped) { | 121 bool flipped) { |
128 SkDLine line; | 122 SkDLine line; |
129 line.set(a); | 123 line.set(a); |
130 fMax = 2; | 124 fMax = 2; |
131 return horizontal(line, left, right, y, flipped); | 125 return horizontal(line, left, right, y, flipped); |
132 } | 126 } |
133 | 127 |
134 int lineVertical(const SkPoint a[2], SkScalar top, SkScalar bottom, SkScalar
x, bool flipped) { | 128 int lineVertical(const SkPoint a[2], SkScalar top, SkScalar bottom, SkScalar
x, bool flipped) { |
135 SkDLine line; | 129 SkDLine line; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bool cubicExactEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic
2); | 265 bool cubicExactEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic
2); |
272 void cubicNearEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic2
, const SkDRect& ); | 266 void cubicNearEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic2
, const SkDRect& ); |
273 void cleanUpParallelLines(bool parallel); | 267 void cleanUpParallelLines(bool parallel); |
274 void computePoints(const SkDLine& line, int used); | 268 void computePoints(const SkDLine& line, int used); |
275 // used by addCoincident to remove ordinary intersections in range | 269 // used by addCoincident to remove ordinary intersections in range |
276 // void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
t& endPt); | 270 // void remove(double one, double two, const SkDPoint& startPt, const SkDPoin
t& endPt); |
277 | 271 |
278 SkDPoint fPt[9]; // FIXME: since scans store points as SkPoint, this should
also | 272 SkDPoint fPt[9]; // FIXME: since scans store points as SkPoint, this should
also |
279 double fT[2][9]; | 273 double fT[2][9]; |
280 uint16_t fIsCoincident[2]; // bit set for each curve's coincident T | 274 uint16_t fIsCoincident[2]; // bit set for each curve's coincident T |
281 uint16_t fIsNear; // bit set for each T if 2nd curve's point is near but no
t equal to 1st | |
282 unsigned char fUsed; | 275 unsigned char fUsed; |
283 unsigned char fMax; | 276 unsigned char fMax; |
284 bool fAllowNear; | 277 bool fAllowNear; |
285 bool fSwap; | 278 bool fSwap; |
286 #ifdef SK_DEBUG | 279 #ifdef SK_DEBUG |
287 int fDepth; | 280 int fDepth; |
288 #endif | 281 #endif |
289 }; | 282 }; |
290 | 283 |
291 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); | 284 extern int (SkIntersections::*CurveRay[])(const SkPoint[], const SkDLine& ); |
292 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, | 285 extern int (SkIntersections::*CurveVertical[])(const SkPoint[], SkScalar top, Sk
Scalar bottom, |
293 SkScalar x, bool flipped); | 286 SkScalar x, bool flipped); |
294 | 287 |
295 #endif | 288 #endif |
OLD | NEW |