Stop using SkTSwap.
Use std::swap instead. It does not appear that any external user
specializes SkTSwap, but some may still use it. This removes all use in
Skia so that SkTSwap can later be removed in a smaller CL. After that
the <utility> include can be removed from SkTypes.h.
Change-Id: If03d4ee07dbecda961aa9f0dc34d171ef5168753
Reviewed-on: https://skia-review.googlesource.com/135578
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp
index 93d0e40..a25a67e 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 @@
// 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 @@
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 @@
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 @@
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 swapOpp = oppTs > oppTe;
if (swapOpp) {
- SkTSwap(oppTs, oppTe);
+ using std::swap;
+ swap(oppTs, oppTe);
}
do {
if (check->coinPtTStart()->segment() != coinSeg) {
@@ -591,7 +599,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
if (addToStart) {
if (operandSwap) {
- SkTSwap(oWindValue, oOppValue);
+ using std::swap;
+ swap(oWindValue, oOppValue);
}
if (flipped) {
windValue -= oWindValue;
@@ -1072,7 +1086,8 @@
oWindValue = oOppValue = 0;
} else {
if (operandSwap) {
- SkTSwap(windValue, oppValue);
+ using std::swap;
+ swap(windValue, oppValue);
}
if (flipped) {
oWindValue -= windValue;
@@ -1327,7 +1342,8 @@
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 */