| 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 "SkOpEdgeBuilder.h" | 9 #include "SkOpEdgeBuilder.h" |
| 10 #include "SkPathOpsCommon.h" | 10 #include "SkPathOpsCommon.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 // add coincidence formed by pairing on curve points and endpoints | 476 // add coincidence formed by pairing on curve points and endpoints |
| 477 coincidence->correctEnds(); | 477 coincidence->correctEnds(); |
| 478 if (!coincidence->addEndMovedSpans()) { | 478 if (!coincidence->addEndMovedSpans()) { |
| 479 return false; | 479 return false; |
| 480 } | 480 } |
| 481 DEBUG_COINCIDENCE_HEALTH(contourList, "addEndMovedSpans"); | 481 DEBUG_COINCIDENCE_HEALTH(contourList, "addEndMovedSpans"); |
| 482 | 482 |
| 483 const int SAFETY_COUNT = 100; // FIXME: tune | 483 const int SAFETY_COUNT = 100; // FIXME: tune |
| 484 int safetyHatch = SAFETY_COUNT; | 484 int safetyHatch = SAFETY_COUNT; |
| 485 // look for coincidence present in A-B and A-C but missing in B-C | 485 // look for coincidence present in A-B and A-C but missing in B-C |
| 486 while (coincidence->addMissing()) { | 486 do { |
| 487 bool added; |
| 488 if (!coincidence->addMissing(&added)) { |
| 489 return false; |
| 490 } |
| 491 if (!added) { |
| 492 break; |
| 493 } |
| 487 if (!--safetyHatch) { | 494 if (!--safetyHatch) { |
| 488 SkASSERT(globalState->debugSkipAssert()); | 495 SkASSERT(globalState->debugSkipAssert()); |
| 489 return false; | 496 return false; |
| 490 } | 497 } |
| 491 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing"); | 498 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing"); |
| 492 moveNearby(contourList); | 499 moveNearby(contourList); |
| 493 DEBUG_COINCIDENCE_HEALTH(contourList, "moveNearby"); | 500 DEBUG_COINCIDENCE_HEALTH(contourList, "moveNearby"); |
| 494 } | 501 } while (true); |
| 495 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing2"); | 502 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing2"); |
| 496 // FIXME: only call this if addMissing modified something when returning fal
se | 503 // FIXME: only call this if addMissing modified something when returning fal
se |
| 497 moveNearby(contourList); | 504 moveNearby(contourList); |
| 498 DEBUG_COINCIDENCE_HEALTH(contourList, "moveNearby2"); | 505 DEBUG_COINCIDENCE_HEALTH(contourList, "moveNearby2"); |
| 499 // check to see if, loosely, coincident ranges may be expanded | 506 // check to see if, loosely, coincident ranges may be expanded |
| 500 if (coincidence->expand()) { | 507 if (coincidence->expand()) { |
| 501 DEBUG_COINCIDENCE_HEALTH(contourList, "expand1"); | 508 DEBUG_COINCIDENCE_HEALTH(contourList, "expand1"); |
| 502 coincidence->addMissing(); | 509 bool added; |
| 510 if (!coincidence->addMissing(&added)) { |
| 511 return false; |
| 512 } |
| 503 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing2"); | 513 DEBUG_COINCIDENCE_HEALTH(contourList, "addMissing2"); |
| 504 if (!coincidence->addExpanded()) { | 514 if (!coincidence->addExpanded()) { |
| 505 return false; | 515 return false; |
| 506 } | 516 } |
| 507 DEBUG_COINCIDENCE_HEALTH(contourList, "addExpanded2"); | 517 DEBUG_COINCIDENCE_HEALTH(contourList, "addExpanded2"); |
| 508 if (!moveMultiples(contourList)) { | 518 if (!moveMultiples(contourList)) { |
| 509 return false; | 519 return false; |
| 510 } | 520 } |
| 511 DEBUG_COINCIDENCE_HEALTH(contourList, "moveMultiples2"); | 521 DEBUG_COINCIDENCE_HEALTH(contourList, "moveMultiples2"); |
| 512 moveNearby(contourList); | 522 moveNearby(contourList); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 592 } |
| 583 #if DEBUG_COINCIDENCE_VERBOSE | 593 #if DEBUG_COINCIDENCE_VERBOSE |
| 584 coincidence->debugShowCoincidence(); | 594 coincidence->debugShowCoincidence(); |
| 585 #endif | 595 #endif |
| 586 #if DEBUG_COINCIDENCE | 596 #if DEBUG_COINCIDENCE |
| 587 coincidence->debugValidate(); | 597 coincidence->debugValidate(); |
| 588 #endif | 598 #endif |
| 589 SkPathOpsDebug::ShowActiveSpans(contourList); | 599 SkPathOpsDebug::ShowActiveSpans(contourList); |
| 590 return true; | 600 return true; |
| 591 } | 601 } |
| OLD | NEW |