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 SkPathOpsTypes_DEFINED | 7 #ifndef SkPathOpsTypes_DEFINED |
8 #define SkPathOpsTypes_DEFINED | 8 #define SkPathOpsTypes_DEFINED |
9 | 9 |
10 #include <float.h> // for FLT_EPSILON | 10 #include <float.h> // for FLT_EPSILON |
11 #include <math.h> // for fabs, sqrt | 11 #include <math.h> // for fabs, sqrt |
12 | 12 |
13 #include "SkFloatingPoint.h" | 13 #include "SkFloatingPoint.h" |
14 #include "SkPath.h" | 14 #include "SkPath.h" |
15 #include "SkPathOps.h" | 15 #include "SkPathOps.h" |
16 #include "SkPathOpsDebug.h" | 16 #include "SkPathOpsDebug.h" |
17 #include "SkScalar.h" | 17 #include "SkScalar.h" |
18 | 18 |
19 enum SkPathOpsMask { | 19 enum SkPathOpsMask { |
20 kWinding_PathOpsMask = -1, | 20 kWinding_PathOpsMask = -1, |
21 kNo_PathOpsMask = 0, | 21 kNo_PathOpsMask = 0, |
22 kEvenOdd_PathOpsMask = 1 | 22 kEvenOdd_PathOpsMask = 1 |
23 }; | 23 }; |
24 | 24 |
25 class SkOpCoincidence; | 25 class SkOpCoincidence; |
26 class SkOpContour; | 26 class SkOpContour; |
27 class SkOpContourHead; | 27 class SkOpContourHead; |
| 28 class SkIntersections; |
| 29 class SkIntersectionHelper; |
28 | 30 |
29 class SkOpGlobalState { | 31 class SkOpGlobalState { |
30 public: | 32 public: |
31 SkOpGlobalState(SkOpCoincidence* coincidence, SkOpContourHead* head | 33 SkOpGlobalState(SkOpCoincidence* coincidence, SkOpContourHead* head |
32 SkDEBUGPARAMS(const char* testName)); | 34 SkDEBUGPARAMS(const char* testName)); |
33 | 35 |
34 enum Phase { | 36 enum Phase { |
35 kIntersecting, | 37 kIntersecting, |
36 kWalking, | 38 kWalking, |
37 kFixWinding, | 39 kFixWinding, |
38 }; | 40 }; |
39 | 41 |
40 enum { | 42 enum { |
41 kMaxWindingTries = 10 | 43 kMaxWindingTries = 10 |
42 }; | 44 }; |
43 | 45 |
44 bool angleCoincidence() { | 46 bool angleCoincidence() const { |
45 return fAngleCoincidence; | 47 return fAngleCoincidence; |
46 } | 48 } |
47 | 49 |
48 void bumpNested() { | 50 void bumpNested() { |
49 ++fNested; | 51 ++fNested; |
50 } | 52 } |
51 | 53 |
52 void clearNested() { | 54 void clearNested() { |
53 fNested = 0; | 55 fNested = 0; |
54 } | 56 } |
55 | 57 |
56 SkOpCoincidence* coincidence() { | 58 SkOpCoincidence* coincidence() { |
57 return fCoincidence; | 59 return fCoincidence; |
58 } | 60 } |
59 | 61 |
60 SkOpContourHead* contourHead() { | 62 SkOpContourHead* contourHead() { |
61 return fContourHead; | 63 return fContourHead; |
62 } | 64 } |
63 | 65 |
64 #ifdef SK_DEBUG | 66 #ifdef SK_DEBUG |
65 const struct SkOpAngle* debugAngle(int id) const; | 67 const struct SkOpAngle* debugAngle(int id) const; |
66 SkOpContour* debugContour(int id); | 68 SkOpContour* debugContour(int id); |
67 const class SkOpPtT* debugPtT(int id) const; | 69 const class SkOpPtT* debugPtT(int id) const; |
68 bool debugRunFail() const; | 70 bool debugRunFail() const; |
69 const class SkOpSegment* debugSegment(int id) const; | 71 const class SkOpSegment* debugSegment(int id) const; |
70 const class SkOpSpanBase* debugSpan(int id) const; | 72 const class SkOpSpanBase* debugSpan(int id) const; |
71 const char* debugTestName() const { return fDebugTestName; } | 73 const char* debugTestName() const { return fDebugTestName; } |
72 #endif | 74 #endif |
73 | 75 |
| 76 #if DEBUG_T_SECT_LOOP_COUNT |
| 77 void debugAddLoopCount(SkIntersections* , const SkIntersectionHelper& , |
| 78 const SkIntersectionHelper& ); |
| 79 void debugDoYourWorst(SkOpGlobalState* ); |
| 80 void debugLoopReport(); |
| 81 void debugResetLoopCounts(); |
| 82 #endif |
| 83 |
74 int nested() const { | 84 int nested() const { |
75 return fNested; | 85 return fNested; |
76 } | 86 } |
77 | 87 |
78 #ifdef SK_DEBUG | 88 #ifdef SK_DEBUG |
79 int nextAngleID() { | 89 int nextAngleID() { |
80 return ++fAngleID; | 90 return ++fAngleID; |
81 } | 91 } |
82 | 92 |
| 93 int nextCoinID() { |
| 94 return ++fCoinID; |
| 95 } |
| 96 |
83 int nextContourID() { | 97 int nextContourID() { |
84 return ++fContourID; | 98 return ++fContourID; |
85 } | 99 } |
| 100 |
86 int nextPtTID() { | 101 int nextPtTID() { |
87 return ++fPtTID; | 102 return ++fPtTID; |
88 } | 103 } |
89 | 104 |
90 int nextSegmentID() { | 105 int nextSegmentID() { |
91 return ++fSegmentID; | 106 return ++fSegmentID; |
92 } | 107 } |
93 | 108 |
94 int nextSpanID() { | 109 int nextSpanID() { |
95 return ++fSpanID; | 110 return ++fSpanID; |
(...skipping 29 matching lines...) Expand all Loading... |
125 private: | 140 private: |
126 SkOpCoincidence* fCoincidence; | 141 SkOpCoincidence* fCoincidence; |
127 SkOpContourHead* fContourHead; | 142 SkOpContourHead* fContourHead; |
128 int fNested; | 143 int fNested; |
129 bool fWindingFailed; | 144 bool fWindingFailed; |
130 bool fAngleCoincidence; | 145 bool fAngleCoincidence; |
131 Phase fPhase; | 146 Phase fPhase; |
132 #ifdef SK_DEBUG | 147 #ifdef SK_DEBUG |
133 const char* fDebugTestName; | 148 const char* fDebugTestName; |
134 int fAngleID; | 149 int fAngleID; |
| 150 int fCoinID; |
135 int fContourID; | 151 int fContourID; |
136 int fPtTID; | 152 int fPtTID; |
137 int fSegmentID; | 153 int fSegmentID; |
138 int fSpanID; | 154 int fSpanID; |
139 #endif | 155 #endif |
| 156 #if DEBUG_T_SECT_LOOP_COUNT |
| 157 int fDebugLoopCount[3]; |
| 158 SkPath::Verb fDebugWorstVerb[6]; |
| 159 SkPoint fDebugWorstPts[24]; |
| 160 float fDebugWorstWeight[6]; |
| 161 #endif |
140 }; | 162 }; |
141 | 163 |
142 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. | 164 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. |
143 bool AlmostEqualUlps(float a, float b); | 165 bool AlmostEqualUlps(float a, float b); |
144 inline bool AlmostEqualUlps(double a, double b) { | 166 inline bool AlmostEqualUlps(double a, double b) { |
145 return AlmostEqualUlps(SkDoubleToScalar(a), SkDoubleToScalar(b)); | 167 return AlmostEqualUlps(SkDoubleToScalar(a), SkDoubleToScalar(b)); |
146 } | 168 } |
147 | 169 |
148 // Use Almost Dequal when comparing should not special case denormalized values. | 170 // Use Almost Dequal when comparing should not special case denormalized values. |
149 bool AlmostDequalUlps(float a, float b); | 171 bool AlmostDequalUlps(float a, float b); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 */ | 526 */ |
505 inline int SkDSideBit(double x) { | 527 inline int SkDSideBit(double x) { |
506 return 1 << SKDSide(x); | 528 return 1 << SKDSide(x); |
507 } | 529 } |
508 | 530 |
509 inline double SkPinT(double t) { | 531 inline double SkPinT(double t) { |
510 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; | 532 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; |
511 } | 533 } |
512 | 534 |
513 #endif | 535 #endif |
OLD | NEW |