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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 247 |
248 static void debugShowCubicConicIntersection(int , const SkIntersectionHelper& , | 248 static void debugShowCubicConicIntersection(int , const SkIntersectionHelper& , |
249 const SkIntersectionHelper& , const SkIntersections& ) { | 249 const SkIntersectionHelper& , const SkIntersections& ) { |
250 } | 250 } |
251 | 251 |
252 static void debugShowCubicIntersection(int , const SkIntersectionHelper& , | 252 static void debugShowCubicIntersection(int , const SkIntersectionHelper& , |
253 const SkIntersectionHelper& , const SkIntersections& ) { | 253 const SkIntersectionHelper& , const SkIntersections& ) { |
254 } | 254 } |
255 #endif | 255 #endif |
256 | 256 |
257 bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
idence, | 257 bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc
idence) { |
258 SkChunkAlloc* allocator) { | |
259 if (test != next) { | 258 if (test != next) { |
260 if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) { | 259 if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) { |
261 return false; | 260 return false; |
262 } | 261 } |
263 // OPTIMIZATION: outset contour bounds a smidgen instead? | 262 // OPTIMIZATION: outset contour bounds a smidgen instead? |
264 if (!SkPathOpsBounds::Intersects(test->bounds(), next->bounds())) { | 263 if (!SkPathOpsBounds::Intersects(test->bounds(), next->bounds())) { |
265 return true; | 264 return true; |
266 } | 265 } |
267 } | 266 } |
268 SkIntersectionHelper wt; | 267 SkIntersectionHelper wt; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 498 } |
500 #if DEBUG_T_SECT_LOOP_COUNT | 499 #if DEBUG_T_SECT_LOOP_COUNT |
501 test->globalState()->debugAddLoopCount(&ts, wt, wn); | 500 test->globalState()->debugAddLoopCount(&ts, wt, wn); |
502 #endif | 501 #endif |
503 int coinIndex = -1; | 502 int coinIndex = -1; |
504 SkOpPtT* coinPtT[2]; | 503 SkOpPtT* coinPtT[2]; |
505 for (int pt = 0; pt < pts; ++pt) { | 504 for (int pt = 0; pt < pts; ++pt) { |
506 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1); | 505 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1); |
507 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1); | 506 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1); |
508 wt.segment()->debugValidate(); | 507 wt.segment()->debugValidate(); |
509 SkOpPtT* testTAt = wt.segment()->addT(ts[swap][pt], SkOpSegment:
:kAllowAlias, | 508 SkOpPtT* testTAt = wt.segment()->addT(ts[swap][pt], SkOpSegment:
:kAllowAliasMatch, |
510 allocator); | 509 nullptr); |
511 wn.segment()->debugValidate(); | 510 wn.segment()->debugValidate(); |
512 SkOpPtT* nextTAt = wn.segment()->addT(ts[!swap][pt], SkOpSegment
::kAllowAlias, | 511 SkOpPtT* nextTAt = wn.segment()->addT(ts[!swap][pt], SkOpSegment
::kAllowAliasMatch, |
513 allocator); | 512 nullptr); |
514 testTAt->addOpp(nextTAt); | 513 if (testTAt->addOpp(nextTAt)) { |
| 514 testTAt->span()->checkForCollapsedCoincidence(); |
| 515 } |
515 if (testTAt->fPt != nextTAt->fPt) { | 516 if (testTAt->fPt != nextTAt->fPt) { |
516 testTAt->span()->unaligned(); | 517 testTAt->span()->unaligned(); |
517 nextTAt->span()->unaligned(); | 518 nextTAt->span()->unaligned(); |
518 } | 519 } |
519 wt.segment()->debugValidate(); | 520 wt.segment()->debugValidate(); |
520 wn.segment()->debugValidate(); | 521 wn.segment()->debugValidate(); |
521 if (!ts.isCoincident(pt)) { | 522 if (!ts.isCoincident(pt)) { |
522 continue; | 523 continue; |
523 } | 524 } |
524 if (coinIndex < 0) { | 525 if (coinIndex < 0) { |
525 coinPtT[0] = testTAt; | 526 coinPtT[0] = testTAt; |
526 coinPtT[1] = nextTAt; | 527 coinPtT[1] = nextTAt; |
527 coinIndex = pt; | 528 coinIndex = pt; |
528 continue; | 529 continue; |
529 } | 530 } |
530 if (coinPtT[0]->span() == testTAt->span()) { | 531 if (coinPtT[0]->span() == testTAt->span()) { |
531 coinIndex = -1; | 532 coinIndex = -1; |
532 continue; | 533 continue; |
533 } | 534 } |
534 if (coinPtT[1]->span() == nextTAt->span()) { | 535 if (coinPtT[1]->span() == nextTAt->span()) { |
535 coinIndex = -1; // coincidence span collapsed | 536 coinIndex = -1; // coincidence span collapsed |
536 continue; | 537 continue; |
537 } | 538 } |
538 if (swap) { | 539 if (swap) { |
539 SkTSwap(coinPtT[0], coinPtT[1]); | 540 SkTSwap(coinPtT[0], coinPtT[1]); |
540 SkTSwap(testTAt, nextTAt); | 541 SkTSwap(testTAt, nextTAt); |
541 } | 542 } |
542 SkASSERT(coinPtT[0]->span()->t() < testTAt->span()->t()); | 543 SkASSERT(coinPtT[0]->span()->t() < testTAt->span()->t()); |
543 coincidence->add(coinPtT[0], testTAt, coinPtT[1], nextTAt, alloc
ator); | 544 coincidence->add(coinPtT[0], testTAt, coinPtT[1], nextTAt); |
544 wt.segment()->debugValidate(); | 545 wt.segment()->debugValidate(); |
545 wn.segment()->debugValidate(); | 546 wn.segment()->debugValidate(); |
546 coinIndex = -1; | 547 coinIndex = -1; |
547 } | 548 } |
548 SkASSERT(coinIndex < 0); // expect coincidence to be paired | 549 SkASSERT(coinIndex < 0); // expect coincidence to be paired |
549 } while (wn.advance()); | 550 } while (wn.advance()); |
550 } while (wt.advance()); | 551 } while (wt.advance()); |
551 return true; | 552 return true; |
552 } | 553 } |
OLD | NEW |