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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 class SkOpContour; | 26 class SkOpContour; |
27 class SkOpContourHead; | 27 class SkOpContourHead; |
28 | 28 |
29 class SkOpGlobalState { | 29 class SkOpGlobalState { |
30 public: | 30 public: |
31 SkOpGlobalState(SkOpCoincidence* coincidence, SkOpContourHead* head) | 31 SkOpGlobalState(SkOpCoincidence* coincidence, SkOpContourHead* head) |
32 : fCoincidence(coincidence) | 32 : fCoincidence(coincidence) |
33 , fContourHead(head) | 33 , fContourHead(head) |
34 , fWindingFailed(false) | 34 , fWindingFailed(false) |
35 , fAngleCoincidence(false) | 35 , fAngleCoincidence(false) |
36 #if DEBUG_VALIDATE | |
37 , fPhase(kIntersecting) | 36 , fPhase(kIntersecting) |
38 #endif | |
39 SkDEBUGPARAMS(fAngleID(0)) | 37 SkDEBUGPARAMS(fAngleID(0)) |
40 SkDEBUGPARAMS(fContourID(0)) | 38 SkDEBUGPARAMS(fContourID(0)) |
41 SkDEBUGPARAMS(fPtTID(0)) | 39 SkDEBUGPARAMS(fPtTID(0)) |
42 SkDEBUGPARAMS(fSegmentID(0)) | 40 SkDEBUGPARAMS(fSegmentID(0)) |
43 SkDEBUGPARAMS(fSpanID(0)) { | 41 SkDEBUGPARAMS(fSpanID(0)) { |
44 } | 42 } |
45 | 43 |
46 #if DEBUG_VALIDATE | |
47 enum Phase { | 44 enum Phase { |
48 kIntersecting, | 45 kIntersecting, |
49 kWalking | 46 kWalking, |
| 47 kFixWinding, |
50 }; | 48 }; |
51 #endif | |
52 | 49 |
53 enum { | 50 enum { |
54 kMaxWindingTries = 10 | 51 kMaxWindingTries = 10 |
55 }; | 52 }; |
56 | 53 |
57 bool angleCoincidence() { | 54 bool angleCoincidence() { |
58 return fAngleCoincidence; | 55 return fAngleCoincidence; |
59 } | 56 } |
60 | 57 |
61 SkOpCoincidence* coincidence() { | 58 SkOpCoincidence* coincidence() { |
(...skipping 24 matching lines...) Expand all Loading... |
86 | 83 |
87 int nextSegmentID() { | 84 int nextSegmentID() { |
88 return ++fSegmentID; | 85 return ++fSegmentID; |
89 } | 86 } |
90 | 87 |
91 int nextSpanID() { | 88 int nextSpanID() { |
92 return ++fSpanID; | 89 return ++fSpanID; |
93 } | 90 } |
94 #endif | 91 #endif |
95 | 92 |
96 #if DEBUG_VALIDATE | |
97 Phase phase() const { | 93 Phase phase() const { |
98 return fPhase; | 94 return fPhase; |
99 } | 95 } |
100 #endif | |
101 | 96 |
102 void setAngleCoincidence() { | 97 void setAngleCoincidence() { |
103 fAngleCoincidence = true; | 98 fAngleCoincidence = true; |
104 } | 99 } |
105 | 100 |
106 void setContourHead(SkOpContourHead* contourHead) { | 101 void setContourHead(SkOpContourHead* contourHead) { |
107 fContourHead = contourHead; | 102 fContourHead = contourHead; |
108 } | 103 } |
109 | 104 |
110 #if DEBUG_VALIDATE | |
111 void setPhase(Phase phase) { | 105 void setPhase(Phase phase) { |
112 SkASSERT(fPhase != phase); | 106 SkASSERT(fPhase != phase); |
113 fPhase = phase; | 107 fPhase = phase; |
114 } | 108 } |
115 #endif | |
116 | 109 |
117 // called in very rare cases where angles are sorted incorrectly -- signfies
op will fail | 110 // called in very rare cases where angles are sorted incorrectly -- signfies
op will fail |
118 void setWindingFailed() { | 111 void setWindingFailed() { |
119 fWindingFailed = true; | 112 fWindingFailed = true; |
120 } | 113 } |
121 | 114 |
122 bool windingFailed() const { | 115 bool windingFailed() const { |
123 return fWindingFailed; | 116 return fWindingFailed; |
124 } | 117 } |
125 | 118 |
126 private: | 119 private: |
127 SkOpCoincidence* fCoincidence; | 120 SkOpCoincidence* fCoincidence; |
128 SkOpContourHead* fContourHead; | 121 SkOpContourHead* fContourHead; |
129 bool fWindingFailed; | 122 bool fWindingFailed; |
130 bool fAngleCoincidence; | 123 bool fAngleCoincidence; |
131 #if DEBUG_VALIDATE | |
132 Phase fPhase; | 124 Phase fPhase; |
133 #endif | |
134 #ifdef SK_DEBUG | 125 #ifdef SK_DEBUG |
135 int fAngleID; | 126 int fAngleID; |
136 int fContourID; | 127 int fContourID; |
137 int fPtTID; | 128 int fPtTID; |
138 int fSegmentID; | 129 int fSegmentID; |
139 int fSpanID; | 130 int fSpanID; |
140 #endif | 131 #endif |
141 }; | 132 }; |
142 | 133 |
143 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. | 134 // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 */ | 496 */ |
506 inline int SkDSideBit(double x) { | 497 inline int SkDSideBit(double x) { |
507 return 1 << SKDSide(x); | 498 return 1 << SKDSide(x); |
508 } | 499 } |
509 | 500 |
510 inline double SkPinT(double t) { | 501 inline double SkPinT(double t) { |
511 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; | 502 return precisely_less_than_zero(t) ? 0 : precisely_greater_than_one(t) ? 1 :
t; |
512 } | 503 } |
513 | 504 |
514 #endif | 505 #endif |
OLD | NEW |