diff options
Diffstat (limited to 'src/pathops')
-rw-r--r-- | src/pathops/SkAddIntersections.cpp | 7 | ||||
-rw-r--r-- | src/pathops/SkDLineIntersection.cpp | 8 | ||||
-rw-r--r-- | src/pathops/SkOpCoincidence.cpp | 68 | ||||
-rw-r--r-- | src/pathops/SkOpSegment.cpp | 22 | ||||
-rw-r--r-- | src/pathops/SkPathOpsDebug.cpp | 46 | ||||
-rw-r--r-- | src/pathops/SkPathOpsOp.cpp | 8 | ||||
-rw-r--r-- | src/pathops/SkPathOpsTSect.h | 16 | ||||
-rw-r--r-- | src/pathops/SkPathOpsWinding.cpp | 8 |
8 files changed, 120 insertions, 63 deletions
diff --git a/src/pathops/SkAddIntersections.cpp b/src/pathops/SkAddIntersections.cpp index f772cc2b06..1749ca9674 100644 --- a/src/pathops/SkAddIntersections.cpp +++ b/src/pathops/SkAddIntersections.cpp @@ -8,6 +8,8 @@ #include "SkOpCoincidence.h" #include "SkPathOpsBounds.h" +#include <utility> + #if DEBUG_ADD_INTERSECTING_TS static void debugShowLineIntersection(int pts, const SkIntersectionHelper& wt, @@ -551,8 +553,9 @@ bool AddIntersectTs(SkOpContour* test, SkOpContour* next, SkOpCoincidence* coinc continue; } if (swap) { - SkTSwap(coinPtT[0], coinPtT[1]); - SkTSwap(testTAt, nextTAt); + using std::swap; + swap(coinPtT[0], coinPtT[1]); + swap(testTAt, nextTAt); } SkASSERT(coincidence->globalState()->debugSkipAssert() || coinPtT[0]->span()->t() < testTAt->span()->t()); diff --git a/src/pathops/SkDLineIntersection.cpp b/src/pathops/SkDLineIntersection.cpp index faca087235..43c37decb8 100644 --- a/src/pathops/SkDLineIntersection.cpp +++ b/src/pathops/SkDLineIntersection.cpp @@ -7,6 +7,8 @@ #include "SkIntersections.h" #include "SkPathOpsLine.h" +#include <utility> + void SkIntersections::cleanUpParallelLines(bool parallel) { while (fUsed > 2) { removeOne(1); @@ -182,7 +184,8 @@ static int horizontal_coincident(const SkDLine& line, double y) { double min = line[0].fY; double max = line[1].fY; if (min > max) { - SkTSwap(min, max); + using std::swap; + swap(min, max); } if (min > y || max < y) { return 0; @@ -258,7 +261,8 @@ static int vertical_coincident(const SkDLine& line, double x) { double min = line[0].fX; double max = line[1].fX; if (min > max) { - SkTSwap(min, max); + using std::swap; + swap(min, max); } if (!precisely_between(min, x, max)) { return 0; diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp index 93d0e403ff..a25a67e168 100644 --- a/src/pathops/SkOpCoincidence.cpp +++ b/src/pathops/SkOpCoincidence.cpp @@ -8,6 +8,8 @@ #include "SkOpSegment.h" #include "SkPathOpsTSect.h" +#include <utility> + // returns true if coincident span's start and end are the same bool SkCoincidentSpans::collapsed(const SkOpPtT* test) const { return (fCoinPtTStart == test && fCoinPtTEnd->contains(test)) @@ -120,7 +122,8 @@ void SkCoincidentSpans::set(SkCoincidentSpans* next, const SkOpPtT* coinPtTStart // returns true if both points are inside this bool SkCoincidentSpans::contains(const SkOpPtT* s, const SkOpPtT* e) const { if (s->fT > e->fT) { - SkTSwap(s, e); + using std::swap; + swap(s, e); } if (s->segment() == fCoinPtTStart->segment()) { return fCoinPtTStart->fT <= s->fT && e->fT <= fCoinPtTEnd->fT; @@ -129,7 +132,8 @@ bool SkCoincidentSpans::contains(const SkOpPtT* s, const SkOpPtT* e) const { double oppTs = fOppPtTStart->fT; double oppTe = fOppPtTEnd->fT; if (oppTs > oppTe) { - SkTSwap(oppTs, oppTe); + using std::swap; + swap(oppTs, oppTe); } return oppTs <= s->fT && e->fT <= oppTe; } @@ -193,12 +197,13 @@ bool SkOpCoincidence::extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtT const SkOpSegment* coinSeg = coinPtTStart->segment(); const SkOpSegment* oppSeg = oppPtTStart->segment(); if (!Ordered(coinPtTStart, oppPtTStart)) { - SkTSwap(coinSeg, oppSeg); - SkTSwap(coinPtTStart, oppPtTStart); - SkTSwap(coinPtTEnd, oppPtTEnd); + using std::swap; + swap(coinSeg, oppSeg); + swap(coinPtTStart, oppPtTStart); + swap(coinPtTEnd, oppPtTEnd); if (coinPtTStart->fT > coinPtTEnd->fT) { - SkTSwap(coinPtTStart, coinPtTEnd); - SkTSwap(oppPtTStart, oppPtTEnd); + swap(coinPtTStart, coinPtTEnd); + swap(oppPtTStart, oppPtTEnd); } } double oppMinT = SkTMin(oppPtTStart->fT, oppPtTEnd->fT); @@ -329,15 +334,17 @@ bool SkOpCoincidence::addEndMovedSpans(const SkOpSpan* base, const SkOpSpanBase* oppTs = oppStart->fT; oppTe = testPtT->fT; } else { - SkTSwap(coinSeg, oppSeg); + using std::swap; + swap(coinSeg, oppSeg); coinTs = oppStart->fT; coinTe = testPtT->fT; oppTs = base->t(); oppTe = testSpan->t(); } if (coinTs > coinTe) { - SkTSwap(coinTs, coinTe); - SkTSwap(oppTs, oppTe); + using std::swap; + swap(coinTs, coinTe); + swap(oppTs, oppTe); } bool added; if (!this->addOrOverlap(coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, &added)) { @@ -573,7 +580,8 @@ bool SkOpCoincidence::checkOverlap(SkCoincidentSpans* check, } bool swapOpp = oppTs > oppTe; if (swapOpp) { - SkTSwap(oppTs, oppTe); + using std::swap; + swap(oppTs, oppTe); } do { if (check->coinPtTStart()->segment() != coinSeg) { @@ -591,7 +599,8 @@ bool SkOpCoincidence::checkOverlap(SkCoincidentSpans* check, if (oCheckTs <= oCheckTe) { return false; } - SkTSwap(oCheckTs, oCheckTe); + using std::swap; + swap(oCheckTs, oCheckTe); } bool oppOutside = oppTe < oCheckTs || oppTs > oCheckTe; if (coinOutside && oppOutside) { @@ -637,8 +646,9 @@ bool SkOpCoincidence::addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over2s, return true; } if (coinTs > coinTe) { - SkTSwap(coinTs, coinTe); - SkTSwap(oppTs, oppTe); + using std::swap; + swap(coinTs, coinTe); + swap(oppTs, oppTe); } return this->addOrOverlap(coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, added); } @@ -747,8 +757,9 @@ bool SkOpCoincidence::addOrOverlap(SkOpSegment* coinSeg, SkOpSegment* oppSeg, result = overlap->extend(cs, ce, os, oe); } else { if (os->fT > oe->fT) { - SkTSwap(cs, ce); - SkTSwap(os, oe); + using std::swap; + swap(cs, ce); + swap(os, oe); } result = overlap->extend(os, oe, cs, ce); } @@ -903,8 +914,9 @@ bool SkOpCoincidence::addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg return true; } if (s1->fT > e1->fT) { - SkTSwap(s1, e1); - SkTSwap(s2, e2); + using std::swap; + swap(s1, e1); + swap(s2, e2); } this->add(s1, e1, s2, e2); return true; @@ -947,12 +959,13 @@ bool SkOpCoincidence::contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinP const SkOpSegment* coinSeg = coinPtTStart->segment(); const SkOpSegment* oppSeg = oppPtTStart->segment(); if (!Ordered(coinPtTStart, oppPtTStart)) { - SkTSwap(coinSeg, oppSeg); - SkTSwap(coinPtTStart, oppPtTStart); - SkTSwap(coinPtTEnd, oppPtTEnd); + using std::swap; + swap(coinSeg, oppSeg); + swap(coinPtTStart, oppPtTStart); + swap(coinPtTEnd, oppPtTEnd); if (coinPtTStart->fT > coinPtTEnd->fT) { - SkTSwap(coinPtTStart, coinPtTEnd); - SkTSwap(oppPtTStart, oppPtTEnd); + swap(coinPtTStart, coinPtTEnd); + swap(oppPtTStart, oppPtTEnd); } } double oppMinT = SkTMin(oppPtTStart->fT, oppPtTEnd->fT); @@ -1054,7 +1067,8 @@ bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { } if (addToStart) { if (operandSwap) { - SkTSwap(oWindValue, oOppValue); + using std::swap; + swap(oWindValue, oOppValue); } if (flipped) { windValue -= oWindValue; @@ -1072,7 +1086,8 @@ bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { oWindValue = oOppValue = 0; } else { if (operandSwap) { - SkTSwap(windValue, oppValue); + using std::swap; + swap(windValue, oppValue); } if (flipped) { oWindValue -= windValue; @@ -1327,7 +1342,8 @@ bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { FAIL_IF(oEnd->deleted()); bool flipped = coin->flipped(); if (flipped) { - SkTSwap(oStart, oEnd); + using std::swap; + swap(oStart, oEnd); } /* coin and opp spans may not match up. Mark the ends, and then let the interior get marked as many times as the spans allow */ diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp index 451a155c58..df70034f93 100644 --- a/src/pathops/SkOpSegment.cpp +++ b/src/pathops/SkOpSegment.cpp @@ -10,6 +10,8 @@ #include "SkPathWriter.h" #include "SkPointPriv.h" +#include <utility> + /* After computing raw intersections, post process all segments to: - find small collections of points that can be collapsed to a single point @@ -112,7 +114,8 @@ bool SkOpSegment::activeOp(SkOpSpanBase* start, SkOpSpanBase* end, int xorMiMask SkASSERT(abs(sumSuWinding) <= DEBUG_LIMIT_WIND_SUM); #endif if (this->operand()) { - SkTSwap<int>(sumMiWinding, sumSuWinding); + using std::swap; + swap(sumMiWinding, sumSuWinding); } return this->activeOp(xorMiMask, xorSuMask, start, end, op, &sumMiWinding, &sumSuWinding); } @@ -343,7 +346,8 @@ void SkOpSegment::ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle if (binary) { sumSuWinding = baseSegment->updateOppWindingReverse(baseAngle); if (baseSegment->operand()) { - SkTSwap<int>(sumMiWinding, sumSuWinding); + using std::swap; + swap(sumMiWinding, sumSuWinding); } } SkOpSegment* nextSegment = nextAngle->segment(); @@ -372,7 +376,8 @@ void SkOpSegment::ComputeOneSumReverse(SkOpAngle* baseAngle, SkOpAngle* nextAngl if (binary) { sumSuWinding = baseSegment->updateOppWinding(baseAngle); if (baseSegment->operand()) { - SkTSwap<int>(sumMiWinding, sumSuWinding); + using std::swap; + swap(sumMiWinding, sumSuWinding); } } SkOpSegment* nextSegment = nextAngle->segment(); @@ -569,7 +574,8 @@ SkOpSegment* SkOpSegment::findNextOp(SkTDArray<SkOpSpanBase*>* chase, SkOpSpanBa } int sumSuWinding = updateOppWinding(end, start); if (operand()) { - SkTSwap<int>(sumMiWinding, sumSuWinding); + using std::swap; + swap(sumMiWinding, sumSuWinding); } SkOpAngle* nextAngle = angle->next(); const SkOpAngle* foundAngle = nullptr; @@ -1170,8 +1176,9 @@ bool SkOpSegment::missingCoincidence() { SkOpPtT* oppEnd = spanBase->ptT(); bool swapped = priorPtT->fT > ptT->fT; if (swapped) { - SkTSwap(priorPtT, ptT); - SkTSwap(oppStart, oppEnd); + using std::swap; + swap(priorPtT, ptT); + swap(oppStart, oppEnd); } SkOpCoincidence* coincidences = this->globalState()->coincidence(); SkOpPtT* rootPriorPtT = priorPtT->span()->ptT(); @@ -1198,7 +1205,8 @@ bool SkOpSegment::missingCoincidence() { } swapBack: if (swapped) { - SkTSwap(priorPtT, ptT); + using std::swap; + swap(priorPtT, ptT); } } } while ((spanBase = spanBase->final() ? nullptr : spanBase->upCast()->next())); diff --git a/src/pathops/SkPathOpsDebug.cpp b/src/pathops/SkPathOpsDebug.cpp index 346db4b340..a88f413b00 100644 --- a/src/pathops/SkPathOpsDebug.cpp +++ b/src/pathops/SkPathOpsDebug.cpp @@ -13,6 +13,8 @@ #include "SkPathOpsDebug.h" #include "SkString.h" +#include <utility> + #if DEBUG_DUMP_VERIFY bool SkPathOpsDebug::gDumpOp; // set to true to write op to file before a crash bool SkPathOpsDebug::gVerifyOp; // set to true to compare result against regions @@ -923,8 +925,9 @@ void SkOpSegment::debugMissingCoincidence(SkPathOpsDebug::GlitchLog* log) const const SkOpPtT* oppEnd = spanBase->ptT(); bool swapped = priorPtT->fT > ptT->fT; if (swapped) { - SkTSwap(priorPtT, ptT); - SkTSwap(oppStart, oppEnd); + using std::swap; + swap(priorPtT, ptT); + swap(oppStart, oppEnd); } const SkOpCoincidence* coincidence = this->globalState()->coincidence(); const SkOpPtT* rootPriorPtT = priorPtT->span()->ptT(); @@ -951,7 +954,8 @@ void SkOpSegment::debugMissingCoincidence(SkPathOpsDebug::GlitchLog* log) const } swapBack: if (swapped) { - SkTSwap(priorPtT, ptT); + using std::swap; + swap(priorPtT, ptT); } } } while ((spanBase = spanBase->final() ? nullptr : spanBase->upCast()->next())); @@ -1531,15 +1535,17 @@ void SkOpCoincidence::debugAddEndMovedSpans(SkPathOpsDebug::GlitchLog* log, cons oppTs = oppStart->fT; oppTe = testPtT->fT; } else { - SkTSwap(coinSeg, oppSeg); + using std::swap; + swap(coinSeg, oppSeg); coinTs = oppStart->fT; coinTe = testPtT->fT; oppTs = base->t(); oppTe = testSpan->t(); } if (coinTs > coinTe) { - SkTSwap(coinTs, coinTe); - SkTSwap(oppTs, oppTe); + using std::swap; + swap(coinTs, coinTe); + swap(oppTs, oppTe); } bool added; if (this->debugAddOrOverlap(log, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, &added), false) { @@ -1743,11 +1749,11 @@ void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const Sk return log->record(SkPathOpsDebug::kAddIfCollapsed_Glitch, oppSeg); } if (coinTs > coinTe) { - SkTSwap(coinTs, coinTe); - SkTSwap(oppTs, oppTe); + using std::swap; + swap(coinTs, coinTe); + swap(oppTs, oppTe); } - return this->debugAddOrOverlap(log, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, added - ); + return this->debugAddOrOverlap(log, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, added); } /* Commented-out lines keep this in sync addOrOverlap() */ @@ -1848,8 +1854,9 @@ void SkOpCoincidence::debugAddOrOverlap(SkPathOpsDebug::GlitchLog* log, log->record(SkPathOpsDebug::kAddMissingExtend_Glitch, coinSeg, coinTs, coinTe, oppSeg, oppTs, oppTe); } else { if (oppTs > oppTe) { - SkTSwap(coinTs, coinTe); - SkTSwap(oppTs, oppTe); + using std::swap; + swap(coinTs, coinTe); + swap(oppTs, oppTe); } log->record(SkPathOpsDebug::kAddMissingExtend_Glitch, oppSeg, oppTs, oppTe, coinSeg, coinTs, coinTe); } @@ -2052,7 +2059,8 @@ void SkOpCoincidence::debugMark(SkPathOpsDebug::GlitchLog* log) const { // SkASSERT(oEnd->deleted()); bool flipped = coin->flipped(); if (flipped) { - SkTSwap(oStart, oEnd); + using std::swap; + swap(oStart, oEnd); } /* coin and opp spans may not match up. Mark the ends, and then let the interior get marked as many times as the spans allow */ @@ -2130,7 +2138,8 @@ static void DebugCheckBetween(const SkOpSpanBase* next, const SkOpSpanBase* end, SkASSERT(next != end); SkASSERT(!next->contains(end) || log); if (next->t() > end->t()) { - SkTSwap(next, end); + using std::swap; + swap(next, end); } do { const SkOpPtT* ptT = next->ptT(); @@ -2187,7 +2196,8 @@ static void DebugCheckOverlap(const SkCoincidentSpans* test, const SkCoincidentS SkASSERT(between(0, toe, 1)); SkASSERT(tos != toe); if (tos > toe) { - SkTSwap(tos, toe); + using std::swap; + swap(tos, toe); } do { double lcs, lce, los, loe; @@ -2200,7 +2210,8 @@ static void DebugCheckOverlap(const SkCoincidentSpans* test, const SkCoincidentS los = list->oppPtTStart()->fT; loe = list->oppPtTEnd()->fT; if (los > loe) { - SkTSwap(los, loe); + using std::swap; + swap(los, loe); } } else if (coinSeg == list->oppPtTStart()->segment()) { if (oppSeg != list->coinPtTStart()->segment()) { @@ -2209,7 +2220,8 @@ static void DebugCheckOverlap(const SkCoincidentSpans* test, const SkCoincidentS lcs = list->oppPtTStart()->fT; lce = list->oppPtTEnd()->fT; if (lcs > lce) { - SkTSwap(lcs, lce); + using std::swap; + swap(lcs, lce); } los = list->coinPtTStart()->fT; loe = list->coinPtTEnd()->fT; diff --git a/src/pathops/SkPathOpsOp.cpp b/src/pathops/SkPathOpsOp.cpp index 4dd687922f..09c6f0e1ce 100644 --- a/src/pathops/SkPathOpsOp.cpp +++ b/src/pathops/SkPathOpsOp.cpp @@ -10,6 +10,8 @@ #include "SkPathOpsCommon.h" #include "SkPathWriter.h" +#include <utility> + static SkOpSegment* findChaseOp(SkTDArray<SkOpSpanBase*>& chase, SkOpSpanBase** startPtr, SkOpSpanBase** endPtr) { while (chase.count()) { @@ -56,7 +58,8 @@ static SkOpSegment* findChaseOp(SkTDArray<SkOpSpanBase*>& chase, SkOpSpanBase** return nullptr; } if (segment->operand()) { - SkTSwap<int>(sumMiWinding, sumSuWinding); + using std::swap; + swap(sumMiWinding, sumSuWinding); } } SkOpSegment* first = nullptr; @@ -284,7 +287,8 @@ bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result subtrahend = &two; } if (op == kReverseDifference_SkPathOp) { - SkTSwap(minuend, subtrahend); + using std::swap; + swap(minuend, subtrahend); op = kDifference_SkPathOp; } #if DEBUG_SORT diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h index b052df97db..379ae34510 100644 --- a/src/pathops/SkPathOpsTSect.h +++ b/src/pathops/SkPathOpsTSect.h @@ -14,6 +14,8 @@ #include "SkPathOpsRect.h" #include "SkTSort.h" +#include <utility> + #ifdef SK_DEBUG typedef uint8_t SkOpDebugBool; #else @@ -1054,7 +1056,8 @@ void SkTSect<TCurve, OppCurve>::coincidentForce(SkTSect<OppCurve, TCurve>* sect2 double oppStartT = first->fCoinStart.perpT() == -1 ? 0 : SkTMax(0., first->fCoinStart.perpT()); double oppEndT = first->fCoinEnd.perpT() == -1 ? 1 : SkTMin(1., first->fCoinEnd.perpT()); if (!oppMatched) { - SkTSwap(oppStartT, oppEndT); + using std::swap; + swap(oppStartT, oppEndT); } oppFirst->fStartT = oppStartT; oppFirst->fEndT = oppEndT; @@ -1246,8 +1249,9 @@ bool SkTSect<TCurve, OppCurve>::extractCoincident( } #endif if (!oppMatched) { - SkTSwap(oppFirst, oppLast); - SkTSwap(oppStartT, oppEndT); + using std::swap; + swap(oppFirst, oppLast); + swap(oppStartT, oppEndT); } SkOPASSERT(oppStartT < oppEndT); SkASSERT(coinStart == first->fStartT); @@ -1277,7 +1281,8 @@ bool SkTSect<TCurve, OppCurve>::extractCoincident( oppEndT = first->fCoinEnd.perpT(); if (between(0, oppStartT, 1) && between(0, oppEndT, 1)) { if (!oppMatched) { - SkTSwap(oppStartT, oppEndT); + using std::swap; + swap(oppStartT, oppEndT); } oppFirst->fStartT = oppStartT; oppFirst->fEndT = oppEndT; @@ -1526,7 +1531,8 @@ int SkTSect<TCurve, OppCurve>::linesIntersect(SkTSpan<TCurve, OppCurve>* span, double tEnd = oCoinE.perpT(); bool swap = tStart > tEnd; if (swap) { - SkTSwap(tStart, tEnd); + using std::swap; + swap(tStart, tEnd); } tStart = SkTMax(tStart, span->fStartT); tEnd = SkTMin(tEnd, span->fEndT); diff --git a/src/pathops/SkPathOpsWinding.cpp b/src/pathops/SkPathOpsWinding.cpp index 48993a69c2..12cb1124e6 100644 --- a/src/pathops/SkPathOpsWinding.cpp +++ b/src/pathops/SkPathOpsWinding.cpp @@ -25,6 +25,8 @@ #include "SkOpSegment.h" #include "SkPathOpsCurve.h" +#include <utility> + enum class SkOpRayDir { kLeft, kTop, @@ -314,7 +316,8 @@ bool SkOpSpan::sortableTop(SkOpContour* contourHead) { } bool operand = hitSegment->operand(); if (operand) { - SkTSwap(wind, oppWind); + using std::swap; + swap(wind, oppWind); } int lastWind = wind; int lastOpp = oppWind; @@ -357,7 +360,8 @@ bool SkOpSpan::sortableTop(SkOpContour* contourHead) { } } if (operand) { - SkTSwap(wind, oppWind); + using std::swap; + swap(wind, oppWind); } last = &hit->fPt; this->globalState()->bumpNested(); |