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 "SkOpCoincidence.h" | 7 #include "SkOpCoincidence.h" |
8 #include "SkOpContour.h" | 8 #include "SkOpContour.h" |
9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 | 848 |
849 bool SkOpSegment::markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, in
t winding, | 849 bool SkOpSegment::markAndChaseWinding(SkOpSpanBase* start, SkOpSpanBase* end, in
t winding, |
850 SkOpSpanBase** lastPtr) { | 850 SkOpSpanBase** lastPtr) { |
851 SkOpSpan* spanStart = start->starter(end); | 851 SkOpSpan* spanStart = start->starter(end); |
852 int step = start->step(end); | 852 int step = start->step(end); |
853 bool success = markWinding(spanStart, winding); | 853 bool success = markWinding(spanStart, winding); |
854 SkOpSpanBase* last = nullptr; | 854 SkOpSpanBase* last = nullptr; |
855 SkOpSegment* other = this; | 855 SkOpSegment* other = this; |
856 while ((other = other->nextChase(&start, &step, &spanStart, &last))) { | 856 while ((other = other->nextChase(&start, &step, &spanStart, &last))) { |
857 if (spanStart->windSum() != SK_MinS32) { | 857 if (spanStart->windSum() != SK_MinS32) { |
858 SkASSERT(spanStart->windSum() == winding); | 858 // SkASSERT(spanStart->windSum() == winding); // FIXME: is this ass
ert too aggressive? |
859 SkASSERT(!last); | 859 SkASSERT(!last); |
860 break; | 860 break; |
861 } | 861 } |
862 (void) other->markWinding(spanStart, winding); | 862 (void) other->markWinding(spanStart, winding); |
863 } | 863 } |
864 if (lastPtr) { | 864 if (lastPtr) { |
865 *lastPtr = last; | 865 *lastPtr = last; |
866 } | 866 } |
867 return success; | 867 return success; |
868 } | 868 } |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 } else { | 1452 } else { |
1453 *maxWinding = *sumMiWinding; | 1453 *maxWinding = *sumMiWinding; |
1454 *sumWinding = *sumMiWinding -= deltaSum; | 1454 *sumWinding = *sumMiWinding -= deltaSum; |
1455 *oppMaxWinding = *sumSuWinding; | 1455 *oppMaxWinding = *sumSuWinding; |
1456 *oppSumWinding = *sumSuWinding -= oppDeltaSum; | 1456 *oppSumWinding = *sumSuWinding -= oppDeltaSum; |
1457 } | 1457 } |
1458 SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*sumWinding) <= DEBUG_LIMIT_WIND_SU
M); | 1458 SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*sumWinding) <= DEBUG_LIMIT_WIND_SU
M); |
1459 SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*oppSumWinding) <= DEBUG_LIMIT_WIND
_SUM); | 1459 SkASSERT(!DEBUG_LIMIT_WIND_SUM || SkTAbs(*oppSumWinding) <= DEBUG_LIMIT_WIND
_SUM); |
1460 } | 1460 } |
1461 | 1461 |
1462 void SkOpSegment::sortAngles() { | 1462 bool SkOpSegment::sortAngles() { |
1463 SkOpSpanBase* span = &this->fHead; | 1463 SkOpSpanBase* span = &this->fHead; |
1464 do { | 1464 do { |
1465 SkOpAngle* fromAngle = span->fromAngle(); | 1465 SkOpAngle* fromAngle = span->fromAngle(); |
1466 SkOpAngle* toAngle = span->final() ? nullptr : span->upCast()->toAngle()
; | 1466 SkOpAngle* toAngle = span->final() ? nullptr : span->upCast()->toAngle()
; |
1467 if (!fromAngle && !toAngle) { | 1467 if (!fromAngle && !toAngle) { |
1468 continue; | 1468 continue; |
1469 } | 1469 } |
1470 #if DEBUG_ANGLE | 1470 #if DEBUG_ANGLE |
1471 bool wroteAfterHeader = false; | 1471 bool wroteAfterHeader = false; |
1472 #endif | 1472 #endif |
1473 SkOpAngle* baseAngle = fromAngle; | 1473 SkOpAngle* baseAngle = fromAngle; |
1474 if (fromAngle && toAngle) { | 1474 if (fromAngle && toAngle) { |
1475 #if DEBUG_ANGLE | 1475 #if DEBUG_ANGLE |
1476 SkDebugf("%s [%d] tStart=%1.9g [%d]\n", __FUNCTION__, debugID(), spa
n->t(), | 1476 SkDebugf("%s [%d] tStart=%1.9g [%d]\n", __FUNCTION__, debugID(), spa
n->t(), |
1477 span->debugID()); | 1477 span->debugID()); |
1478 wroteAfterHeader = true; | 1478 wroteAfterHeader = true; |
1479 #endif | 1479 #endif |
1480 fromAngle->insert(toAngle); | 1480 FAIL_IF(!fromAngle->insert(toAngle)); |
1481 } else if (!fromAngle) { | 1481 } else if (!fromAngle) { |
1482 baseAngle = toAngle; | 1482 baseAngle = toAngle; |
1483 } | 1483 } |
1484 SkOpPtT* ptT = span->ptT(), * stopPtT = ptT; | 1484 SkOpPtT* ptT = span->ptT(), * stopPtT = ptT; |
1485 do { | 1485 do { |
1486 SkOpSpanBase* oSpan = ptT->span(); | 1486 SkOpSpanBase* oSpan = ptT->span(); |
1487 if (oSpan == span) { | 1487 if (oSpan == span) { |
1488 continue; | 1488 continue; |
1489 } | 1489 } |
1490 SkOpAngle* oAngle = oSpan->fromAngle(); | 1490 SkOpAngle* oAngle = oSpan->fromAngle(); |
(...skipping 29 matching lines...) Expand all Loading... |
1520 span->setFromAngle(nullptr); | 1520 span->setFromAngle(nullptr); |
1521 if (toAngle) { | 1521 if (toAngle) { |
1522 span->upCast()->setToAngle(nullptr); | 1522 span->upCast()->setToAngle(nullptr); |
1523 } | 1523 } |
1524 baseAngle = nullptr; | 1524 baseAngle = nullptr; |
1525 } | 1525 } |
1526 #if DEBUG_SORT | 1526 #if DEBUG_SORT |
1527 SkASSERT(!baseAngle || baseAngle->loopCount() > 1); | 1527 SkASSERT(!baseAngle || baseAngle->loopCount() > 1); |
1528 #endif | 1528 #endif |
1529 } while (!span->final() && (span = span->upCast()->next())); | 1529 } while (!span->final() && (span = span->upCast()->next())); |
| 1530 return true; |
1530 } | 1531 } |
1531 | 1532 |
1532 bool SkOpSegment::subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, | 1533 bool SkOpSegment::subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, |
1533 SkDCurve* edge) const { | 1534 SkDCurve* edge) const { |
1534 SkASSERT(start != end); | 1535 SkASSERT(start != end); |
1535 const SkOpPtT& startPtT = *start->ptT(); | 1536 const SkOpPtT& startPtT = *start->ptT(); |
1536 const SkOpPtT& endPtT = *end->ptT(); | 1537 const SkOpPtT& endPtT = *end->ptT(); |
1537 SkDEBUGCODE(edge->fVerb = fVerb); | 1538 SkDEBUGCODE(edge->fVerb = fVerb); |
1538 edge->fCubic[0].set(startPtT.fPt); | 1539 edge->fCubic[0].set(startPtT.fPt); |
1539 int points = SkPathOpsVerbToPoints(fVerb); | 1540 int points = SkPathOpsVerbToPoints(fVerb); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 int absOut = SkTAbs(outerWinding); | 1687 int absOut = SkTAbs(outerWinding); |
1687 int absIn = SkTAbs(innerWinding); | 1688 int absIn = SkTAbs(innerWinding); |
1688 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1689 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
1689 return result; | 1690 return result; |
1690 } | 1691 } |
1691 | 1692 |
1692 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1693 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
1693 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1694 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
1694 return minSpan->windSum(); | 1695 return minSpan->windSum(); |
1695 } | 1696 } |
OLD | NEW |