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 "SkPathOpsBounds.h" | 8 #include "SkPathOpsBounds.h" |
9 | 9 |
10 #if DEBUG_ADD_INTERSECTING_TS | 10 #if DEBUG_ADD_INTERSECTING_TS |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 if (!foundCommonContour && pts > 0) { | 357 if (!foundCommonContour && pts > 0) { |
358 test->addCross(next); | 358 test->addCross(next); |
359 next->addCross(test); | 359 next->addCross(test); |
360 foundCommonContour = true; | 360 foundCommonContour = true; |
361 } | 361 } |
362 // in addition to recording T values, record matching segment | 362 // in addition to recording T values, record matching segment |
363 if (pts == 2) { | 363 if (pts == 2) { |
364 if (wn.segmentType() <= SkIntersectionHelper::kLine_Segment | 364 if (wn.segmentType() <= SkIntersectionHelper::kLine_Segment |
365 && wt.segmentType() <= SkIntersectionHelper::kLine_Segme
nt) { | 365 && wt.segmentType() <= SkIntersectionHelper::kLine_Segme
nt) { |
366 wt.addCoincident(wn, ts, swap); | 366 if (wt.addCoincident(wn, ts, swap)) { |
367 continue; | 367 continue; |
368 } | 368 } |
369 if (wn.segmentType() >= SkIntersectionHelper::kQuad_Segment | 369 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1) |
| 370 pts = 1; |
| 371 } else if (wn.segmentType() >= SkIntersectionHelper::kQuad_Segme
nt |
370 && wt.segmentType() >= SkIntersectionHelper::kQuad_Segme
nt | 372 && wt.segmentType() >= SkIntersectionHelper::kQuad_Segme
nt |
371 && ts.isCoincident(0)) { | 373 && ts.isCoincident(0)) { |
372 SkASSERT(ts.coincidentUsed() == 2); | 374 SkASSERT(ts.coincidentUsed() == 2); |
373 wt.addCoincident(wn, ts, swap); | 375 if (wt.addCoincident(wn, ts, swap)) { |
374 continue; | 376 continue; |
| 377 } |
| 378 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1) |
| 379 pts = 1; |
375 } | 380 } |
376 } | 381 } |
377 if (pts >= 2) { | 382 if (pts >= 2) { |
378 for (int pt = 0; pt < pts - 1; ++pt) { | 383 for (int pt = 0; pt < pts - 1; ++pt) { |
379 const SkDPoint& point = ts.pt(pt); | 384 const SkDPoint& point = ts.pt(pt); |
380 const SkDPoint& next = ts.pt(pt + 1); | 385 const SkDPoint& next = ts.pt(pt + 1); |
381 if (wt.isNear(ts[swap][pt], ts[swap][pt + 1], point, next) | 386 if (wt.isNear(ts[swap][pt], ts[swap][pt + 1], point, next) |
382 && wn.isNear(ts[!swap][pt], ts[!swap][pt + 1], point
, next)) { | 387 && wn.isNear(ts[!swap][pt], ts[!swap][pt + 1], point
, next)) { |
383 wt.addPartialCoincident(wn, ts, pt, swap); | 388 if (!wt.addPartialCoincident(wn, ts, pt, swap)) { |
| 389 // remove extra point if two map to same float value
s |
| 390 ts.cleanUpCoincidence(); // prefer (t == 0 or t ==
1) |
| 391 pts = 1; |
| 392 } |
384 } | 393 } |
385 } | 394 } |
386 } | 395 } |
387 for (int pt = 0; pt < pts; ++pt) { | 396 for (int pt = 0; pt < pts; ++pt) { |
388 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1); | 397 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1); |
389 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1); | 398 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1); |
390 SkPoint point = ts.pt(pt).asSkPoint(); | 399 SkPoint point = ts.pt(pt).asSkPoint(); |
391 int testTAt = wt.addT(wn, point, ts[swap][pt], swap && ts.isNear
(pt)); | 400 int testTAt = wt.addT(wn, point, ts[swap][pt], swap && ts.isNear
(pt)); |
392 int nextTAt = wn.addT(wt, point, ts[!swap][pt], !swap && ts.isNe
ar(pt)); | 401 int nextTAt = wn.addT(wt, point, ts[!swap][pt], !swap && ts.isNe
ar(pt)); |
393 wt.addOtherT(testTAt, ts[!swap][pt], nextTAt); | 402 wt.addOtherT(testTAt, ts[!swap][pt], nextTAt); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 441 } |
433 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { | 442 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { |
434 SkOpContour* contour = (*contourList)[cIndex]; | 443 SkOpContour* contour = (*contourList)[cIndex]; |
435 contour->calcCoincidentWinding(); | 444 contour->calcCoincidentWinding(); |
436 } | 445 } |
437 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { | 446 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { |
438 SkOpContour* contour = (*contourList)[cIndex]; | 447 SkOpContour* contour = (*contourList)[cIndex]; |
439 contour->calcPartialCoincidentWinding(); | 448 contour->calcPartialCoincidentWinding(); |
440 } | 449 } |
441 } | 450 } |
OLD | NEW |