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 "SkPathOpsConic.h" |
11 #include "SkPathOpsCubic.h" | 11 #include "SkPathOpsCubic.h" |
12 #include "SkPathOpsLine.h" | 12 #include "SkPathOpsLine.h" |
13 #include "SkPathOpsPoint.h" | 13 #include "SkPathOpsPoint.h" |
14 #include "SkPathOpsQuad.h" | 14 #include "SkPathOpsQuad.h" |
15 | 15 |
16 class SkIntersections { | 16 class SkIntersections { |
17 public: | 17 public: |
18 SkIntersections() | 18 SkIntersections() |
19 : fSwap(0) | 19 : fSwap(0) |
20 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
21 , fDepth(0) | 21 , fDepth(0) |
22 #endif | 22 #endif |
23 { | 23 { |
24 sk_bzero(fPt, sizeof(fPt)); | 24 sk_bzero(fPt, sizeof(fPt)); |
25 sk_bzero(fPt2, sizeof(fPt2)); | 25 sk_bzero(fPt2, sizeof(fPt2)); |
26 sk_bzero(fT, sizeof(fT)); | 26 sk_bzero(fT, sizeof(fT)); |
27 sk_bzero(fNearlySame, sizeof(fNearlySame)); | 27 sk_bzero(fNearlySame, sizeof(fNearlySame)); |
| 28 #if DEBUG_T_SECT_LOOP_COUNT |
| 29 sk_bzero(fDebugLoopCount, sizeof(fDebugLoopCount)); |
| 30 #endif |
28 reset(); | 31 reset(); |
29 fMax = 0; // require that the caller set the max | 32 fMax = 0; // require that the caller set the max |
30 } | 33 } |
31 | 34 |
32 class TArray { | 35 class TArray { |
33 public: | 36 public: |
34 explicit TArray(const double ts[10]) : fTArray(ts) {} | 37 explicit TArray(const double ts[10]) : fTArray(ts) {} |
35 double operator[](int n) const { | 38 double operator[](int n) const { |
36 return fTArray[n]; | 39 return fTArray[n]; |
37 } | 40 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 static int VerticalIntercept(const SkDConic& conic, SkScalar x, double* root
s); | 273 static int VerticalIntercept(const SkDConic& conic, SkScalar x, double* root
s); |
271 | 274 |
272 int depth() const { | 275 int depth() const { |
273 #ifdef SK_DEBUG | 276 #ifdef SK_DEBUG |
274 return fDepth; | 277 return fDepth; |
275 #else | 278 #else |
276 return 0; | 279 return 0; |
277 #endif | 280 #endif |
278 } | 281 } |
279 | 282 |
| 283 enum DebugLoop { |
| 284 kIterations_DebugLoop, |
| 285 kCoinCheck_DebugLoop, |
| 286 kComputePerp_DebugLoop, |
| 287 }; |
| 288 |
| 289 void debugBumpLoopCount(DebugLoop ); |
280 int debugCoincidentUsed() const; | 290 int debugCoincidentUsed() const; |
| 291 int debugLoopCount(DebugLoop ) const; |
| 292 void debugResetLoopCount(); |
281 void dump() const; // implemented for testing only | 293 void dump() const; // implemented for testing only |
282 | 294 |
283 private: | 295 private: |
284 bool cubicCheckCoincidence(const SkDCubic& c1, const SkDCubic& c2); | 296 bool cubicCheckCoincidence(const SkDCubic& c1, const SkDCubic& c2); |
285 bool cubicExactEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic
2); | 297 bool cubicExactEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic
2); |
286 void cubicNearEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic2
, const SkDRect& ); | 298 void cubicNearEnd(const SkDCubic& cubic1, bool start, const SkDCubic& cubic2
, const SkDRect& ); |
287 void cleanUpParallelLines(bool parallel); | 299 void cleanUpParallelLines(bool parallel); |
288 void computePoints(const SkDLine& line, int used); | 300 void computePoints(const SkDLine& line, int used); |
289 | 301 |
290 SkDPoint fPt[12]; // FIXME: since scans store points as SkPoint, this shoul
d also | 302 SkDPoint fPt[12]; // FIXME: since scans store points as SkPoint, this shoul
d also |
291 SkDPoint fPt2[2]; // used by nearly same to store alternate intersection po
int | 303 SkDPoint fPt2[2]; // used by nearly same to store alternate intersection po
int |
292 double fT[2][12]; | 304 double fT[2][12]; |
293 uint16_t fIsCoincident[2]; // bit set for each curve's coincident T | 305 uint16_t fIsCoincident[2]; // bit set for each curve's coincident T |
294 bool fNearlySame[2]; // true if end points nearly match | 306 bool fNearlySame[2]; // true if end points nearly match |
295 unsigned char fUsed; | 307 unsigned char fUsed; |
296 unsigned char fMax; | 308 unsigned char fMax; |
297 bool fAllowNear; | 309 bool fAllowNear; |
298 bool fSwap; | 310 bool fSwap; |
299 #ifdef SK_DEBUG | 311 #ifdef SK_DEBUG |
300 int fDepth; | 312 int fDepth; |
301 #endif | 313 #endif |
| 314 #if DEBUG_T_SECT_LOOP_COUNT |
| 315 int fDebugLoopCount[3]; |
| 316 #endif |
302 }; | 317 }; |
303 | 318 |
304 #endif | 319 #endif |
OLD | NEW |