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 #include "SkAddIntersections.h" | 7 #include "SkAddIntersections.h" |
8 #include "SkOpCoincidence.h" | 8 #include "SkOpCoincidence.h" |
9 #include "SkPathOpsBounds.h" | 9 #include "SkPathOpsBounds.h" |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 for (int n = 1; n < pts; ++n) { | 64 for (int n = 1; n < pts; ++n) { |
65 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); | 65 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
66 } | 66 } |
67 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts())); | 67 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts())); |
68 for (int n = 1; n < pts; ++n) { | 68 for (int n = 1; n < pts; ++n) { |
69 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); | 69 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
70 } | 70 } |
71 SkDebugf("\n"); | 71 SkDebugf("\n"); |
72 } | 72 } |
73 | 73 |
| 74 static void debugShowConicLineIntersection(int pts, const SkIntersectionHelper&
wt, |
| 75 const SkIntersectionHelper& wn, const SkIntersections& i) { |
| 76 SkASSERT(i.used() == pts); |
| 77 if (!pts) { |
| 78 SkDebugf("%s no intersect " CONIC_DEBUG_STR " " LINE_DEBUG_STR "\n", |
| 79 __FUNCTION__, CONIC_DEBUG_DATA(wt.pts(), wt.weight()), LINE_DEBU
G_DATA(wn.pts())); |
| 80 return; |
| 81 } |
| 82 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CONIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
| 83 i[0][0], CONIC_DEBUG_DATA(wt.pts(), wt.weight()), PT_DEBUG_DATA(i, 0
)); |
| 84 for (int n = 1; n < pts; ++n) { |
| 85 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
| 86 } |
| 87 SkDebugf(" wnTs[0]=%g " LINE_DEBUG_STR, i[1][0], LINE_DEBUG_DATA(wn.pts())); |
| 88 for (int n = 1; n < pts; ++n) { |
| 89 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
| 90 } |
| 91 SkDebugf("\n"); |
| 92 } |
| 93 |
| 94 static void debugShowConicQuadIntersection(int pts, const SkIntersectionHelper&
wt, |
| 95 const SkIntersectionHelper& wn, const SkIntersections& i) { |
| 96 SkASSERT(i.used() == pts); |
| 97 if (!pts) { |
| 98 SkDebugf("%s no intersect " CONIC_DEBUG_STR " " QUAD_DEBUG_STR "\n", |
| 99 __FUNCTION__, CONIC_DEBUG_DATA(wt.pts(), wt.weight()), QUAD_DEBU
G_DATA(wn.pts())); |
| 100 return; |
| 101 } |
| 102 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CONIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
| 103 i[0][0], CONIC_DEBUG_DATA(wt.pts(), wt.weight()), PT_DEBUG_DATA(i, 0
)); |
| 104 for (int n = 1; n < pts; ++n) { |
| 105 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
| 106 } |
| 107 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts())); |
| 108 for (int n = 1; n < pts; ++n) { |
| 109 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
| 110 } |
| 111 SkDebugf("\n"); |
| 112 } |
| 113 |
| 114 static void debugShowConicIntersection(int pts, const SkIntersectionHelper& wt, |
| 115 const SkIntersectionHelper& wn, const SkIntersections& i) { |
| 116 SkASSERT(i.used() == pts); |
| 117 if (!pts) { |
| 118 SkDebugf("%s no intersect " CONIC_DEBUG_STR " " CONIC_DEBUG_STR "\n", |
| 119 __FUNCTION__, CONIC_DEBUG_DATA(wt.pts(), wt.weight()), |
| 120 CONIC_DEBUG_DATA(wn.pts(), wn.weight())); |
| 121 return; |
| 122 } |
| 123 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CONIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
| 124 i[0][0], CONIC_DEBUG_DATA(wt.pts(), wt.weight()), PT_DEBUG_DATA(i, 0
)); |
| 125 for (int n = 1; n < pts; ++n) { |
| 126 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
| 127 } |
| 128 SkDebugf(" wnTs[0]=%g " CONIC_DEBUG_STR, i[1][0], CONIC_DEBUG_DATA(wn.pts(),
wn.weight())); |
| 129 for (int n = 1; n < pts; ++n) { |
| 130 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
| 131 } |
| 132 SkDebugf("\n"); |
| 133 } |
| 134 |
74 static void debugShowCubicLineIntersection(int pts, const SkIntersectionHelper&
wt, | 135 static void debugShowCubicLineIntersection(int pts, const SkIntersectionHelper&
wt, |
75 const SkIntersectionHelper& wn, const SkIntersections& i) { | 136 const SkIntersectionHelper& wn, const SkIntersections& i) { |
76 SkASSERT(i.used() == pts); | 137 SkASSERT(i.used() == pts); |
77 if (!pts) { | 138 if (!pts) { |
78 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " LINE_DEBUG_STR "\n", | 139 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " LINE_DEBUG_STR "\n", |
79 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), LINE_DEBUG_DATA(wn.pts
())); | 140 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), LINE_DEBUG_DATA(wn.pts
())); |
80 return; | 141 return; |
81 } | 142 } |
82 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, | 143 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
83 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0)); | 144 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0)); |
(...skipping 20 matching lines...) Expand all Loading... |
104 for (int n = 1; n < pts; ++n) { | 165 for (int n = 1; n < pts; ++n) { |
105 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); | 166 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
106 } | 167 } |
107 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts())); | 168 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts())); |
108 for (int n = 1; n < pts; ++n) { | 169 for (int n = 1; n < pts; ++n) { |
109 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); | 170 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
110 } | 171 } |
111 SkDebugf("\n"); | 172 SkDebugf("\n"); |
112 } | 173 } |
113 | 174 |
| 175 static void debugShowCubicConicIntersection(int pts, const SkIntersectionHelper&
wt, |
| 176 const SkIntersectionHelper& wn, const SkIntersections& i) { |
| 177 SkASSERT(i.used() == pts); |
| 178 if (!pts) { |
| 179 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " CONIC_DEBUG_STR "\n", |
| 180 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), CONIC_DEBUG_DATA(wn.pt
s(), wn.weight())); |
| 181 return; |
| 182 } |
| 183 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
| 184 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0)); |
| 185 for (int n = 1; n < pts; ++n) { |
| 186 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_D
ATA(i, n)); |
| 187 } |
| 188 SkDebugf(" wnTs[0]=%g " CONIC_DEBUG_STR, i[1][0], CONIC_DEBUG_DATA(wn.pts(),
wn.weight())); |
| 189 for (int n = 1; n < pts; ++n) { |
| 190 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]); |
| 191 } |
| 192 SkDebugf("\n"); |
| 193 } |
| 194 |
114 static void debugShowCubicIntersection(int pts, const SkIntersectionHelper& wt, | 195 static void debugShowCubicIntersection(int pts, const SkIntersectionHelper& wt, |
115 const SkIntersectionHelper& wn, const SkIntersections& i) { | 196 const SkIntersectionHelper& wn, const SkIntersections& i) { |
116 SkASSERT(i.used() == pts); | 197 SkASSERT(i.used() == pts); |
117 if (!pts) { | 198 if (!pts) { |
118 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " CUBIC_DEBUG_STR "\n", | 199 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " CUBIC_DEBUG_STR "\n", |
119 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), CUBIC_DEBUG_DATA(wn.pt
s())); | 200 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), CUBIC_DEBUG_DATA(wn.pt
s())); |
120 return; | 201 return; |
121 } | 202 } |
122 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, | 203 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __
FUNCTION__, |
123 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0)); | 204 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0)); |
(...skipping 13 matching lines...) Expand all Loading... |
137 } | 218 } |
138 | 219 |
139 static void debugShowQuadLineIntersection(int , const SkIntersectionHelper& , | 220 static void debugShowQuadLineIntersection(int , const SkIntersectionHelper& , |
140 const SkIntersectionHelper& , const SkIntersections& ) { | 221 const SkIntersectionHelper& , const SkIntersections& ) { |
141 } | 222 } |
142 | 223 |
143 static void debugShowQuadIntersection(int , const SkIntersectionHelper& , | 224 static void debugShowQuadIntersection(int , const SkIntersectionHelper& , |
144 const SkIntersectionHelper& , const SkIntersections& ) { | 225 const SkIntersectionHelper& , const SkIntersections& ) { |
145 } | 226 } |
146 | 227 |
| 228 static void debugShowConicLineIntersection(int , const SkIntersectionHelper& , |
| 229 const SkIntersectionHelper& , const SkIntersections& ) { |
| 230 } |
| 231 |
| 232 static void debugShowConicQuadIntersection(int , const SkIntersectionHelper& , |
| 233 const SkIntersectionHelper& , const SkIntersections& ) { |
| 234 } |
| 235 |
| 236 static void debugShowConicIntersection(int , const SkIntersectionHelper& , |
| 237 const SkIntersectionHelper& , const SkIntersections& ) { |
| 238 } |
| 239 |
147 static void debugShowCubicLineIntersection(int , const SkIntersectionHelper& , | 240 static void debugShowCubicLineIntersection(int , const SkIntersectionHelper& , |
148 const SkIntersectionHelper& , const SkIntersections& ) { | 241 const SkIntersectionHelper& , const SkIntersections& ) { |
149 } | 242 } |
150 | 243 |
151 static void debugShowCubicQuadIntersection(int , const SkIntersectionHelper& , | 244 static void debugShowCubicQuadIntersection(int , const SkIntersectionHelper& , |
152 const SkIntersectionHelper& , const SkIntersections& ) { | 245 const SkIntersectionHelper& , const SkIntersections& ) { |
153 } | 246 } |
154 | 247 |
| 248 static void debugShowCubicConicIntersection(int , const SkIntersectionHelper& , |
| 249 const SkIntersectionHelper& , const SkIntersections& ) { |
| 250 } |
| 251 |
155 static void debugShowCubicIntersection(int , const SkIntersectionHelper& , | 252 static void debugShowCubicIntersection(int , const SkIntersectionHelper& , |
156 const SkIntersectionHelper& , const SkIntersections& ) { | 253 const SkIntersectionHelper& , const SkIntersections& ) { |
157 } | 254 } |
158 #endif | 255 #endif |
159 | 256 |
160 bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
idence, | 257 bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
idence, |
161 SkChunkAlloc* allocator) { | 258 SkChunkAlloc* allocator) { |
162 if (test != next) { | 259 if (test != next) { |
163 if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) { | 260 if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) { |
164 return false; | 261 return false; |
(...skipping 13 matching lines...) Expand all Loading... |
178 if (test == next && !wn.startAfter(wt)) { | 275 if (test == next && !wn.startAfter(wt)) { |
179 continue; | 276 continue; |
180 } | 277 } |
181 do { | 278 do { |
182 if (!SkPathOpsBounds::Intersects(wt.bounds(), wn.bounds())) { | 279 if (!SkPathOpsBounds::Intersects(wt.bounds(), wn.bounds())) { |
183 continue; | 280 continue; |
184 } | 281 } |
185 int pts = 0; | 282 int pts = 0; |
186 SkIntersections ts; | 283 SkIntersections ts; |
187 bool swap = false; | 284 bool swap = false; |
| 285 SkDQuad quad1, quad2; |
| 286 SkDConic conic1, conic2; |
| 287 SkDCubic cubic1, cubic2; |
188 switch (wt.segmentType()) { | 288 switch (wt.segmentType()) { |
189 case SkIntersectionHelper::kHorizontalLine_Segment: | 289 case SkIntersectionHelper::kHorizontalLine_Segment: |
190 swap = true; | 290 swap = true; |
191 switch (wn.segmentType()) { | 291 switch (wn.segmentType()) { |
192 case SkIntersectionHelper::kHorizontalLine_Segment: | 292 case SkIntersectionHelper::kHorizontalLine_Segment: |
193 case SkIntersectionHelper::kVerticalLine_Segment: | 293 case SkIntersectionHelper::kVerticalLine_Segment: |
194 case SkIntersectionHelper::kLine_Segment: { | 294 case SkIntersectionHelper::kLine_Segment: |
195 pts = ts.lineHorizontal(wn.pts(), wt.left(), | 295 pts = ts.lineHorizontal(wn.pts(), wt.left(), |
196 wt.right(), wt.y(), wt.xFlipped()); | 296 wt.right(), wt.y(), wt.xFlipped()); |
197 debugShowLineIntersection(pts, wn, wt, ts); | 297 debugShowLineIntersection(pts, wn, wt, ts); |
198 break; | 298 break; |
199 } | 299 case SkIntersectionHelper::kQuad_Segment: |
200 case SkIntersectionHelper::kQuad_Segment: { | |
201 pts = ts.quadHorizontal(wn.pts(), wt.left(), | 300 pts = ts.quadHorizontal(wn.pts(), wt.left(), |
202 wt.right(), wt.y(), wt.xFlipped()); | 301 wt.right(), wt.y(), wt.xFlipped()); |
203 debugShowQuadLineIntersection(pts, wn, wt, ts); | 302 debugShowQuadLineIntersection(pts, wn, wt, ts); |
204 break; | 303 break; |
205 } | 304 case SkIntersectionHelper::kConic_Segment: |
206 case SkIntersectionHelper::kCubic_Segment: { | 305 pts = ts.conicHorizontal(wn.pts(), wn.weight(), wt.l
eft(), |
| 306 wt.right(), wt.y(), wt.xFlipped()); |
| 307 debugShowConicLineIntersection(pts, wn, wt, ts); |
| 308 break; |
| 309 case SkIntersectionHelper::kCubic_Segment: |
207 pts = ts.cubicHorizontal(wn.pts(), wt.left(), | 310 pts = ts.cubicHorizontal(wn.pts(), wt.left(), |
208 wt.right(), wt.y(), wt.xFlipped()); | 311 wt.right(), wt.y(), wt.xFlipped()); |
209 debugShowCubicLineIntersection(pts, wn, wt, ts); | 312 debugShowCubicLineIntersection(pts, wn, wt, ts); |
210 break; | 313 break; |
211 } | |
212 default: | 314 default: |
213 SkASSERT(0); | 315 SkASSERT(0); |
214 } | 316 } |
215 break; | 317 break; |
216 case SkIntersectionHelper::kVerticalLine_Segment: | 318 case SkIntersectionHelper::kVerticalLine_Segment: |
217 swap = true; | 319 swap = true; |
218 switch (wn.segmentType()) { | 320 switch (wn.segmentType()) { |
219 case SkIntersectionHelper::kHorizontalLine_Segment: | 321 case SkIntersectionHelper::kHorizontalLine_Segment: |
220 case SkIntersectionHelper::kVerticalLine_Segment: | 322 case SkIntersectionHelper::kVerticalLine_Segment: |
221 case SkIntersectionHelper::kLine_Segment: { | 323 case SkIntersectionHelper::kLine_Segment: { |
222 pts = ts.lineVertical(wn.pts(), wt.top(), | 324 pts = ts.lineVertical(wn.pts(), wt.top(), |
223 wt.bottom(), wt.x(), wt.yFlipped()); | 325 wt.bottom(), wt.x(), wt.yFlipped()); |
224 debugShowLineIntersection(pts, wn, wt, ts); | 326 debugShowLineIntersection(pts, wn, wt, ts); |
225 break; | 327 break; |
226 } | 328 } |
227 case SkIntersectionHelper::kQuad_Segment: { | 329 case SkIntersectionHelper::kQuad_Segment: { |
228 pts = ts.quadVertical(wn.pts(), wt.top(), | 330 pts = ts.quadVertical(wn.pts(), wt.top(), |
229 wt.bottom(), wt.x(), wt.yFlipped()); | 331 wt.bottom(), wt.x(), wt.yFlipped()); |
230 debugShowQuadLineIntersection(pts, wn, wt, ts); | 332 debugShowQuadLineIntersection(pts, wn, wt, ts); |
231 break; | 333 break; |
232 } | 334 } |
| 335 case SkIntersectionHelper::kConic_Segment: { |
| 336 pts = ts.conicVertical(wn.pts(), wn.weight(), wt.top
(), |
| 337 wt.bottom(), wt.x(), wt.yFlipped()); |
| 338 debugShowConicLineIntersection(pts, wn, wt, ts); |
| 339 break; |
| 340 } |
233 case SkIntersectionHelper::kCubic_Segment: { | 341 case SkIntersectionHelper::kCubic_Segment: { |
234 pts = ts.cubicVertical(wn.pts(), wt.top(), | 342 pts = ts.cubicVertical(wn.pts(), wt.top(), |
235 wt.bottom(), wt.x(), wt.yFlipped()); | 343 wt.bottom(), wt.x(), wt.yFlipped()); |
236 debugShowCubicLineIntersection(pts, wn, wt, ts); | 344 debugShowCubicLineIntersection(pts, wn, wt, ts); |
237 break; | 345 break; |
238 } | 346 } |
239 default: | 347 default: |
240 SkASSERT(0); | 348 SkASSERT(0); |
241 } | 349 } |
242 break; | 350 break; |
243 case SkIntersectionHelper::kLine_Segment: | 351 case SkIntersectionHelper::kLine_Segment: |
244 switch (wn.segmentType()) { | 352 switch (wn.segmentType()) { |
245 case SkIntersectionHelper::kHorizontalLine_Segment: | 353 case SkIntersectionHelper::kHorizontalLine_Segment: |
246 pts = ts.lineHorizontal(wt.pts(), wn.left(), | 354 pts = ts.lineHorizontal(wt.pts(), wn.left(), |
247 wn.right(), wn.y(), wn.xFlipped()); | 355 wn.right(), wn.y(), wn.xFlipped()); |
248 debugShowLineIntersection(pts, wt, wn, ts); | 356 debugShowLineIntersection(pts, wt, wn, ts); |
249 break; | 357 break; |
250 case SkIntersectionHelper::kVerticalLine_Segment: | 358 case SkIntersectionHelper::kVerticalLine_Segment: |
251 pts = ts.lineVertical(wt.pts(), wn.top(), | 359 pts = ts.lineVertical(wt.pts(), wn.top(), |
252 wn.bottom(), wn.x(), wn.yFlipped()); | 360 wn.bottom(), wn.x(), wn.yFlipped()); |
253 debugShowLineIntersection(pts, wt, wn, ts); | 361 debugShowLineIntersection(pts, wt, wn, ts); |
254 break; | 362 break; |
255 case SkIntersectionHelper::kLine_Segment: { | 363 case SkIntersectionHelper::kLine_Segment: |
256 pts = ts.lineLine(wt.pts(), wn.pts()); | 364 pts = ts.lineLine(wt.pts(), wn.pts()); |
257 debugShowLineIntersection(pts, wt, wn, ts); | 365 debugShowLineIntersection(pts, wt, wn, ts); |
258 break; | 366 break; |
259 } | 367 case SkIntersectionHelper::kQuad_Segment: |
260 case SkIntersectionHelper::kQuad_Segment: { | |
261 swap = true; | 368 swap = true; |
262 pts = ts.quadLine(wn.pts(), wt.pts()); | 369 pts = ts.quadLine(wn.pts(), wt.pts()); |
263 debugShowQuadLineIntersection(pts, wn, wt, ts); | 370 debugShowQuadLineIntersection(pts, wn, wt, ts); |
264 break; | 371 break; |
265 } | 372 case SkIntersectionHelper::kConic_Segment: |
266 case SkIntersectionHelper::kCubic_Segment: { | 373 swap = true; |
| 374 pts = ts.conicLine(wn.pts(), wn.weight(), wt.pts()); |
| 375 debugShowConicLineIntersection(pts, wn, wt, ts); |
| 376 break; |
| 377 case SkIntersectionHelper::kCubic_Segment: |
267 swap = true; | 378 swap = true; |
268 pts = ts.cubicLine(wn.pts(), wt.pts()); | 379 pts = ts.cubicLine(wn.pts(), wt.pts()); |
269 debugShowCubicLineIntersection(pts, wn, wt, ts); | 380 debugShowCubicLineIntersection(pts, wn, wt, ts); |
270 break; | 381 break; |
271 } | |
272 default: | 382 default: |
273 SkASSERT(0); | 383 SkASSERT(0); |
274 } | 384 } |
275 break; | 385 break; |
276 case SkIntersectionHelper::kQuad_Segment: | 386 case SkIntersectionHelper::kQuad_Segment: |
277 switch (wn.segmentType()) { | 387 switch (wn.segmentType()) { |
278 case SkIntersectionHelper::kHorizontalLine_Segment: | 388 case SkIntersectionHelper::kHorizontalLine_Segment: |
279 pts = ts.quadHorizontal(wt.pts(), wn.left(), | 389 pts = ts.quadHorizontal(wt.pts(), wn.left(), |
280 wn.right(), wn.y(), wn.xFlipped()); | 390 wn.right(), wn.y(), wn.xFlipped()); |
281 debugShowQuadLineIntersection(pts, wt, wn, ts); | 391 debugShowQuadLineIntersection(pts, wt, wn, ts); |
282 break; | 392 break; |
283 case SkIntersectionHelper::kVerticalLine_Segment: | 393 case SkIntersectionHelper::kVerticalLine_Segment: |
284 pts = ts.quadVertical(wt.pts(), wn.top(), | 394 pts = ts.quadVertical(wt.pts(), wn.top(), |
285 wn.bottom(), wn.x(), wn.yFlipped()); | 395 wn.bottom(), wn.x(), wn.yFlipped()); |
286 debugShowQuadLineIntersection(pts, wt, wn, ts); | 396 debugShowQuadLineIntersection(pts, wt, wn, ts); |
287 break; | 397 break; |
288 case SkIntersectionHelper::kLine_Segment: { | 398 case SkIntersectionHelper::kLine_Segment: |
289 pts = ts.quadLine(wt.pts(), wn.pts()); | 399 pts = ts.quadLine(wt.pts(), wn.pts()); |
290 debugShowQuadLineIntersection(pts, wt, wn, ts); | 400 debugShowQuadLineIntersection(pts, wt, wn, ts); |
291 break; | 401 break; |
| 402 case SkIntersectionHelper::kQuad_Segment: { |
| 403 pts = ts.intersect(quad1.set(wt.pts()), quad2.set(wn
.pts())); |
| 404 debugShowQuadIntersection(pts, wt, wn, ts); |
| 405 break; |
292 } | 406 } |
293 case SkIntersectionHelper::kQuad_Segment: { | 407 case SkIntersectionHelper::kConic_Segment: { |
294 SkDQuad quad1; | 408 swap = true; |
295 quad1.set(wt.pts()); | 409 pts = ts.intersect(conic2.set(wn.pts(), wn.weight())
, |
296 SkDQuad quad2; | 410 quad1.set(wt.pts())); |
297 quad2.set(wn.pts()); | 411 debugShowConicQuadIntersection(pts, wn, wt, ts); |
298 pts = ts.intersect(quad1, quad2); | |
299 debugShowQuadIntersection(pts, wt, wn, ts); | |
300 break; | 412 break; |
301 } | 413 } |
302 case SkIntersectionHelper::kCubic_Segment: { | 414 case SkIntersectionHelper::kCubic_Segment: { |
303 swap = true; | 415 swap = true; |
304 SkDQuad quad1; | 416 pts = ts.intersect(cubic2.set(wn.pts()), quad1.set(w
t.pts())); |
305 quad1.set(wt.pts()); | |
306 SkDCubic cubic1 = quad1.toCubic(); | |
307 SkDCubic cubic2; | |
308 cubic2.set(wn.pts()); | |
309 pts = ts.intersect(cubic2, cubic1); | |
310 debugShowCubicQuadIntersection(pts, wn, wt, ts); | 417 debugShowCubicQuadIntersection(pts, wn, wt, ts); |
311 break; | 418 break; |
312 } | 419 } |
313 default: | 420 default: |
314 SkASSERT(0); | 421 SkASSERT(0); |
315 } | 422 } |
316 break; | 423 break; |
| 424 case SkIntersectionHelper::kConic_Segment: |
| 425 switch (wn.segmentType()) { |
| 426 case SkIntersectionHelper::kHorizontalLine_Segment: |
| 427 pts = ts.conicHorizontal(wt.pts(), wt.weight(), wn.l
eft(), |
| 428 wn.right(), wn.y(), wn.xFlipped()); |
| 429 debugShowConicLineIntersection(pts, wt, wn, ts); |
| 430 break; |
| 431 case SkIntersectionHelper::kVerticalLine_Segment: |
| 432 pts = ts.conicVertical(wt.pts(), wt.weight(), wn.top
(), |
| 433 wn.bottom(), wn.x(), wn.yFlipped()); |
| 434 debugShowConicLineIntersection(pts, wt, wn, ts); |
| 435 break; |
| 436 case SkIntersectionHelper::kLine_Segment: |
| 437 pts = ts.conicLine(wt.pts(), wt.weight(), wn.pts()); |
| 438 debugShowConicLineIntersection(pts, wt, wn, ts); |
| 439 break; |
| 440 case SkIntersectionHelper::kQuad_Segment: { |
| 441 pts = ts.intersect(conic1.set(wt.pts(), wt.weight())
, |
| 442 quad2.set(wn.pts())); |
| 443 debugShowConicQuadIntersection(pts, wt, wn, ts); |
| 444 break; |
| 445 } |
| 446 case SkIntersectionHelper::kConic_Segment: { |
| 447 pts = ts.intersect(conic1.set(wt.pts(), wt.weight())
, |
| 448 conic2.set(wn.pts(), wn.weight())); |
| 449 debugShowConicIntersection(pts, wt, wn, ts); |
| 450 break; |
| 451 } |
| 452 case SkIntersectionHelper::kCubic_Segment: { |
| 453 swap = true; |
| 454 pts = ts.intersect(cubic2.set(wn.pts()), |
| 455 conic1.set(wt.pts(), wt.weight())); |
| 456 debugShowCubicConicIntersection(pts, wn, wt, ts); |
| 457 break; |
| 458 } |
| 459 } |
| 460 break; |
317 case SkIntersectionHelper::kCubic_Segment: | 461 case SkIntersectionHelper::kCubic_Segment: |
318 switch (wn.segmentType()) { | 462 switch (wn.segmentType()) { |
319 case SkIntersectionHelper::kHorizontalLine_Segment: | 463 case SkIntersectionHelper::kHorizontalLine_Segment: |
320 pts = ts.cubicHorizontal(wt.pts(), wn.left(), | 464 pts = ts.cubicHorizontal(wt.pts(), wn.left(), |
321 wn.right(), wn.y(), wn.xFlipped()); | 465 wn.right(), wn.y(), wn.xFlipped()); |
322 debugShowCubicLineIntersection(pts, wt, wn, ts); | 466 debugShowCubicLineIntersection(pts, wt, wn, ts); |
323 break; | 467 break; |
324 case SkIntersectionHelper::kVerticalLine_Segment: | 468 case SkIntersectionHelper::kVerticalLine_Segment: |
325 pts = ts.cubicVertical(wt.pts(), wn.top(), | 469 pts = ts.cubicVertical(wt.pts(), wn.top(), |
326 wn.bottom(), wn.x(), wn.yFlipped()); | 470 wn.bottom(), wn.x(), wn.yFlipped()); |
327 debugShowCubicLineIntersection(pts, wt, wn, ts); | 471 debugShowCubicLineIntersection(pts, wt, wn, ts); |
328 break; | 472 break; |
329 case SkIntersectionHelper::kLine_Segment: { | 473 case SkIntersectionHelper::kLine_Segment: |
330 pts = ts.cubicLine(wt.pts(), wn.pts()); | 474 pts = ts.cubicLine(wt.pts(), wn.pts()); |
331 debugShowCubicLineIntersection(pts, wt, wn, ts); | 475 debugShowCubicLineIntersection(pts, wt, wn, ts); |
332 break; | 476 break; |
333 } | |
334 case SkIntersectionHelper::kQuad_Segment: { | 477 case SkIntersectionHelper::kQuad_Segment: { |
335 SkDCubic cubic1; | 478 pts = ts.intersect(cubic1.set(wt.pts()), quad2.set(w
n.pts())); |
336 cubic1.set(wt.pts()); | |
337 SkDQuad quad2; | |
338 quad2.set(wn.pts()); | |
339 SkDCubic cubic2 = quad2.toCubic(); | |
340 pts = ts.intersect(cubic1, cubic2); | |
341 debugShowCubicQuadIntersection(pts, wt, wn, ts); | 479 debugShowCubicQuadIntersection(pts, wt, wn, ts); |
342 break; | 480 break; |
343 } | 481 } |
| 482 case SkIntersectionHelper::kConic_Segment: { |
| 483 pts = ts.intersect(cubic1.set(wt.pts()), |
| 484 conic2.set(wn.pts(), wn.weight())); |
| 485 debugShowCubicConicIntersection(pts, wt, wn, ts); |
| 486 break; |
| 487 } |
344 case SkIntersectionHelper::kCubic_Segment: { | 488 case SkIntersectionHelper::kCubic_Segment: { |
345 SkDCubic cubic1; | 489 pts = ts.intersect(cubic1.set(wt.pts()), cubic2.set(
wn.pts())); |
346 cubic1.set(wt.pts()); | |
347 SkDCubic cubic2; | |
348 cubic2.set(wn.pts()); | |
349 pts = ts.intersect(cubic1, cubic2); | |
350 debugShowCubicIntersection(pts, wt, wn, ts); | 490 debugShowCubicIntersection(pts, wt, wn, ts); |
351 break; | 491 break; |
352 } | 492 } |
353 default: | 493 default: |
354 SkASSERT(0); | 494 SkASSERT(0); |
355 } | 495 } |
356 break; | 496 break; |
357 default: | 497 default: |
358 SkASSERT(0); | 498 SkASSERT(0); |
359 } | 499 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 coincidence->add(coinPtT[0], testTAt, coinPtT[1], nextTAt, alloc
ator); | 540 coincidence->add(coinPtT[0], testTAt, coinPtT[1], nextTAt, alloc
ator); |
401 wt.segment()->debugValidate(); | 541 wt.segment()->debugValidate(); |
402 wn.segment()->debugValidate(); | 542 wn.segment()->debugValidate(); |
403 coinIndex = -1; | 543 coinIndex = -1; |
404 } | 544 } |
405 SkASSERT(coinIndex < 0); // expect coincidence to be paired | 545 SkASSERT(coinIndex < 0); // expect coincidence to be paired |
406 } while (wn.advance()); | 546 } while (wn.advance()); |
407 } while (wt.advance()); | 547 } while (wt.advance()); |
408 return true; | 548 return true; |
409 } | 549 } |
OLD | NEW |