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/bench/ImageCacheBudgetBench.cpp b/bench/ImageCacheBudgetBench.cpp
index d8f6cbb..2955945 100644
--- a/bench/ImageCacheBudgetBench.cpp
+++ b/bench/ImageCacheBudgetBench.cpp
@@ -14,6 +14,8 @@
#include "GrContext.h"
#include "GrContextPriv.h"
+#include <utility>
+
/** These benchmarks were designed to measure changes to GrResourceCache's replacement policy */
//////////////////////////////////////////////////////////////////////////////
@@ -102,7 +104,8 @@
}
for (int i = 0; i < kImagesToDraw - 1; ++i) {
int other = random.nextULessThan(kImagesToDraw - i) + i;
- SkTSwap(base[i], base[other]);
+ using std::swap;
+ swap(base[i], base[other]);
}
}
}
diff --git a/docs/SkColor_Reference.bmh b/docs/SkColor_Reference.bmh
index a92e393..27b76a5 100644
--- a/docs/SkColor_Reference.bmh
+++ b/docs/SkColor_Reference.bmh
@@ -676,8 +676,9 @@
for (int y = 0; y < 256; ++y) {
for (int x = 0; x < 256; ++x) {
SkScalar hsv[3];
- SkColorToHSV(source.getColor(x, y), hsv);
- SkTSwap(hsv[1], hsv[2]);
+ SkColorToHSV(source.getColor(x, y), hsv)
+ using std::swap;
+ swap(hsv[1], hsv[2]);
SkPaint paint;
paint.setColor(SkHSVToColor(hsv));
canvas->drawRect(SkRect::MakeXYWH(x, y, 1, 1), paint);
diff --git a/docs/SkPixmap_Reference.bmh b/docs/SkPixmap_Reference.bmh
index 432324e..019c13a 100644
--- a/docs/SkPixmap_Reference.bmh
+++ b/docs/SkPixmap_Reference.bmh
@@ -1387,8 +1387,9 @@
for (int y = 0; y < pixmap.height() / 2; ++y) {
for (int x = 0; x < pixmap.width(); ++x) {
if ((x & 4) == (y & 4)) {
- SkTSwap(*pixmap.writable_addr32(x, y),
- *pixmap.writable_addr32(pixmap.width() - x, pixmap.height() - y));
+ using std::swap;
+ swap(*pixmap.writable_addr32(x, y),
+ *pixmap.writable_addr32(pixmap.width() - x, pixmap.height() - y));
}
}
}
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index f63ddb1..2cb9968 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -77,6 +77,7 @@
// MISC
#include <iostream>
+#include <utility>
DEFINE_bool2(gpuInfo, g, false, "Display GPU information on relevant targets.");
@@ -1582,7 +1583,8 @@
paint.getTextWidths(text.begin(), SkToSizeT(text.count()), widths.get());
SkScalar x = widths[0];
for (int i = 0; i < glyphCount; ++i) {
- SkTSwap(x, widths[i]);
+ using std::swap;
+ swap(x, widths[i]);
x += widths[i];
SkScalar offset;
fuzz->nextRange(&offset, -0.125f * paint.getTextSize(),
diff --git a/gm/complexclip3.cpp b/gm/complexclip3.cpp
index 7c5c672..2415806 100644
--- a/gm/complexclip3.cpp
+++ b/gm/complexclip3.cpp
@@ -9,6 +9,8 @@
#include "SkCanvas.h"
#include "SkPath.h"
+#include <utility>
+
namespace skiagm {
constexpr SkColor gPathColor = SK_ColorYELLOW;
@@ -44,7 +46,8 @@
SkPath* secondClip = &clipComplex;
if (!fDoSimpleClipFirst) {
- SkTSwap<SkPath*>(firstClip, secondClip);
+ using std::swap;
+ swap(firstClip, secondClip);
}
SkPaint paint;
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index bfff3f3..4c1f028 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -14,6 +14,8 @@
#include "SkTArray.h"
#include "SkTrimPathEffect.h"
+#include <utility>
+
/*
* Inspired by http://code.google.com/p/chromium/issues/detail?id=112145
*/
@@ -128,8 +130,9 @@
start -= SkScalarFloorToScalar(start);
stop -= SkScalarFloorToScalar(stop);
if (start > stop) {
- SkTSwap(start, stop);
- SkTSwap(normalMode, invertedMode);
+ using std::swap;
+ swap(start, stop);
+ swap(normalMode, invertedMode);
}
}
diff --git a/gn/core.gni b/gn/core.gni
index 99da62f..9761dcc 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -267,6 +267,7 @@
"$_src/core/SkScalar.cpp",
"$_src/core/SkScalerContext.cpp",
"$_src/core/SkScalerContext.h",
+ "$_src/core/SkScaleToSides.h",
"$_src/core/SkScan.cpp",
"$_src/core/SkScan.h",
"$_src/core/SkScanPriv.h",
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index b33b0b9..ed0e599 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -23,6 +23,8 @@
#include "../private/SkSafe32.h"
#include "../private/SkTFitsIn.h"
+#include <utility>
+
struct SkRect;
/** \struct SkIRect
@@ -646,11 +648,12 @@
and width() and height() will be zero or positive.
*/
void sort() {
+ using std::swap;
if (fLeft > fRight) {
- SkTSwap<int32_t>(fLeft, fRight);
+ swap(fLeft, fRight);
}
if (fTop > fBottom) {
- SkTSwap<int32_t>(fTop, fBottom);
+ swap(fTop, fBottom);
}
}
@@ -1519,12 +1522,13 @@
and width() and height() will be zero or positive.
*/
void sort() {
+ using std::swap;
if (fLeft > fRight) {
- SkTSwap<SkScalar>(fLeft, fRight);
+ swap(fLeft, fRight);
}
if (fTop > fBottom) {
- SkTSwap<SkScalar>(fTop, fBottom);
+ swap(fTop, fBottom);
}
}
diff --git a/include/core/SkString.h b/include/core/SkString.h
index aa3292a..300d9ed 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -274,9 +274,7 @@
/// optional.
static inline SkString SkStringPrintf() { return SkString(); }
-// Specialized to take advantage of SkString's fast swap path. The unspecialized function is
-// declared in SkTypes.h and called by SkTSort.
-template <> inline void SkTSwap(SkString& a, SkString& b) {
+static inline void swap(SkString& a, SkString& b) {
a.swap(b);
}
diff --git a/include/gpu/gl/GrGLExtensions.h b/include/gpu/gl/GrGLExtensions.h
index 0b1ff44..73e5097 100644
--- a/include/gpu/gl/GrGLExtensions.h
+++ b/include/gpu/gl/GrGLExtensions.h
@@ -12,6 +12,8 @@
#include "GrGLFunctions.h"
#include "SkString.h"
+#include <utility>
+
struct GrGLInterface;
class SkJSONWriter;
@@ -30,8 +32,9 @@
GrGLExtensions& operator=(const GrGLExtensions&);
void swap(GrGLExtensions* that) {
- fStrings.swap(&that->fStrings);
- SkTSwap(fInitialized, that->fInitialized);
+ using std::swap;
+ swap(fStrings, that->fStrings);
+ swap(fInitialized, that->fInitialized);
}
/**
diff --git a/include/private/SkMessageBus.h b/include/private/SkMessageBus.h
index 6ddf82c..19e9375 100644
--- a/include/private/SkMessageBus.h
+++ b/include/private/SkMessageBus.h
@@ -93,7 +93,7 @@
SkASSERT(messages);
messages->reset();
SkAutoMutexAcquire lock(fMessagesMutex);
- fMessages.swap(messages);
+ fMessages.swap(*messages);
}
// ----------------------- Implementation of SkMessageBus -----------------------
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index c9bee99..75cd001 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -298,18 +298,19 @@
/** Swaps the contents of this array with that array. Does a pointer swap if possible,
otherwise copies the T values. */
- void swap(SkTArray* that) {
- if (this == that) {
+ void swap(SkTArray& that) {
+ using std::swap;
+ if (this == &that) {
return;
}
- if (fOwnMemory && that->fOwnMemory) {
- SkTSwap(fItemArray, that->fItemArray);
- SkTSwap(fCount, that->fCount);
- SkTSwap(fAllocCount, that->fAllocCount);
+ if (fOwnMemory && that.fOwnMemory) {
+ swap(fItemArray, that.fItemArray);
+ swap(fCount, that.fCount);
+ swap(fAllocCount, that.fAllocCount);
} else {
// This could be more optimal...
- SkTArray copy(std::move(*that));
- *that = std::move(*this);
+ SkTArray copy(std::move(that));
+ that = std::move(*this);
*this = std::move(copy);
}
}
@@ -563,6 +564,10 @@
bool fReserved : 1;
};
+template <typename T, bool M> static inline void swap(SkTArray<T, M>& a, SkTArray<T, M>& b) {
+ a.swap(b);
+}
+
template<typename T, bool MEM_MOVE> constexpr int SkTArray<T, MEM_MOVE>::kMinHeapAllocCount;
/**
diff --git a/include/private/SkTDArray.h b/include/private/SkTDArray.h
index dd3212d..c6bd4ff 100644
--- a/include/private/SkTDArray.h
+++ b/include/private/SkTDArray.h
@@ -13,6 +13,8 @@
#include "SkTo.h"
#include "SkTypes.h"
+#include <utility>
+
template <typename T> class SkTDArray {
public:
SkTDArray() : fArray(nullptr), fReserve(0), fCount(0) {}
@@ -67,10 +69,11 @@
return !(a == b);
}
- void swap(SkTDArray<T>& other) {
- SkTSwap(fArray, other.fArray);
- SkTSwap(fReserve, other.fReserve);
- SkTSwap(fCount, other.fCount);
+ void swap(SkTDArray<T>& that) {
+ using std::swap;
+ swap(fArray, that.fArray);
+ swap(fReserve, that.fReserve);
+ swap(fCount, that.fCount);
}
bool isEmpty() const { return fCount == 0; }
@@ -371,4 +374,8 @@
}
};
+template <typename T> static inline void swap(SkTDArray<T>& a, SkTDArray<T>& b) {
+ a.swap(b);
+}
+
#endif
diff --git a/modules/skottie/src/SkottieAdapter.cpp b/modules/skottie/src/SkottieAdapter.cpp
index 2caf570..615390e 100644
--- a/modules/skottie/src/SkottieAdapter.cpp
+++ b/modules/skottie/src/SkottieAdapter.cpp
@@ -19,6 +19,7 @@
#include "SkottieValue.h"
#include <cmath>
+#include <utility>
namespace skottie {
@@ -151,7 +152,8 @@
stopT -= SkScalarFloorToScalar(stopT);
if (startT > stopT) {
- SkTSwap(startT, stopT);
+ using std::swap;
+ swap(startT, stopT);
mode = SkTrimPathEffect::Mode::kInverted;
}
} else {
diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp
index 2db72c9..ab9fb4b 100644
--- a/samplecode/SamplePathClip.cpp
+++ b/samplecode/SamplePathClip.cpp
@@ -20,6 +20,8 @@
#include "SkUtils.h"
#include "SkView.h"
+#include <utility>
+
class PathClipView : public SampleView {
public:
SkRect fOval;
@@ -81,7 +83,8 @@
}
if (p0.fY > p1.fY) {
- SkTSwap(p0, p1);
+ using std::swap;
+ swap(p0, p1);
}
// now we're monotonic in Y: p0 <= p1
if (p1.fY <= bounds.top() || p0.fY >= bounds.bottom()) {
@@ -101,7 +104,8 @@
// Now p0...p1 is strictly inside bounds vertically, so we just need to clip horizontally
if (p0.fX > p1.fX) {
- SkTSwap(p0, p1);
+ using std::swap;
+ swap(p0, p1);
}
// now we're left-to-right: p0 .. p1
diff --git a/src/android/SkAnimatedImage.cpp b/src/android/SkAnimatedImage.cpp
index 4885ada..6bbea6b 100644
--- a/src/android/SkAnimatedImage.cpp
+++ b/src/android/SkAnimatedImage.cpp
@@ -15,6 +15,8 @@
#include "SkPictureRecorder.h"
#include "SkPixelRef.h"
+#include <utility>
+
sk_sp<SkAnimatedImage> SkAnimatedImage::Make(std::unique_ptr<SkAndroidCodec> codec,
SkISize scaledSize, SkIRect cropRect, sk_sp<SkPicture> postProcess) {
if (!codec) {
@@ -114,7 +116,8 @@
}
memcpy(tmp.getPixels(), fBitmap.getPixels(), fBitmap.computeByteSize());
- SkTSwap(tmp, fBitmap);
+ using std::swap;
+ swap(tmp, fBitmap);
return true;
}
}
@@ -213,7 +216,8 @@
for (Frame* frame : { &fRestoreFrame, &fDecodingFrame }) {
if (frameToDecode == frame->fIndex) {
- SkTSwap(fDisplayFrame, *frame);
+ using std::swap;
+ swap(fDisplayFrame, *frame);
if (animationEnded) {
return this->finish();
}
@@ -236,7 +240,8 @@
// future.
if (fDecodingFrame.fIndex != SkCodec::kNone &&
!is_restore_previous(fDecodingFrame.fDisposalMethod)) {
- SkTSwap(fDecodingFrame, fRestoreFrame);
+ using std::swap;
+ swap(fDecodingFrame, fRestoreFrame);
}
}
} else {
@@ -262,7 +267,8 @@
options.fPriorFrame = fDecodingFrame.fIndex;
} else if (validPriorFrame(fRestoreFrame)) {
if (!is_restore_previous(frameInfo.fDisposalMethod)) {
- SkTSwap(fDecodingFrame, fRestoreFrame);
+ using std::swap;
+ swap(fDecodingFrame, fRestoreFrame);
} else if (!fRestoreFrame.copyTo(&fDecodingFrame)) {
SkCodecPrintf("Failed to restore frame\n");
return this->finish();
@@ -289,7 +295,8 @@
fDecodingFrame.fIndex = frameToDecode;
fDecodingFrame.fDisposalMethod = frameInfo.fDisposalMethod;
- SkTSwap(fDecodingFrame, fDisplayFrame);
+ using std::swap;
+ swap(fDecodingFrame, fDisplayFrame);
fDisplayFrame.fBitmap.notifyPixelsChanged();
if (animationEnded) {
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index 46c09e0..f0b341c 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -17,6 +17,8 @@
#include "SkTo.h"
#include "SkUtils.h"
+#include <utility>
+
class AutoAAClipValidate {
public:
AutoAAClipValidate(const SkAAClip& clip) : fClip(clip) {
@@ -690,8 +692,9 @@
AUTO_AACLIP_VALIDATE(*this);
other.validate();
- SkTSwap(fBounds, other.fBounds);
- SkTSwap(fRunHead, other.fRunHead);
+ using std::swap;
+ swap(fBounds, other.fBounds);
+ swap(fRunHead, other.fRunHead);
}
bool SkAAClip::set(const SkAAClip& src) {
@@ -1700,7 +1703,8 @@
const SkAAClip* clipB = &clipBOrig;
if (SkRegion::kReverseDifference_Op == op) {
- SkTSwap(clipA, clipB);
+ using std::swap;
+ swap(clipA, clipB);
op = SkRegion::kDifference_Op;
}
diff --git a/src/core/SkAnalyticEdge.cpp b/src/core/SkAnalyticEdge.cpp
index 60c956a..9226aca 100644
--- a/src/core/SkAnalyticEdge.cpp
+++ b/src/core/SkAnalyticEdge.cpp
@@ -11,6 +11,8 @@
#include "SkMathPriv.h"
#include "SkTo.h"
+#include <utility>
+
// This will become a bottleneck for small ovals rendering if we call SkFixedDiv twice here.
// Therefore, we'll let the outter function compute the slope once and send in the value.
// Moreover, we'll compute fDY by quickly lookup the inverse table (if possible).
@@ -24,8 +26,9 @@
// We don't chop at y extrema for cubics so the y is not guaranteed to be increasing for them.
// In that case, we have to swap x/y and negate the winding.
if (y0 > y1) {
- SkTSwap(x0, x1);
- SkTSwap(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
fWinding = -fWinding;
}
diff --git a/src/core/SkAnalyticEdge.h b/src/core/SkAnalyticEdge.h
index b18ccac..a1d3da3 100644
--- a/src/core/SkAnalyticEdge.h
+++ b/src/core/SkAnalyticEdge.h
@@ -11,6 +11,8 @@
#include "SkEdge.h"
#include "SkTo.h"
+#include <utility>
+
struct SkAnalyticEdge {
// Similar to SkEdge, the conic edges will be converted to quadratic edges
enum Type {
@@ -156,8 +158,9 @@
int winding = 1;
if (y0 > y1) {
- SkTSwap(x0, x1);
- SkTSwap(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
winding = -1;
}
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 8c70d54..e942a4c 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -29,7 +29,8 @@
#include "SkWriteBuffer.h"
#include "SkWritePixelsRec.h"
-#include <string.h>
+#include <cstring>
+#include <utility>
static bool reset_return_false(SkBitmap* bm) {
bm->reset();
@@ -82,7 +83,8 @@
}
void SkBitmap::swap(SkBitmap& other) {
- SkTSwap(*this, other);
+ using std::swap;
+ swap(*this, other);
SkDEBUGCODE(this->validate();)
}
diff --git a/src/core/SkCubicClipper.cpp b/src/core/SkCubicClipper.cpp
index b5b7dce..e4ec79e 100644
--- a/src/core/SkCubicClipper.cpp
+++ b/src/core/SkCubicClipper.cpp
@@ -9,6 +9,8 @@
#include "SkCubicClipper.h"
#include "SkGeometry.h"
+#include <utility>
+
SkCubicClipper::SkCubicClipper() {
fClip.setEmpty();
}
@@ -146,8 +148,9 @@
}
if (reverse) {
- SkTSwap<SkPoint>(dst[0], dst[3]);
- SkTSwap<SkPoint>(dst[1], dst[2]);
+ using std::swap;
+ swap(dst[0], dst[3]);
+ swap(dst[1], dst[2]);
}
return true;
}
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 9038178..fe99405 100644
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -10,6 +10,8 @@
#include "SkPointPriv.h"
#include "SkTemplates.h"
+#include <utility>
+
struct DFData {
float fAlpha; // alpha value of source texel
float fDistSq; // distance squared to nearest (so far) edge texel
@@ -120,7 +122,8 @@
dx = SkScalarAbs(dx);
dy = SkScalarAbs(dy);
if (dx < dy) {
- SkTSwap(dx, dy);
+ using std::swap;
+ swap(dx, dy);
}
// a1 = 0.5*dy/dx is the smaller fractional area chopped off by the edge
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 79712a2..98cfd87 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -39,6 +39,8 @@
#include "SkTo.h"
#include "SkUtils.h"
+#include <utility>
+
static SkPaint make_paint_with_image(
const SkPaint& origPaint, const SkBitmap& bitmap, SkMatrix* matrix = nullptr) {
SkPaint paint(origPaint);
@@ -870,7 +872,8 @@
SkScalar x = SkScalarAbs(vec.fX);
SkScalar y = SkScalarAbs(vec.fY);
if (x < y) {
- SkTSwap(x, y);
+ using std::swap;
+ swap(x, y);
}
return x + SkScalarHalf(y);
}
diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp
index 0a19e53..905e17f 100644
--- a/src/core/SkEdge.cpp
+++ b/src/core/SkEdge.cpp
@@ -11,6 +11,8 @@
#include "SkMathPriv.h"
#include "SkTo.h"
+#include <utility>
+
/*
In setLine, setQuadratic, setCubic, the first thing we do is to convert
the points into FDot6. This is modulated by the shift parameter, which
@@ -53,8 +55,9 @@
int winding = 1;
if (y0 > y1) {
- SkTSwap(x0, x1);
- SkTSwap(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
winding = -1;
}
@@ -204,8 +207,9 @@
int winding = 1;
if (y0 > y2)
{
- SkTSwap(x0, x2);
- SkTSwap(y0, y2);
+ using std::swap;
+ swap(x0, x2);
+ swap(y0, y2);
winding = -1;
}
SkASSERT(y0 <= y1 && y1 <= y2);
@@ -377,10 +381,11 @@
int winding = 1;
if (sortY && y0 > y3)
{
- SkTSwap(x0, x3);
- SkTSwap(x1, x2);
- SkTSwap(y0, y3);
- SkTSwap(y1, y2);
+ using std::swap;
+ swap(x0, x3);
+ swap(x1, x2);
+ swap(y0, y3);
+ swap(y1, y2);
winding = -1;
}
diff --git a/src/core/SkEdge.h b/src/core/SkEdge.h
index 7fc6851..cc35baa 100644
--- a/src/core/SkEdge.h
+++ b/src/core/SkEdge.h
@@ -13,6 +13,8 @@
#include "SkRect.h"
#include "SkTo.h"
+#include <utility>
+
// This correctly favors the lower-pixel when y0 is on a 1/2 pixel boundary
#define SkEdge_Compute_DY(top, y0) (SkLeftShift(top, 6) + 32 - (y0))
@@ -106,8 +108,9 @@
int winding = 1;
if (y0 > y1) {
- SkTSwap(x0, x1);
- SkTSwap(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
winding = -1;
}
diff --git a/src/core/SkEdgeClipper.cpp b/src/core/SkEdgeClipper.cpp
index b2b95fc..cbb0327 100644
--- a/src/core/SkEdgeClipper.cpp
+++ b/src/core/SkEdgeClipper.cpp
@@ -10,6 +10,8 @@
#include "SkLineClipper.h"
#include "SkMacros.h"
+#include <utility>
+
static bool quick_reject(const SkRect& bounds, const SkRect& clip) {
return bounds.fTop >= clip.fBottom || bounds.fBottom <= clip.fTop;
}
@@ -152,7 +154,8 @@
chop_quad_in_Y(pts, clip);
if (pts[0].fX > pts[2].fX) {
- SkTSwap<SkPoint>(pts[0], pts[2]);
+ using std::swap;
+ swap(pts[0], pts[2]);
reverse = !reverse;
}
SkASSERT(pts[0].fX <= pts[1].fX);
@@ -342,8 +345,9 @@
chop_cubic_in_Y(pts, clip);
if (pts[0].fX > pts[3].fX) {
- SkTSwap<SkPoint>(pts[0], pts[3]);
- SkTSwap<SkPoint>(pts[1], pts[2]);
+ using std::swap;
+ swap(pts[0], pts[3]);
+ swap(pts[1], pts[2]);
reverse = !reverse;
}
@@ -453,12 +457,12 @@
fCurrPoint += 2;
}
-void SkEdgeClipper::appendVLine(SkScalar x, SkScalar y0, SkScalar y1,
- bool reverse) {
+void SkEdgeClipper::appendVLine(SkScalar x, SkScalar y0, SkScalar y1, bool reverse) {
*fCurrVerb++ = SkPath::kLine_Verb;
if (reverse) {
- SkTSwap<SkScalar>(y0, y1);
+ using std::swap;
+ swap(y0, y1);
}
fCurrPoint[0].set(x, y0);
fCurrPoint[1].set(x, y1);
diff --git a/src/core/SkGeometry.cpp b/src/core/SkGeometry.cpp
index 249b62e..a534509 100644
--- a/src/core/SkGeometry.cpp
+++ b/src/core/SkGeometry.cpp
@@ -11,6 +11,8 @@
#include "SkPoint3.h"
#include "SkPointPriv.h"
+#include <utility>
+
static SkVector to_vector(const Sk2s& x) {
SkVector vector;
x.store(&vector);
@@ -89,10 +91,12 @@
r += valid_unit_divide(Q, A, r);
r += valid_unit_divide(C, Q, r);
if (r - roots == 2) {
- if (roots[0] > roots[1])
- SkTSwap<SkScalar>(roots[0], roots[1]);
- else if (roots[0] == roots[1]) // nearly-equal?
+ if (roots[0] > roots[1]) {
+ using std::swap;
+ swap(roots[0], roots[1]);
+ } else if (roots[0] == roots[1]) { // nearly-equal?
r -= 1; // skip the double root
+ }
}
return (int)(r - roots);
}
@@ -567,8 +571,9 @@
// Ensure t[0]/s[0] <= t[1]/s[1] (s[1] is negative from above).
if (copysign(s[1], s[0]) * t[0] > -fabs(s[0]) * t[1]) {
- std::swap(t[0], t[1]);
- std::swap(s[0], s[1]);
+ using std::swap;
+ swap(t[0], t[1]);
+ swap(s[0], s[1]);
}
}
diff --git a/src/core/SkLineClipper.cpp b/src/core/SkLineClipper.cpp
index 73a1819..d7c75c3 100644
--- a/src/core/SkLineClipper.cpp
+++ b/src/core/SkLineClipper.cpp
@@ -8,9 +8,12 @@
#include "SkLineClipper.h"
#include "SkTo.h"
+#include <utility>
+
template <typename T> T pin_unsorted(T value, T limit0, T limit1) {
if (limit1 < limit0) {
- SkTSwap(limit0, limit1);
+ using std::swap;
+ swap(limit0, limit1);
}
// now the limits are sorted
SkASSERT(limit0 <= limit1);
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index cb4b792..3d50659 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -16,7 +16,9 @@
#include "SkRSXform.h"
#include "SkString.h"
#include "SkTo.h"
-#include <stddef.h>
+
+#include <cstddef>
+#include <utility>
static void normalize_perspective(SkScalar mat[9]) {
// If it was interesting to never store the last element, we could divide all 8 other
@@ -1488,7 +1490,8 @@
results[0] = SkScalarAbs(m[SkMatrix::kMScaleX]);
results[1] = SkScalarAbs(m[SkMatrix::kMScaleY]);
if (results[0] > results[1]) {
- SkTSwap(results[0], results[1]);
+ using std::swap;
+ swap(results[0], results[1]);
}
}
return true;
@@ -1518,7 +1521,8 @@
results[0] = a;
results[1] = c;
if (results[0] > results[1]) {
- SkTSwap(results[0], results[1]);
+ using std::swap;
+ swap(results[0], results[1]);
}
}
} else {
diff --git a/src/core/SkMatrix44.cpp b/src/core/SkMatrix44.cpp
index bc3b35f..a79b703 100644
--- a/src/core/SkMatrix44.cpp
+++ b/src/core/SkMatrix44.cpp
@@ -6,6 +6,7 @@
*/
#include "SkMatrix44.h"
+#include <utility>
static inline bool eq4(const SkMScalar* SK_RESTRICT a,
const SkMScalar* SK_RESTRICT b) {
@@ -692,12 +693,13 @@
///////////////////////////////////////////////////////////////////////////////
void SkMatrix44::transpose() {
- SkTSwap(fMat[0][1], fMat[1][0]);
- SkTSwap(fMat[0][2], fMat[2][0]);
- SkTSwap(fMat[0][3], fMat[3][0]);
- SkTSwap(fMat[1][2], fMat[2][1]);
- SkTSwap(fMat[1][3], fMat[3][1]);
- SkTSwap(fMat[2][3], fMat[3][2]);
+ using std::swap;
+ swap(fMat[0][1], fMat[1][0]);
+ swap(fMat[0][2], fMat[2][0]);
+ swap(fMat[0][3], fMat[3][0]);
+ swap(fMat[1][2], fMat[2][1]);
+ swap(fMat[1][3], fMat[3][1]);
+ swap(fMat[2][3], fMat[3][2]);
if (!this->isTriviallyIdentity()) {
this->dirtyTypeMask();
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index e38d736..99ac492 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -22,6 +22,7 @@
#include "SkTo.h"
#include <cmath>
+#include <utility>
static float poly_eval(float A, float B, float C, float t) {
return (A * t + B) * t + C;
@@ -201,10 +202,11 @@
void SkPath::swap(SkPath& that) {
if (this != &that) {
+ using std::swap;
fPathRef.swap(that.fPathRef);
- SkTSwap(fLastMoveToIndex, that.fLastMoveToIndex);
- SkTSwap(fFillType, that.fFillType);
- SkTSwap(fIsVolatile, that.fIsVolatile);
+ swap(fLastMoveToIndex, that.fLastMoveToIndex);
+ swap(fFillType, that.fFillType);
+ swap(fIsVolatile, that.fIsVolatile);
// Non-atomic swaps of atomic values.
Convexity c = fConvexity.load();
@@ -2797,7 +2799,8 @@
int dir = 1;
if (y0 > y3) {
- SkTSwap(y0, y3);
+ using std::swap;
+ swap(y0, y3);
dir = -1;
}
if (y < y0 || y > y3) {
@@ -2871,7 +2874,8 @@
int dir = 1;
if (y0 > y2) {
- SkTSwap(y0, y2);
+ using std::swap;
+ swap(y0, y2);
dir = -1;
}
if (y < y0 || y > y2) {
@@ -2945,7 +2949,8 @@
int dir = 1;
if (y0 > y2) {
- SkTSwap(y0, y2);
+ using std::swap;
+ swap(y0, y2);
dir = -1;
}
if (y < y0 || y > y2) {
@@ -3018,7 +3023,8 @@
int dir = 1;
if (y0 > y1) {
- SkTSwap(y0, y1);
+ using std::swap;
+ swap(y0, y1);
dir = -1;
}
if (y < y0 || y > y1) {
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index aad9e34..6eaf679 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -26,6 +26,8 @@
#include "SkUnPreMultiply.h"
#include "SkUtils.h"
+#include <utility>
+
/////////////////////////////////////////////////////////////////////////////////////////////////
void SkPixmap::reset() {
@@ -499,7 +501,8 @@
SkMatrix s;
s.setAll(0, 1, 0, 1, 0, 0, 0, 0, 1);
m.postConcat(s);
- SkTSwap(W, H);
+ using std::swap;
+ swap(W, H);
}
if (flags & SkPixmapPriv::kMirrorX) {
m.postScale(-1, 1);
@@ -526,7 +529,8 @@
int w = src.width();
int h = src.height();
if (flags & kSwapXY) {
- SkTSwap(w, h);
+ using std::swap;
+ swap(w, h);
}
if (dst.width() != w || dst.height() != h) {
return false;
diff --git a/src/core/SkQuadClipper.cpp b/src/core/SkQuadClipper.cpp
index fcde929..baa7fee 100644
--- a/src/core/SkQuadClipper.cpp
+++ b/src/core/SkQuadClipper.cpp
@@ -8,6 +8,8 @@
#include "SkQuadClipper.h"
#include "SkGeometry.h"
+#include <utility>
+
SkQuadClipper::SkQuadClipper() {
fClip.setEmpty();
}
@@ -108,7 +110,8 @@
}
if (reverse) {
- SkTSwap<SkPoint>(dst[0], dst[2]);
+ using std::swap;
+ swap(dst[0], dst[2]);
}
return true;
}
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 46e83ae..01e76d5 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include <cmath>
#include "SkRRectPriv.h"
#include "SkScopeExit.h"
#include "SkBuffer.h"
@@ -13,6 +12,9 @@
#include "SkMatrix.h"
#include "SkScaleToSides.h"
+#include <cmath>
+#include <utility>
+
///////////////////////////////////////////////////////////////////////////////
void SkRRect::setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
@@ -430,20 +432,21 @@
}
// Now swap as necessary.
+ using std::swap;
if (flipX) {
if (flipY) {
// Swap with opposite corners
- SkTSwap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerRight_Corner]);
- SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerLeft_Corner]);
+ swap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerRight_Corner]);
+ swap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerLeft_Corner]);
} else {
// Only swap in x
- SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kUpperLeft_Corner]);
- SkTSwap(dst->fRadii[kLowerRight_Corner], dst->fRadii[kLowerLeft_Corner]);
+ swap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kUpperLeft_Corner]);
+ swap(dst->fRadii[kLowerRight_Corner], dst->fRadii[kLowerLeft_Corner]);
}
} else if (flipY) {
// Only swap in y
- SkTSwap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerLeft_Corner]);
- SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerRight_Corner]);
+ swap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerLeft_Corner]);
+ swap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerRight_Corner]);
}
if (!AreRectAndRadiiValid(dst->fRect, dst->fRadii)) {
diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp
index 3d48f36..86ef4f8 100644
--- a/src/core/SkRegion.cpp
+++ b/src/core/SkRegion.cpp
@@ -15,6 +15,8 @@
#include "SkTo.h"
#include "SkUtils.h"
+#include <utility>
+
/* Region Layout
*
* TOP
@@ -161,8 +163,9 @@
}
void SkRegion::swap(SkRegion& other) {
- SkTSwap<SkIRect>(fBounds, other.fBounds);
- SkTSwap<RunHead*>(fRunHead, other.fRunHead);
+ using std::swap;
+ swap(fBounds, other.fBounds);
+ swap(fRunHead, other.fRunHead);
}
int SkRegion::computeRegionComplexity() const {
@@ -1046,7 +1049,8 @@
// collaps difference and reverse-difference into just difference
if (kReverseDifference_Op == op) {
- SkTSwap<const SkRegion*>(rgna, rgnb);
+ using std::swap;
+ swap(rgna, rgnb);
op = kDifference_Op;
}
diff --git a/src/core/SkScaleToSides.h b/src/core/SkScaleToSides.h
index c700891..61bff63 100644
--- a/src/core/SkScaleToSides.h
+++ b/src/core/SkScaleToSides.h
@@ -8,10 +8,12 @@
#ifndef SkScaleToSides_DEFINED
#define SkScaleToSides_DEFINED
-#include <cmath>
#include "SkScalar.h"
#include "SkTypes.h"
+#include <cmath>
+#include <utility>
+
class SkScaleToSides {
public:
// This code assumes that a and b fit in a float, and therefore the resulting smaller value
@@ -30,7 +32,8 @@
// Force minRadius to be the smaller of the two.
if (*minRadius > *maxRadius) {
- SkTSwap(minRadius, maxRadius);
+ using std::swap;
+ swap(minRadius, maxRadius);
}
// newMinRadius must be float in order to give the actual value of the radius.
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp
index bd649e7..9dbb271 100644
--- a/src/core/SkScan_AAAPath.cpp
+++ b/src/core/SkScan_AAAPath.cpp
@@ -23,6 +23,8 @@
#include "SkTo.h"
#include "SkUtils.h"
+#include <utility>
+
///////////////////////////////////////////////////////////////////////////////
/*
@@ -581,8 +583,8 @@
// Suppose that line (l1, y)-(r1, y+1) intersects with (l2, y)-(r2, y+1),
// approximate (very coarsely) the x coordinate of the intersection.
static inline SkFixed approximateIntersection(SkFixed l1, SkFixed r1, SkFixed l2, SkFixed r2) {
- if (l1 > r1) { SkTSwap(l1, r1); }
- if (l2 > r2) { SkTSwap(l2, r2); }
+ if (l1 > r1) { using std::swap; swap(l1, r1); }
+ if (l2 > r2) { using std::swap; swap(l2, r2); }
return (SkTMax(l1, l2) + SkTMin(r1, r2)) >> 1;
}
@@ -830,8 +832,8 @@
// to exclude the area that's not covered by the path.
// Swapping (ul, ll) or (ur, lr) won't affect that exclusion
// so we'll do that for simplicity.
- if (ul > ll) { SkTSwap(ul, ll); }
- if (ur > lr) { SkTSwap(ur, lr); }
+ if (ul > ll) { using std::swap; swap(ul, ll); }
+ if (ur > lr) { using std::swap; swap(ur, lr); }
SkFixed joinLeft = SkFixedCeilToFixed(ll);
SkFixed joinRite = SkFixedFloorToFixed(ur);
@@ -978,7 +980,8 @@
}
// Ensure that currE is the next left edge and nextCurrE is the next right edge. Swap if not.
if (nextCurrE->fUpperX < currE->fUpperX) {
- SkTSwap(currE, nextCurrE);
+ using std::swap;
+ swap(currE, nextCurrE);
}
return isSmoothEnough(leftE, currE, stop_y) && isSmoothEnough(riteE, nextCurrE, stop_y);
}
@@ -1037,7 +1040,8 @@
if (leftE->fX > riteE->fX || (leftE->fX == riteE->fX &&
leftE->fDX > riteE->fDX)) {
- SkTSwap(leftE, riteE);
+ using std::swap;
+ swap(leftE, riteE);
}
SkFixed local_bot_fixed = SkMin32(leftE->fLowerY, riteE->fLowerY);
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp
index 37faed4..ade4818 100644
--- a/src/core/SkScan_Antihair.cpp
+++ b/src/core/SkScan_Antihair.cpp
@@ -14,6 +14,8 @@
#include "SkRasterClip.h"
#include "SkTo.h"
+#include <utility>
+
/* Our attempt to compute the worst case "bounds" for the horizontal and
vertical cases has some numerical bug in it, and we sometimes undervalue
our extends. The bug is that when this happens, we will set the clip to
@@ -344,8 +346,9 @@
if (SkAbs32(x1 - x0) > SkAbs32(y1 - y0)) { // mostly horizontal
if (x0 > x1) { // we want to go left-to-right
- SkTSwap<SkFDot6>(x0, x1);
- SkTSwap<SkFDot6>(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
}
istart = SkFDot6Floor(x0);
@@ -417,8 +420,9 @@
}
} else { // mostly vertical
if (y0 > y1) { // we want to go top-to-bottom
- SkTSwap<SkFDot6>(x0, x1);
- SkTSwap<SkFDot6>(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
}
istart = SkFDot6Floor(y0);
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index 815130d..d9c0408 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -13,6 +13,8 @@
#include "SkFDot6.h"
#include "SkLineClipper.h"
+#include <utility>
+
static void horiline(int x, int stopx, SkFixed fy, SkFixed dy,
SkBlitter* blitter) {
SkASSERT(x < stopx);
@@ -110,8 +112,9 @@
if (SkAbs32(dx) > SkAbs32(dy)) { // mostly horizontal
if (x0 > x1) { // we want to go left-to-right
- SkTSwap<SkFDot6>(x0, x1);
- SkTSwap<SkFDot6>(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
}
int ix0 = SkFDot6Round(x0);
int ix1 = SkFDot6Round(x1);
@@ -125,8 +128,9 @@
horiline(ix0, ix1, startY, slope, blitter);
} else { // mostly vertical
if (y0 > y1) { // we want to go top-to-bottom
- SkTSwap<SkFDot6>(x0, x1);
- SkTSwap<SkFDot6>(y0, y1);
+ using std::swap;
+ swap(x0, x1);
+ swap(y0, y1);
}
int iy0 = SkFDot6Round(y0);
int iy1 = SkFDot6Round(y1);
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index c26a224..e5dd774 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -20,6 +20,8 @@
#include "SkTSort.h"
#include "SkTemplates.h"
+#include <utility>
+
#define kEDGE_HEAD_Y SK_MinS32
#define kEDGE_TAIL_Y SK_MaxS32
@@ -233,7 +235,8 @@
if (leftE->fX > riteE->fX || (leftE->fX == riteE->fX &&
leftE->fDX > riteE->fDX)) {
- SkTSwap(leftE, riteE);
+ using std::swap;
+ swap(leftE, riteE);
}
int local_bot = SkMin32(leftE->fLastY, riteE->fLastY);
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 23c85f9..65dae1b 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -12,9 +12,11 @@
#include "SkTo.h"
#include "SkUtils.h"
+#include <cstdarg>
#include <cstdio>
#include <new>
-#include <stdarg.h>
+#include <utility>
+
// number of bytes (on the stack) to receive the printf result
static const size_t kBufferSize = 1024;
@@ -574,7 +576,8 @@
this->validate();
other.validate();
- SkTSwap(fRec, other.fRec);
+ using std::swap;
+ swap(fRec, other.fRec);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index bb216d1..b880c15 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -13,6 +13,8 @@
#include "SkPointPriv.h"
#include "SkTo.h"
+#include <utility>
+
enum {
kTangent_RecursiveLimit,
kCubic_RecursiveLimit,
@@ -983,7 +985,8 @@
SkScalar smallerLen = SkPointPriv::LengthSqd(smaller);
SkScalar largerLen = SkPointPriv::LengthSqd(larger);
if (smallerLen > largerLen) {
- SkTSwap(smaller, larger);
+ using std::swap;
+ swap(smaller, larger);
largerLen = smallerLen;
}
if (!smaller.setLength(largerLen)) {
diff --git a/src/core/SkStrokerPriv.cpp b/src/core/SkStrokerPriv.cpp
index be7b1f5..87bc172 100644
--- a/src/core/SkStrokerPriv.cpp
+++ b/src/core/SkStrokerPriv.cpp
@@ -10,6 +10,8 @@
#include "SkPath.h"
#include "SkPointPriv.h"
+#include <utility>
+
static void ButtCapper(SkPath* path, const SkPoint& pivot, const SkVector& normal,
const SkPoint& stop, SkPath*) {
path->lineTo(stop.fX, stop.fY);
@@ -86,7 +88,8 @@
afterUnitNormal.scale(radius, &after);
if (!is_clockwise(beforeUnitNormal, afterUnitNormal)) {
- SkTSwap<SkPath*>(outer, inner);
+ using std::swap;
+ swap(outer, inner);
after.negate();
}
@@ -108,7 +111,8 @@
SkRotationDirection dir = kCW_SkRotationDirection;
if (!is_clockwise(before, after)) {
- SkTSwap<SkPath*>(outer, inner);
+ using std::swap;
+ swap(outer, inner);
before.negate();
after.negate();
dir = kCCW_SkRotationDirection;
@@ -153,7 +157,8 @@
ccw = !is_clockwise(before, after);
if (ccw) {
- SkTSwap<SkPath*>(outer, inner);
+ using std::swap;
+ swap(outer, inner);
before.negate();
after.negate();
}
diff --git a/src/core/SkTDPQueue.h b/src/core/SkTDPQueue.h
index 5f6fd3b..5dca491 100644
--- a/src/core/SkTDPQueue.h
+++ b/src/core/SkTDPQueue.h
@@ -11,6 +11,8 @@
#include "SkTDArray.h"
#include "SkTSort.h"
+#include <utility>
+
/**
* This class implements a priority queue. T is the type of the elements in the queue. LESS is a
* function that compares two Ts and returns true if the first is higher priority than the second.
@@ -138,7 +140,8 @@
}
int p = ParentOf(index);
if (LESS(fArray[index], fArray[p])) {
- SkTSwap(fArray[index], fArray[p]);
+ using std::swap;
+ swap(fArray[index], fArray[p]);
this->setIndex(index);
index = p;
percolated = true;
@@ -164,7 +167,8 @@
if (child + 1 >= fArray.count()) {
// We only have a left child.
if (LESS(fArray[child], fArray[index])) {
- SkTSwap(fArray[child], fArray[index]);
+ using std::swap;
+ swap(fArray[child], fArray[index]);
this->setIndex(child);
this->setIndex(index);
return;
@@ -176,7 +180,8 @@
// Check if we need to swap.
if (LESS(fArray[child], fArray[index])) {
- SkTSwap(fArray[child], fArray[index]);
+ using std::swap;
+ swap(fArray[child], fArray[index]);
this->setIndex(index);
index = child;
} else {
diff --git a/src/core/SkTSort.h b/src/core/SkTSort.h
index a97baf9..87d99d5 100644
--- a/src/core/SkTSort.h
+++ b/src/core/SkTSort.h
@@ -12,6 +12,8 @@
#include "SkTo.h"
#include "SkTypes.h"
+#include <utility>
+
/* A comparison functor which performs the comparison 'a < b'. */
template <typename T> struct SkTCompareLT {
bool operator()(const T a, const T b) const { return a < b; }
@@ -92,7 +94,7 @@
}
/** Sorts the array of size count using comparator lessThan using a Heap Sort algorithm. Be sure to
- * specialize SkTSwap if T has an efficient swap operation.
+ * specialize swap if T has an efficient swap operation.
*
* @param array the array to be sorted.
* @param count the number of elements in the array.
@@ -104,7 +106,8 @@
}
for (size_t i = count - 1; i > 0; --i) {
- SkTSwap<T>(array[0], array[i]);
+ using std::swap;
+ swap(array[0], array[i]);
SkTHeapSort_SiftUp(array, 1, i, lessThan);
}
}
@@ -136,17 +139,18 @@
template <typename T, typename C>
static T* SkTQSort_Partition(T* left, T* right, T* pivot, C lessThan) {
+ using std::swap;
T pivotValue = *pivot;
- SkTSwap(*pivot, *right);
+ swap(*pivot, *right);
T* newPivot = left;
while (left < right) {
if (lessThan(*left, pivotValue)) {
- SkTSwap(*left, *newPivot);
+ swap(*left, *newPivot);
newPivot += 1;
}
left += 1;
}
- SkTSwap(*newPivot, *right);
+ swap(*newPivot, *right);
return newPivot;
}
@@ -184,7 +188,7 @@
}
/** Sorts the region from left to right using comparator lessThan using a Quick Sort algorithm. Be
- * sure to specialize SkTSwap if T has an efficient swap operation.
+ * sure to specialize swap if T has an efficient swap operation.
*
* @param left the beginning of the region to be sorted.
* @param right the end of the region to be sorted (inclusive).
diff --git a/src/core/SkTTopoSort.h b/src/core/SkTTopoSort.h
index 722707d..01dee53 100644
--- a/src/core/SkTTopoSort.h
+++ b/src/core/SkTTopoSort.h
@@ -102,7 +102,7 @@
}
SkASSERT(graph->count() == result.count());
- graph->swap(&result);
+ graph->swap(result);
#ifdef SK_DEBUG
SkTTopoSort_CleanExit<T, Traits>(*graph);
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index 8301592..aa3803a 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -15,6 +15,8 @@
#include "SkTo.h"
#include "SkWriteBuffer.h"
+#include <utility>
+
SkDashImpl::SkDashImpl(const SkScalar intervals[], int count, SkScalar phase)
: fPhase(0)
, fInitialDashLength(-1)
@@ -93,7 +95,8 @@
SkScalar maxX = pts[1].fX;
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
SkASSERT(minX < maxX);
@@ -114,7 +117,8 @@
SkASSERT(maxX > minX);
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
pts[0].fX = minX;
pts[1].fX = maxX;
@@ -124,7 +128,8 @@
SkScalar maxY = pts[1].fY;
if (dy < 0) {
- SkTSwap(minY, maxY);
+ using std::swap;
+ swap(minY, maxY);
}
SkASSERT(minY < maxY);
@@ -145,7 +150,8 @@
SkASSERT(maxY > minY);
if (dy < 0) {
- SkTSwap(minY, maxY);
+ using std::swap;
+ swap(minY, maxY);
}
pts[0].fY = minY;
pts[1].fY = maxY;
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp
index d74b144..a0a395b 100644
--- a/src/gpu/GrShape.cpp
+++ b/src/gpu/GrShape.cpp
@@ -7,6 +7,8 @@
#include "GrShape.h"
+#include <utility>
+
GrShape& GrShape::operator=(const GrShape& that) {
fStyle = that.fStyle;
this->changeType(that.fType, Type::kPath == that.fType ? &that.path() : nullptr);
@@ -674,7 +676,8 @@
// the point order.
SkPoint* pts = fLineData.fPts;
if (pts[1].fY < pts[0].fY || (pts[1].fY == pts[0].fY && pts[1].fX < pts[0].fX)) {
- SkTSwap(pts[0], pts[1]);
+ using std::swap;
+ swap(pts[0], pts[1]);
}
}
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 6490c5b..2dd82a0 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -17,7 +17,8 @@
#include "SkTDPQueue.h"
#include <algorithm>
-#include <stdio.h>
+#include <cstdio>
+#include <utility>
/*
* There are six stages to the basic algorithm:
@@ -1682,7 +1683,8 @@
return;
}
if (c.sweep_lt(edge->fBottom->fPoint, edge->fTop->fPoint)) {
- SkTSwap(edge->fTop, edge->fBottom);
+ using std::swap;
+ swap(edge->fTop, edge->fBottom);
edge->fWinding *= -1;
}
edge->recompute();
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 81e8da1..e219702 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -19,6 +19,8 @@
#include "glsl/GrGLSLShaderBuilder.h"
#include "glsl/GrGLSLUniformHandler.h"
+#include <utility>
+
static bool can_ignore_rect(GrTextureProxy* proxy, const SkRect& domain) {
if (GrProxyProvider::IsFunctionallyExact(proxy)) {
const SkIRect kFullRect = SkIRect::MakeWH(proxy->width(), proxy->height());
@@ -184,7 +186,8 @@
values[3] = 1.0f - values[3];
// The top and bottom were just flipped, so correct the ordering
// of elements so that values = (l, t, r, b).
- SkTSwap(values[1], values[3]);
+ using std::swap;
+ swap(values[1], values[3]);
}
if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(float))) {
pdman.set4fv(fDomainUni, 1, values);
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 747fa5f..7b0e462 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -25,6 +25,8 @@
#include "ops/GrMeshDrawOp.h"
#include "ops/GrSimpleMeshDrawOpHelper.h"
+#include <utility>
+
namespace {
struct EllipseVertex {
@@ -973,7 +975,8 @@
// If the matrix included scale (on one axis) we need to swap our start and end points
if ((viewMatrix.getScaleX() < 0) != (viewMatrix.getScaleY() < 0)) {
- SkTSwap(startPoint, stopPoint);
+ using std::swap;
+ swap(startPoint, stopPoint);
}
fRoundCaps = style.strokeRec().getWidth() > 0 &&
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index d0eb876..1149855 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -39,6 +39,8 @@
#include "vk/GrVkInterface.h"
#include "vk/GrVkTypes.h"
+#include <utility>
+
#if !defined(SK_BUILD_FOR_WIN)
#include <unistd.h>
#endif // !defined(SK_BUILD_FOR_WIN)
@@ -1628,7 +1630,8 @@
// If we have different origins, we need to flip the top and bottom of the dst rect so that we
// get the correct origintation of the copied data.
if (srcOrigin != dstOrigin) {
- SkTSwap(dstRect.fTop, dstRect.fBottom);
+ using std::swap;
+ swap(dstRect.fTop, dstRect.fBottom);
}
VkImageBlit blitRegion;
diff --git a/src/opts/SkSwizzler_opts.h b/src/opts/SkSwizzler_opts.h
index 699b11c..892dc31 100644
--- a/src/opts/SkSwizzler_opts.h
+++ b/src/opts/SkSwizzler_opts.h
@@ -10,6 +10,8 @@
#include "SkColorData.h"
+#include <utility>
+
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
#include <immintrin.h>
#elif defined(SK_ARM_HAS_NEON)
@@ -244,13 +246,14 @@
}
/*not static*/ inline void RGBA_to_BGRA(uint32_t* dst, const void* vsrc, int count) {
+ using std::swap;
auto src = (const uint32_t*)vsrc;
while (count >= 16) {
// Load 16 pixels.
uint8x16x4_t rgba = vld4q_u8((const uint8_t*) src);
// Swap r and b.
- SkTSwap(rgba.val[0], rgba.val[2]);
+ swap(rgba.val[0], rgba.val[2]);
// Store 16 pixels.
vst4q_u8((uint8_t*) dst, rgba);
@@ -264,7 +267,7 @@
uint8x8x4_t rgba = vld4_u8((const uint8_t*) src);
// Swap r and b.
- SkTSwap(rgba.val[0], rgba.val[2]);
+ swap(rgba.val[0], rgba.val[2]);
// Store 8 pixels.
vst4_u8((uint8_t*) dst, rgba);
diff --git a/src/pathops/SkAddIntersections.cpp b/src/pathops/SkAddIntersections.cpp
index f772cc2..1749ca9 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 @@
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 faca087..43c37de 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 @@
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 @@
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 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 */
diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp
index 451a155..df70034 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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
}
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 346db4b..a88f413 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 @@
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 @@
}
swapBack:
if (swapped) {
- SkTSwap(priorPtT, ptT);
+ using std::swap;
+ swap(priorPtT, ptT);
}
}
} while ((spanBase = spanBase->final() ? nullptr : spanBase->upCast()->next()));
@@ -1531,15 +1535,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->debugAddOrOverlap(log, coinSeg, oppSeg, coinTs, coinTe, oppTs, oppTe, &added), false) {
@@ -1743,11 +1749,11 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 4dd6879..09c6f0e 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 @@
return nullptr;
}
if (segment->operand()) {
- SkTSwap<int>(sumMiWinding, sumSuWinding);
+ using std::swap;
+ swap(sumMiWinding, sumSuWinding);
}
}
SkOpSegment* first = nullptr;
@@ -284,7 +287,8 @@
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 b052df9..379ae34 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 @@
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 @@
}
#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 @@
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 @@
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 48993a6..12cb112 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 operand = hitSegment->operand();
if (operand) {
- SkTSwap(wind, oppWind);
+ using std::swap;
+ swap(wind, oppWind);
}
int lastWind = wind;
int lastOpp = oppWind;
@@ -357,7 +360,8 @@
}
}
if (operand) {
- SkTSwap(wind, oppWind);
+ using std::swap;
+ swap(wind, oppWind);
}
last = &hit->fPt;
this->globalState()->bumpNested();
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 577bac7..7d91454 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -123,7 +123,7 @@
// curNodes takes a reference to its items, which it passes to pageTree.
int totalPageCount = pages->count();
SkTArray<sk_sp<SkPDFDict>> curNodes;
- curNodes.swap(pages);
+ curNodes.swap(*pages);
// nextRoundNodes passes its references to nodes on to curNodes.
int treeCapacity = kNodeSize;
@@ -164,7 +164,7 @@
}
SkDEBUGCODE( for (const auto& n : curNodes) { SkASSERT(!n); } );
- curNodes.swap(&nextRoundNodes);
+ curNodes.swap(nextRoundNodes);
nextRoundNodes.reset();
treeCapacity *= kNodeSize;
} while (curNodes.count() > 1);
diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp
index 5627304..bd15834 100644
--- a/src/ports/SkFontHost_FreeType_common.cpp
+++ b/src/ports/SkFontHost_FreeType_common.cpp
@@ -15,6 +15,8 @@
#include "SkPath.h"
#include "SkTo.h"
+#include <utility>
+
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
@@ -161,7 +163,8 @@
const uint8_t* srcG = srcR + bitmap.pitch;
const uint8_t* srcB = srcG + bitmap.pitch;
if (lcdIsBGR) {
- SkTSwap(srcR, srcB);
+ using std::swap;
+ swap(srcR, srcB);
}
for (int x = 0; x < width; x++) {
dst[x] = packTriple(sk_apply_lut_if<APPLY_PREBLEND>(*srcR++, tableR),
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 4c06e96..18d09b4 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -49,6 +49,8 @@
#include <dlfcn.h>
+#include <utility>
+
// Experimental code to use a global lock whenever we access CG, to see if this reduces
// crashes in Chrome
#define USE_GLOBAL_MUTEX_FOR_CG_ACCESS
@@ -1170,7 +1172,8 @@
CTFontGetAdvancesForGlyphs(fCTFont.get(), kCTFontOrientationVertical,
&cgGlyph, &cgAdvance, 1);
// Vertical advances are returned as widths instead of heights.
- SkTSwap(cgAdvance.height, cgAdvance.width);
+ using std::swap;
+ swap(cgAdvance.height, cgAdvance.width);
cgAdvance.height = -cgAdvance.height;
} else {
CTFontGetAdvancesForGlyphs(fCTFont.get(), kCTFontOrientationHorizontal,
diff --git a/src/shaders/gradients/Sk4fLinearGradient.cpp b/src/shaders/gradients/Sk4fLinearGradient.cpp
index 0000fd9..8f061e2 100644
--- a/src/shaders/gradients/Sk4fLinearGradient.cpp
+++ b/src/shaders/gradients/Sk4fLinearGradient.cpp
@@ -10,6 +10,7 @@
#include "SkPaint.h"
#include <cmath>
+#include <utility>
namespace {
@@ -162,7 +163,8 @@
bias1 = dither_cell[rowIndex + 1];
if (x & 1) {
- SkTSwap(bias0, bias1);
+ using std::swap;
+ swap(bias0, bias1);
}
}
@@ -262,7 +264,8 @@
dst += n;
if (n & 1) {
- SkTSwap(bias4f0, bias4f1);
+ using std::swap;
+ swap(bias4f0, bias4f1);
}
}
}
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
index 7d5026b..5739a80 100644
--- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp
@@ -12,6 +12,8 @@
#include "SkWriteBuffer.h"
#include "../../jumper/SkJumper.h"
+#include <utility>
+
// Please see https://skia.org/dev/design/conical for how our shader works.
bool SkTwoPointConicalGradient::FocalData::set(SkScalar r0, SkScalar r1, SkMatrix* matrix) {
@@ -134,16 +136,17 @@
SkScalar r2 = buffer.readScalar();
if (buffer.isVersionLT(SkReadBuffer::k2PtConicalNoFlip_Version) && buffer.readBool()) {
+ using std::swap;
// legacy flipped gradient
- SkTSwap(c1, c2);
- SkTSwap(r1, r2);
+ swap(c1, c2);
+ swap(r1, r2);
SkColor4f* colors = desc.mutableColors();
SkScalar* pos = desc.mutablePos();
const int last = desc.fCount - 1;
const int half = desc.fCount >> 1;
for (int i = 0; i < half; ++i) {
- SkTSwap(colors[i], colors[last - i]);
+ swap(colors[i], colors[last - i]);
if (pos) {
SkScalar tmp = pos[i];
pos[i] = SK_Scalar1 - pos[last - i];
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index e4840c8..fc73c9f 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -10,6 +10,8 @@
#include "SkPointPriv.h"
#include "SkStrokeRec.h"
+#include <utility>
+
static inline int is_even(int x) {
return !(x & 1);
}
@@ -108,7 +110,8 @@
SkScalar maxXY = (&pts[1].fX)[xyOffset];
bool swapped = maxXY < minXY;
if (swapped) {
- SkTSwap(minXY, maxXY);
+ using std::swap;
+ swap(minXY, maxXY);
}
SkASSERT(minXY <= maxXY);
@@ -137,7 +140,8 @@
SkASSERT(maxXY >= minXY);
if (swapped) {
- SkTSwap(minXY, maxXY);
+ using std::swap;
+ swap(minXY, maxXY);
}
(&pts[0].fX)[xyOffset] = minXY;
(&pts[1].fX)[xyOffset] = maxXY;
@@ -196,7 +200,8 @@
SkScalar maxX = pts[1].fX;
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
SkASSERT(minX <= maxX);
@@ -219,7 +224,8 @@
SkASSERT(maxX >= minX);
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
pts[0].fX = minX;
pts[1].fX = maxX;
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 930012c..905ff44 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -17,6 +17,8 @@
#include "SkSurface.h"
#include "SkClipOpPriv.h"
+#include <utility>
+
uint32_t GrShape::testingOnly_getOriginalGenerationID() const {
if (const auto* lp = this->originalPathForListeners()) {
return lp->getGenerationID();
@@ -1932,7 +1934,8 @@
canonicalizeAsAB = true;
} else if (pts[1] == kA && pts[0] == kB) {
canonicalizeAsAB = false;
- SkTSwap(canonicalPts[0], canonicalPts[1]);
+ using std::swap;
+ swap(canonicalPts[0], canonicalPts[1]);
} else {
ERRORF(r, "Should return pts (a,b) or (b, a)");
return;
diff --git a/tests/PathOpsConicLineIntersectionTest.cpp b/tests/PathOpsConicLineIntersectionTest.cpp
index c3d4a2a..8a96519 100644
--- a/tests/PathOpsConicLineIntersectionTest.cpp
+++ b/tests/PathOpsConicLineIntersectionTest.cpp
@@ -13,6 +13,8 @@
#include "SkReduceOrder.h"
#include "Test.h"
+#include <utility>
+
static struct lineConic {
ConicPts conic;
SkDLine line;
@@ -38,7 +40,8 @@
double bottom = line[1].fY;
flipped = top > bottom;
if (flipped) {
- SkTSwap<double>(top, bottom);
+ using std::swap;
+ swap(top, bottom);
}
result = intersections.vertical(conic, top, bottom, line[0].fX, flipped);
} else if (line[0].fY == line[1].fY) {
@@ -46,7 +49,8 @@
double right = line[1].fX;
flipped = left > right;
if (flipped) {
- SkTSwap<double>(left, right);
+ using std::swap;
+ swap(left, right);
}
result = intersections.horizontal(conic, left, right, line[0].fY, flipped);
} else {
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index a6ae5e6..87e6cea 100644
--- a/tests/PathOpsCubicLineIntersectionTest.cpp
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp
@@ -11,6 +11,8 @@
#include "SkReduceOrder.h"
#include "Test.h"
+#include <utility>
+
struct lineCubic {
CubicPts cubic;
SkDLine line;
@@ -106,7 +108,8 @@
double bottom = line[1].fY;
flipped = top > bottom;
if (flipped) {
- SkTSwap<double>(top, bottom);
+ using std::swap;
+ swap(top, bottom);
}
result = intersections.vertical(cubic, top, bottom, line[0].fX, flipped);
} else if (line[0].fY == line[1].fY) {
@@ -114,7 +117,8 @@
double right = line[1].fX;
flipped = left > right;
if (flipped) {
- SkTSwap<double>(left, right);
+ using std::swap;
+ swap(left, right);
}
result = intersections.horizontal(cubic, left, right, line[0].fY, flipped);
} else {
diff --git a/tests/PathOpsQuadLineIntersectionTest.cpp b/tests/PathOpsQuadLineIntersectionTest.cpp
index f24b2e4..5bbd845 100644
--- a/tests/PathOpsQuadLineIntersectionTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionTest.cpp
@@ -12,6 +12,8 @@
#include "SkReduceOrder.h"
#include "Test.h"
+#include <utility>
+
static struct lineQuad {
QuadPts quad;
SkDLine line;
@@ -37,7 +39,8 @@
double bottom = line[1].fY;
flipped = top > bottom;
if (flipped) {
- SkTSwap<double>(top, bottom);
+ using std::swap;
+ swap(top, bottom);
}
result = intersections.vertical(quad, top, bottom, line[0].fX, flipped);
} else if (line[0].fY == line[1].fY) {
@@ -45,7 +48,8 @@
double right = line[1].fX;
flipped = left > right;
if (flipped) {
- SkTSwap<double>(left, right);
+ using std::swap;
+ swap(left, right);
}
result = intersections.horizontal(quad, left, right, line[0].fY, flipped);
} else {
diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
index a82ac28..c615894 100644
--- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
@@ -13,6 +13,8 @@
#include "SkReduceOrder.h"
#include "SkString.h"
+#include <utility>
+
static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, const SkDLine& line,
bool& flipped) {
int result;
@@ -22,7 +24,8 @@
double bottom = line[1].fY;
flipped = top > bottom;
if (flipped) {
- SkTSwap<double>(top, bottom);
+ using std::swap;
+ swap(top, bottom);
}
result = intersections.vertical(quad, top, bottom, line[0].fX, flipped);
} else if (line[0].fY == line[1].fY) {
@@ -30,7 +33,8 @@
double right = line[1].fX;
flipped = left > right;
if (flipped) {
- SkTSwap<double>(left, right);
+ using std::swap;
+ swap(left, right);
}
result = intersections.horizontal(quad, left, right, line[0].fY, flipped);
} else {
diff --git a/tests/PathOpsTestCommon.cpp b/tests/PathOpsTestCommon.cpp
index d7db579..c067d1d 100644
--- a/tests/PathOpsTestCommon.cpp
+++ b/tests/PathOpsTestCommon.cpp
@@ -14,6 +14,8 @@
#include "SkReduceOrder.h"
#include "SkTSort.h"
+#include <utility>
+
static double calc_t_div(const SkDCubic& cubic, double precision, double start) {
const double adjust = sqrt(3.) / 36;
SkDCubic sub;
@@ -223,7 +225,8 @@
double tInflects[2];
int inflections = cubic.findInflections(tInflects);
if (inflections > 1 && tInflects[0] > tInflects[1]) {
- SkTSwap(tInflects[0], tInflects[1]);
+ using std::swap;
+ swap(tInflects[0], tInflects[1]);
}
double lo = 0;
for (int index = 0; index <= inflections; ++index) {
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 30d27c1..a742bcb 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -26,6 +26,7 @@
#include "Test.h"
#include <cmath>
+#include <utility>
static void set_radii(SkVector radii[4], int index, float rad) {
sk_bzero(radii, sizeof(SkVector) * 4);
@@ -1804,10 +1805,12 @@
for (size_t q = 0; q < SK_ARRAY_COUNT(kQueries); ++q) {
SkRect qRect = kQueries[q].fQueryRect;
if (inv & 0x1) {
- SkTSwap(qRect.fLeft, qRect.fRight);
+ using std::swap;
+ swap(qRect.fLeft, qRect.fRight);
}
if (inv & 0x2) {
- SkTSwap(qRect.fTop, qRect.fBottom);
+ using std::swap;
+ swap(qRect.fTop, qRect.fBottom);
}
for (int d = 0; d < 2; ++d) {
SkPath::Direction dir = d ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
@@ -2145,6 +2148,7 @@
}
static void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
+ using std::swap;
SkRect r = SkRect::MakeEmpty();
SkPath::Direction d = SkPath::kCCW_Direction;
unsigned s = ~0U;
@@ -2216,12 +2220,12 @@
static constexpr unsigned kXSwapStarts[] = { 1, 0, 3, 2 };
static constexpr unsigned kYSwapStarts[] = { 3, 2, 1, 0 };
SkRect swapRect = testRect;
- SkTSwap(swapRect.fLeft, swapRect.fRight);
+ swap(swapRect.fLeft, swapRect.fRight);
path2.reset();
path2.addRect(swapRect, dir, start);
check_simple_closed_rect(reporter, path2, testRect, swapDir, kXSwapStarts[start]);
swapRect = testRect;
- SkTSwap(swapRect.fTop, swapRect.fBottom);
+ swap(swapRect.fTop, swapRect.fBottom);
path2.reset();
path2.addRect(swapRect, dir, start);
check_simple_closed_rect(reporter, path2, testRect, swapDir, kYSwapStarts[start]);
diff --git a/tests/TArrayTest.cpp b/tests/TArrayTest.cpp
index 5845b61..f80f672 100644
--- a/tests/TArrayTest.cpp
+++ b/tests/TArrayTest.cpp
@@ -79,7 +79,7 @@
for (int i = 0; i < sizeA; i++) { a->push_back(curr++); }
for (int i = 0; i < sizeB; i++) { b->push_back(curr++); }
- a->swap(b);
+ a->swap(*b);
REPORTER_ASSERT(reporter, b->count() == sizeA);
REPORTER_ASSERT(reporter, a->count() == sizeB);
@@ -87,7 +87,7 @@
for (auto&& x : *b) { REPORTER_ASSERT(reporter, x == curr++); }
for (auto&& x : *a) { REPORTER_ASSERT(reporter, x == curr++); }
- a->swap(a);
+ a->swap(*a);
curr = sizeA;
for (auto&& x : *a) { REPORTER_ASSERT(reporter, x == curr++); }
}}
diff --git a/tools/viewer/BisectSlide.cpp b/tools/viewer/BisectSlide.cpp
index 38ab3c3..0239ef2 100644
--- a/tools/viewer/BisectSlide.cpp
+++ b/tools/viewer/BisectSlide.cpp
@@ -11,6 +11,8 @@
#include "SkPicture.h"
#include "SkStream.h"
+#include <utility>
+
#ifdef SK_XML
#include "SkDOM.h"
#include "../experimental/svg/model/SkSVGDOM.h"
@@ -74,7 +76,8 @@
switch (c) {
case 'X':
if (!fTossedPaths.empty()) {
- SkTSwap(fFoundPaths, fTossedPaths);
+ using std::swap;
+ swap(fFoundPaths, fTossedPaths);
if ('X' == fTrail.back()) {
fTrail.pop_back();
} else {
diff --git a/tools/viewer/SlideDir.cpp b/tools/viewer/SlideDir.cpp
index 41bff87..0cc1230 100644
--- a/tools/viewer/SlideDir.cpp
+++ b/tools/viewer/SlideDir.cpp
@@ -25,6 +25,7 @@
#include "SkTypeface.h"
#include <cmath>
+#include <utility>
namespace {
@@ -147,8 +148,9 @@
void startUnfocus() {
SkASSERT(fTarget);
- SkTSwap(fM0, fM1);
- SkTSwap(fOpacity0, fOpacity1);
+ using std::swap;
+ swap(fM0, fM1);
+ swap(fOpacity0, fOpacity1);
fTimeBase = 0;
fState = State::kUnfocusing;