| 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 "SkOpEdgeBuilder.h" | 8 #include "SkOpEdgeBuilder.h" |
| 8 #include "SkPathOpsCommon.h" | 9 #include "SkPathOpsCommon.h" |
| 9 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
| 10 #include "SkTSort.h" | 11 #include "SkTSort.h" |
| 11 | 12 |
| 12 static int contourRangeCheckY(const SkTArray<SkOpContour*, true>& contourList, S
kOpSegment** currentPtr, | 13 static int contourRangeCheckY(const SkTArray<SkOpContour*, true>& contourList, S
kOpSegment** currentPtr, |
| 13 int* indexPtr, int* endIndexPtr, double* bestHit,
SkScalar* bestDx, | 14 int* indexPtr, int* endIndexPtr, double* bestHit,
SkScalar* bestDx, |
| 14 bool* tryAgain, double* midPtr, bool opp) { | 15 bool* tryAgain, double* midPtr, bool opp) { |
| 15 const int index = *indexPtr; | 16 const int index = *indexPtr; |
| 16 const int endIndex = *endIndexPtr; | 17 const int endIndex = *endIndexPtr; |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 break; | 344 break; |
| 344 } | 345 } |
| 345 oppContourWinding = rightAngleWinding(contourList, ¤t, indexPtr, e
ndIndexPtr, &tHit, | 346 oppContourWinding = rightAngleWinding(contourList, ¤t, indexPtr, e
ndIndexPtr, &tHit, |
| 346 &hitOppDx, &tryAgain, true); | 347 &hitOppDx, &tryAgain, true); |
| 347 } while (tryAgain); | 348 } while (tryAgain); |
| 348 current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx, o
ppContourWinding, | 349 current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx, o
ppContourWinding, |
| 349 hitOppDx); | 350 hitOppDx); |
| 350 return current; | 351 return current; |
| 351 } | 352 } |
| 352 | 353 |
| 353 void CheckEnds(SkTArray<SkOpContour*, true>* contourList) { | 354 static void checkEnds(SkTArray<SkOpContour*, true>* contourList) { |
| 354 // it's hard to determine if the end of a cubic or conic nearly intersects a
nother curve. | 355 // it's hard to determine if the end of a cubic or conic nearly intersects a
nother curve. |
| 355 // instead, look to see if the connecting curve intersected at that same end
. | 356 // instead, look to see if the connecting curve intersected at that same end
. |
| 356 int contourCount = (*contourList).count(); | 357 int contourCount = (*contourList).count(); |
| 357 for (int cTest = 0; cTest < contourCount; ++cTest) { | 358 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 358 SkOpContour* contour = (*contourList)[cTest]; | 359 SkOpContour* contour = (*contourList)[cTest]; |
| 359 contour->checkEnds(); | 360 contour->checkEnds(); |
| 360 } | 361 } |
| 361 } | 362 } |
| 362 | 363 |
| 363 // A tiny interval may indicate an undiscovered coincidence. Find and fix. | 364 // A tiny interval may indicate an undiscovered coincidence. Find and fix. |
| 364 void CheckTiny(SkTArray<SkOpContour*, true>* contourList) { | 365 static void checkTiny(SkTArray<SkOpContour*, true>* contourList) { |
| 365 int contourCount = (*contourList).count(); | 366 int contourCount = (*contourList).count(); |
| 366 for (int cTest = 0; cTest < contourCount; ++cTest) { | 367 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 367 SkOpContour* contour = (*contourList)[cTest]; | 368 SkOpContour* contour = (*contourList)[cTest]; |
| 368 contour->checkTiny(); | 369 contour->checkTiny(); |
| 369 } | 370 } |
| 370 } | 371 } |
| 371 | 372 |
| 372 void FixOtherTIndex(SkTArray<SkOpContour*, true>* contourList) { | 373 static void fixOtherTIndex(SkTArray<SkOpContour*, true>* contourList) { |
| 373 int contourCount = (*contourList).count(); | 374 int contourCount = (*contourList).count(); |
| 374 for (int cTest = 0; cTest < contourCount; ++cTest) { | 375 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 375 SkOpContour* contour = (*contourList)[cTest]; | 376 SkOpContour* contour = (*contourList)[cTest]; |
| 376 contour->fixOtherTIndex(); | 377 contour->fixOtherTIndex(); |
| 377 } | 378 } |
| 378 } | 379 } |
| 379 | 380 |
| 380 void SortSegments(SkTArray<SkOpContour*, true>* contourList) { | 381 static void joinCoincidence(SkTArray<SkOpContour*, true>* contourList) { |
| 381 int contourCount = (*contourList).count(); | 382 int contourCount = (*contourList).count(); |
| 382 for (int cTest = 0; cTest < contourCount; ++cTest) { | 383 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 383 SkOpContour* contour = (*contourList)[cTest]; | 384 SkOpContour* contour = (*contourList)[cTest]; |
| 385 contour->joinCoincidence(); |
| 386 } |
| 387 } |
| 388 |
| 389 static void sortSegments(SkTArray<SkOpContour*, true>* contourList) { |
| 390 int contourCount = (*contourList).count(); |
| 391 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 392 SkOpContour* contour = (*contourList)[cTest]; |
| 384 contour->sortSegments(); | 393 contour->sortSegments(); |
| 385 } | 394 } |
| 386 } | 395 } |
| 387 | 396 |
| 388 void MakeContourList(SkTArray<SkOpContour>& contours, SkTArray<SkOpContour*, tru
e>& list, | 397 void MakeContourList(SkTArray<SkOpContour>& contours, SkTArray<SkOpContour*, tru
e>& list, |
| 389 bool evenOdd, bool oppEvenOdd) { | 398 bool evenOdd, bool oppEvenOdd) { |
| 390 int count = contours.count(); | 399 int count = contours.count(); |
| 391 if (count == 0) { | 400 if (count == 0) { |
| 392 return; | 401 return; |
| 393 } | 402 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 605 } |
| 597 } | 606 } |
| 598 } while (rIndex < count); | 607 } while (rIndex < count); |
| 599 #if DEBUG_ASSEMBLE | 608 #if DEBUG_ASSEMBLE |
| 600 for (rIndex = 0; rIndex < count; ++rIndex) { | 609 for (rIndex = 0; rIndex < count; ++rIndex) { |
| 601 SkASSERT(sLink[rIndex] == SK_MaxS32); | 610 SkASSERT(sLink[rIndex] == SK_MaxS32); |
| 602 SkASSERT(eLink[rIndex] == SK_MaxS32); | 611 SkASSERT(eLink[rIndex] == SK_MaxS32); |
| 603 } | 612 } |
| 604 #endif | 613 #endif |
| 605 } | 614 } |
| 615 |
| 616 void HandleCoincidence(SkTArray<SkOpContour*, true>* contourList, int total) { |
| 617 #if DEBUG_SHOW_WINDING |
| 618 SkOpContour::debugShowWindingValues(contourList); |
| 619 #endif |
| 620 CoincidenceCheck(contourList, total); |
| 621 #if DEBUG_SHOW_WINDING |
| 622 SkOpContour::debugShowWindingValues(contourList); |
| 623 #endif |
| 624 fixOtherTIndex(contourList); |
| 625 checkEnds(contourList); |
| 626 checkTiny(contourList); |
| 627 joinCoincidence(contourList); |
| 628 sortSegments(contourList); |
| 629 #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY |
| 630 DebugShowActiveSpans(*contourList); |
| 631 #endif |
| 632 } |
| OLD | NEW |