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 "SkOpEdgeBuilder.h" | 7 #include "SkOpEdgeBuilder.h" |
8 #include "SkPathOpsCommon.h" | 8 #include "SkPathOpsCommon.h" |
9 #include "SkPathWriter.h" | 9 #include "SkPathWriter.h" |
10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 return; | 392 return; |
393 } | 393 } |
394 for (int index = 0; index < count; ++index) { | 394 for (int index = 0; index < count; ++index) { |
395 SkOpContour& contour = contours[index]; | 395 SkOpContour& contour = contours[index]; |
396 contour.setOppXor(contour.operand() ? evenOdd : oppEvenOdd); | 396 contour.setOppXor(contour.operand() ? evenOdd : oppEvenOdd); |
397 list.push_back(&contour); | 397 list.push_back(&contour); |
398 } | 398 } |
399 SkTQSort<SkOpContour>(list.begin(), list.end() - 1); | 399 SkTQSort<SkOpContour>(list.begin(), list.end() - 1); |
400 } | 400 } |
401 | 401 |
402 static bool approximatelyEqual(const SkPoint& a, const SkPoint& b) { | |
403 return AlmostEqualUlps(a.fX, b.fX) && AlmostEqualUlps(a.fY, b.fY); | |
404 } | |
405 | |
406 class DistanceLessThan { | 402 class DistanceLessThan { |
407 public: | 403 public: |
408 DistanceLessThan(double* distances) : fDistances(distances) { } | 404 DistanceLessThan(double* distances) : fDistances(distances) { } |
409 double* fDistances; | 405 double* fDistances; |
410 bool operator()(const int one, const int two) { | 406 bool operator()(const int one, const int two) { |
411 return fDistances[one] < fDistances[two]; | 407 return fDistances[one] < fDistances[two]; |
412 } | 408 } |
413 }; | 409 }; |
414 | 410 |
415 /* | 411 /* |
(...skipping 12 matching lines...) Expand all Loading... |
428 builder.finish(); | 424 builder.finish(); |
429 int count = contours.count(); | 425 int count = contours.count(); |
430 int outer; | 426 int outer; |
431 SkTArray<int, true> runs(count); // indices of partial contours | 427 SkTArray<int, true> runs(count); // indices of partial contours |
432 for (outer = 0; outer < count; ++outer) { | 428 for (outer = 0; outer < count; ++outer) { |
433 const SkOpContour& eContour = contours[outer]; | 429 const SkOpContour& eContour = contours[outer]; |
434 const SkPoint& eStart = eContour.start(); | 430 const SkPoint& eStart = eContour.start(); |
435 const SkPoint& eEnd = eContour.end(); | 431 const SkPoint& eEnd = eContour.end(); |
436 #if DEBUG_ASSEMBLE | 432 #if DEBUG_ASSEMBLE |
437 SkDebugf("%s contour", __FUNCTION__); | 433 SkDebugf("%s contour", __FUNCTION__); |
438 if (!approximatelyEqual(eStart, eEnd)) { | 434 if (!SkDPoint::ApproximatelyEqual(eStart, eEnd)) { |
439 SkDebugf("[%d]", runs.count()); | 435 SkDebugf("[%d]", runs.count()); |
440 } else { | 436 } else { |
441 SkDebugf(" "); | 437 SkDebugf(" "); |
442 } | 438 } |
443 SkDebugf(" start=(%1.9g,%1.9g) end=(%1.9g,%1.9g)\n", | 439 SkDebugf(" start=(%1.9g,%1.9g) end=(%1.9g,%1.9g)\n", |
444 eStart.fX, eStart.fY, eEnd.fX, eEnd.fY); | 440 eStart.fX, eStart.fY, eEnd.fX, eEnd.fY); |
445 #endif | 441 #endif |
446 if (approximatelyEqual(eStart, eEnd)) { | 442 if (SkDPoint::ApproximatelyEqual(eStart, eEnd)) { |
447 eContour.toPath(simple); | 443 eContour.toPath(simple); |
448 continue; | 444 continue; |
449 } | 445 } |
450 runs.push_back(outer); | 446 runs.push_back(outer); |
451 } | 447 } |
452 count = runs.count(); | 448 count = runs.count(); |
453 if (count == 0) { | 449 if (count == 0) { |
454 return; | 450 return; |
455 } | 451 } |
456 SkTArray<int, true> sLink, eLink; | 452 SkTArray<int, true> sLink, eLink; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 596 } |
601 } | 597 } |
602 } while (rIndex < count); | 598 } while (rIndex < count); |
603 #if DEBUG_ASSEMBLE | 599 #if DEBUG_ASSEMBLE |
604 for (rIndex = 0; rIndex < count; ++rIndex) { | 600 for (rIndex = 0; rIndex < count; ++rIndex) { |
605 SkASSERT(sLink[rIndex] == SK_MaxS32); | 601 SkASSERT(sLink[rIndex] == SK_MaxS32); |
606 SkASSERT(eLink[rIndex] == SK_MaxS32); | 602 SkASSERT(eLink[rIndex] == SK_MaxS32); |
607 } | 603 } |
608 #endif | 604 #endif |
609 } | 605 } |
OLD | NEW |