aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-06-18 15:11:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 02:06:31 +0000
commitf08d1d0ce19c72bb911f059dcf916cf99a0a2467 (patch)
tree65fed059b8bd2b730c86e202cc8475fb60b76455
parent93724202640b1f5ae9ccf7646151c9c3bb5afa5c (diff)
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>
-rw-r--r--bench/ImageCacheBudgetBench.cpp5
-rw-r--r--docs/SkColor_Reference.bmh5
-rw-r--r--docs/SkPixmap_Reference.bmh5
-rw-r--r--fuzz/FuzzCanvas.cpp4
-rw-r--r--gm/complexclip3.cpp5
-rw-r--r--gm/dashcubics.cpp7
-rw-r--r--gn/core.gni1
-rw-r--r--include/core/SkRect.h12
-rw-r--r--include/core/SkString.h4
-rw-r--r--include/gpu/gl/GrGLExtensions.h7
-rw-r--r--include/private/SkMessageBus.h2
-rw-r--r--include/private/SkTArray.h21
-rw-r--r--include/private/SkTDArray.h15
-rw-r--r--modules/skottie/src/SkottieAdapter.cpp4
-rw-r--r--samplecode/SamplePathClip.cpp8
-rw-r--r--src/android/SkAnimatedImage.cpp17
-rw-r--r--src/core/SkAAClip.cpp10
-rw-r--r--src/core/SkAnalyticEdge.cpp7
-rw-r--r--src/core/SkAnalyticEdge.h7
-rw-r--r--src/core/SkBitmap.cpp6
-rw-r--r--src/core/SkCubicClipper.cpp7
-rw-r--r--src/core/SkDistanceFieldGen.cpp5
-rw-r--r--src/core/SkDraw.cpp5
-rw-r--r--src/core/SkEdge.cpp21
-rw-r--r--src/core/SkEdge.h7
-rw-r--r--src/core/SkEdgeClipper.cpp16
-rw-r--r--src/core/SkGeometry.cpp15
-rw-r--r--src/core/SkLineClipper.cpp5
-rw-r--r--src/core/SkMatrix.cpp10
-rw-r--r--src/core/SkMatrix44.cpp14
-rw-r--r--src/core/SkPath.cpp20
-rw-r--r--src/core/SkPixmap.cpp8
-rw-r--r--src/core/SkQuadClipper.cpp5
-rw-r--r--src/core/SkRRect.cpp17
-rw-r--r--src/core/SkRegion.cpp10
-rw-r--r--src/core/SkScaleToSides.h7
-rw-r--r--src/core/SkScan_AAAPath.cpp16
-rw-r--r--src/core/SkScan_Antihair.cpp12
-rw-r--r--src/core/SkScan_Hairline.cpp12
-rw-r--r--src/core/SkScan_Path.cpp5
-rw-r--r--src/core/SkString.cpp7
-rw-r--r--src/core/SkStroke.cpp5
-rw-r--r--src/core/SkStrokerPriv.cpp11
-rw-r--r--src/core/SkTDPQueue.h11
-rw-r--r--src/core/SkTSort.h16
-rw-r--r--src/core/SkTTopoSort.h2
-rw-r--r--src/effects/SkDashPathEffect.cpp14
-rw-r--r--src/gpu/GrShape.cpp5
-rw-r--r--src/gpu/GrTessellator.cpp6
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp5
-rw-r--r--src/gpu/ops/GrOvalOpFactory.cpp5
-rw-r--r--src/gpu/vk/GrVkGpu.cpp5
-rw-r--r--src/opts/SkSwizzler_opts.h7
-rw-r--r--src/pathops/SkAddIntersections.cpp7
-rw-r--r--src/pathops/SkDLineIntersection.cpp8
-rw-r--r--src/pathops/SkOpCoincidence.cpp68
-rw-r--r--src/pathops/SkOpSegment.cpp22
-rw-r--r--src/pathops/SkPathOpsDebug.cpp46
-rw-r--r--src/pathops/SkPathOpsOp.cpp8
-rw-r--r--src/pathops/SkPathOpsTSect.h16
-rw-r--r--src/pathops/SkPathOpsWinding.cpp8
-rw-r--r--src/pdf/SkPDFDocument.cpp4
-rw-r--r--src/ports/SkFontHost_FreeType_common.cpp5
-rw-r--r--src/ports/SkFontHost_mac.cpp5
-rw-r--r--src/shaders/gradients/Sk4fLinearGradient.cpp7
-rw-r--r--src/shaders/gradients/SkTwoPointConicalGradient.cpp9
-rw-r--r--src/utils/SkDashPath.cpp14
-rw-r--r--tests/GrShapeTest.cpp5
-rw-r--r--tests/PathOpsConicLineIntersectionTest.cpp8
-rw-r--r--tests/PathOpsCubicLineIntersectionTest.cpp8
-rw-r--r--tests/PathOpsQuadLineIntersectionTest.cpp8
-rw-r--r--tests/PathOpsQuadLineIntersectionThreadedTest.cpp8
-rw-r--r--tests/PathOpsTestCommon.cpp5
-rw-r--r--tests/PathTest.cpp12
-rw-r--r--tests/TArrayTest.cpp4
-rw-r--r--tools/viewer/BisectSlide.cpp5
-rw-r--r--tools/viewer/SlideDir.cpp6
77 files changed, 521 insertions, 243 deletions
diff --git a/bench/ImageCacheBudgetBench.cpp b/bench/ImageCacheBudgetBench.cpp
index d8f6cbbc25..2955945051 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 @@ protected:
}
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 a92e393853..27b76a58dc 100644
--- a/docs/SkColor_Reference.bmh
+++ b/docs/SkColor_Reference.bmh
@@ -676,8 +676,9 @@ hsv[2] contains HSV_Value, a value from zero to one.
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 432324e3e2..019c13a8ac 100644
--- a/docs/SkPixmap_Reference.bmh
+++ b/docs/SkPixmap_Reference.bmh
@@ -1387,8 +1387,9 @@ One word corresponds to one pixel.
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 f63ddb12f8..2cb9968d5b 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 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) {
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 7c5c672128..2415806863 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 @@ protected:
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 bfff3f3658..4c1f028326 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 @@ protected:
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 99da62fe4a..9761dcccbe 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -267,6 +267,7 @@ skia_core_sources = [
"$_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 b33b0b9ac9..ed0e599ad9 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 @@ struct SK_API SkIRect {
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 @@ public:
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 aa3292abfe..300d9ed8ef 100644
--- a/include/core/SkString.h
+++ b/include/core/SkString.h
@@ -274,9 +274,7 @@ SkString SkStringPrintf(const char* format, ...);
/// 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 0b1ff44603..73e509798e 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 @@ public:
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 6ddf82c446..19e937555d 100644
--- a/include/private/SkMessageBus.h
+++ b/include/private/SkMessageBus.h
@@ -93,7 +93,7 @@ void SkMessageBus<Message>::Inbox::poll(SkTArray<Message>* messages) {
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 c9bee99c6d..75cd001b72 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -298,18 +298,19 @@ public:
/** 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 @@ private:
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 dd3212d0dd..c6bd4ffd37 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 @@ public:
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 @@ private:
}
};
+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 2caf570eff..615390e0b2 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 @@ void TrimEffectAdapter::apply() {
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 2db72c9f75..ab9fb4bd48 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 @@ static int clip_line(const SkRect& bounds, SkPoint p0, SkPoint p1, SkPoint edges
}
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 @@ static int clip_line(const SkRect& bounds, SkPoint p0, SkPoint p1, SkPoint edges
// 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 4885ada117..6bbea6b2e4 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 @@ bool SkAnimatedImage::Frame::init(const SkImageInfo& info, OnInit onInit) {
}
memcpy(tmp.getPixels(), fBitmap.getPixels(), fBitmap.computeByteSize());
- SkTSwap(tmp, fBitmap);
+ using std::swap;
+ swap(tmp, fBitmap);
return true;
}
}
@@ -213,7 +216,8 @@ int SkAnimatedImage::decodeNextFrame() {
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 @@ int SkAnimatedImage::decodeNextFrame() {
// 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 @@ int SkAnimatedImage::decodeNextFrame() {
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 @@ int SkAnimatedImage::decodeNextFrame() {
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 46c09e0ca5..f0b341c5d0 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 @@ void SkAAClip::swap(SkAAClip& other) {
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 @@ bool SkAAClip::op(const SkAAClip& clipAOrig, const SkAAClip& clipBOrig,
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 60c956aaf8..9226aca5ff 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 @@ bool SkAnalyticEdge::updateLine(SkFixed x0, SkFixed y0, SkFixed x1, SkFixed y1,
// 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 b18ccac918..a1d3da3314 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 @@ bool SkAnalyticEdge::setLine(const SkPoint& p0, const SkPoint& p1) {
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 8c70d54ea9..e942a4c2d2 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 @@ SkBitmap& SkBitmap::operator=(SkBitmap&& other) {
}
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 b5b7dceabe..e4ec79ed6d 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 @@ bool SkCubicClipper::clipCubic(const SkPoint srcPts[4], SkPoint dst[4]) {
}
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 9038178d06..fe99405688 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 @@ static float edge_distance(const SkPoint& direction, float alpha) {
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 79712a2312..98cfd87a84 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 @@ static SkScalar fast_len(const SkVector& vec) {
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 0a19e53221..905e17f58a 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 SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, const SkIRect* clip,
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 @@ bool SkQuadraticEdge::setQuadraticWithoutUpdate(const SkPoint pts[3], int shift)
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 @@ bool SkCubicEdge::setCubicWithoutUpdate(const SkPoint pts[4], int shift, bool so
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 7fc685136a..cc35baa8fc 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 SkEdge::setLine(const SkPoint& p0, const SkPoint& p1, int shift) {
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 b2b95fc78e..cbb0327114 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 @@ void SkEdgeClipper::clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip) {
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 @@ void SkEdgeClipper::clipMonoCubic(const SkPoint src[4], const SkRect& clip) {
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 @@ void SkEdgeClipper::appendLine(SkPoint p0, SkPoint p1) {
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 249b62e577..a53450949d 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 @@ int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]) {
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 @@ inline static void write_cubic_inflection_roots(double t0, double s0, double t1,
// 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 73a18192c9..d7c75c362f 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 cb4b792a6b..3d50659e08 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 @@ template <MinMaxOrBoth MIN_MAX_OR_BOTH> bool get_scale_factor(SkMatrix::TypeMask
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 @@ template <MinMaxOrBoth MIN_MAX_OR_BOTH> bool get_scale_factor(SkMatrix::TypeMask
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 bc3b35f1f5..a79b703761 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 @@ bool SkMatrix44::invert(SkMatrix44* storage) const {
///////////////////////////////////////////////////////////////////////////////
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 e38d736294..99ac492967 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 @@ bool operator==(const SkPath& a, const SkPath& b) {
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 @@ static int winding_mono_cubic(const SkPoint pts[], SkScalar x, SkScalar y, int*
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 @@ static int winding_mono_conic(const SkConic& conic, SkScalar x, SkScalar y, int*
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 @@ static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* o
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 @@ static int winding_line(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurv
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 aad9e34222..6eaf679715 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 @@ static bool draw_orientation(const SkPixmap& dst, const SkPixmap& src, unsigned
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 @@ bool SkPixmapPriv::Orient(const SkPixmap& dst, const SkPixmap& src, OrientFlags
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 fcde929ea7..baa7fee91a 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 @@ bool SkQuadClipper::clipQuad(const SkPoint srcPts[3], SkPoint dst[3]) {
}
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 46e83aec0f..01e76d5db1 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 @@ bool SkRRect::transform(const SkMatrix& matrix, SkRRect* dst) const {
}
// 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 3d48f3696b..86ef4f8600 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 @@ SkRegion& SkRegion::operator=(const SkRegion& src) {
}
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 @@ bool SkRegion::Oper(const SkRegion& rgnaOrig, const SkRegion& rgnbOrig, Op op,
// 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 c700891061..61bff63a2b 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 @@ public:
// 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 bd649e7aef..9dbb271890 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 @@ static inline SkAlpha f2a(SkFixed f) {
// 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 @@ static SK_ALWAYS_INLINE void blit_trapezoid_row(AdditiveBlitter* blitter, int y,
// 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 @@ static inline bool isSmoothEnough(SkAnalyticEdge* leftE, SkAnalyticEdge* riteE,
}
// 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 @@ static inline void aaa_walk_convex_edges(SkAnalyticEdge* prevHead,
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 37faed4850..ade4818537 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 @@ static void do_anti_hairline(SkFDot6 x0, SkFDot6 y0, SkFDot6 x1, SkFDot6 y1,
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 @@ static void do_anti_hairline(SkFDot6 x0, SkFDot6 y0, SkFDot6 x1, SkFDot6 y1,
}
} 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 815130d532..d9c0408b34 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 @@ void SkScan::HairLineRgn(const SkPoint array[], int arrayCount, const SkRegion*
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 @@ void SkScan::HairLineRgn(const SkPoint array[], int arrayCount, const SkRegion*
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 c26a22476e..e5dd774c3b 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 @@ static void walk_convex_edges(SkEdge* prevHead, SkPath::FillType,
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 23c85f993e..65dae1b753 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 @@ void SkString::swap(SkString& other) {
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 bb216d12d1..b880c152da 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 @@ static bool sharp_angle(const SkPoint quad[3]) {
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 be7b1f5eb4..87bc172926 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 @@ static void BluntJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
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 @@ static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
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 @@ static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnit
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 5f6fd3bc73..5dca4910ed 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 @@ private:
}
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 @@ private:
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 @@ private:
// 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 a97baf9446..87d99d5eb9 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 @@ void SkTHeapSort_SiftDown(T array[], size_t root, size_t bottom, C lessThan) {
}
/** 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 @@ template <typename T, typename C> void SkTHeapSort(T array[], size_t count, C le
}
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 void SkTInsertionSort(T* left, T* right
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 @@ template <typename T, typename C> void SkTIntroSort(int depth, T* left, T* right
}
/** 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 722707d5b5..01dee53327 100644
--- a/src/core/SkTTopoSort.h
+++ b/src/core/SkTTopoSort.h
@@ -102,7 +102,7 @@ bool SkTTopoSort(SkTArray<sk_sp<T>>* graph) {
}
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 830159253a..aa3803a95c 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 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
SkScalar maxX = pts[1].fX;
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
SkASSERT(minX < maxX);
@@ -114,7 +117,8 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
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 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
SkScalar maxY = pts[1].fY;
if (dy < 0) {
- SkTSwap(minY, maxY);
+ using std::swap;
+ swap(minY, maxY);
}
SkASSERT(minY < maxY);
@@ -145,7 +150,8 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
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 d74b144741..a0a395bf66 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 @@ void GrShape::attemptToSimplifyLine() {
// 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 6490c5b73a..2dd82a0892 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 @@ void reconnect(Edge* edge, Vertex* src, Vertex* dst, Comparator& c) {
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 81e8da1a7d..e2197023b1 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 @@ void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
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 747fa5f119..7b0e4621e9 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 @@ public:
// 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 d0eb8765ba..1149855b1b 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 @@ void GrVkGpu::copySurfaceAsBlit(GrSurface* dst, GrSurfaceOrigin dstOrigin,
// 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 699b11cb16..892dc31f62 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 @@ static void premul_should_swapRB(uint32_t* dst, const void* vsrc, int count) {
}
/*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 @@ static void premul_should_swapRB(uint32_t* dst, const void* vsrc, int count) {
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 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();
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 577bac7252..7d914544e5 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -123,7 +123,7 @@ static sk_sp<SkPDFDict> generate_page_tree(SkTArray<sk_sp<SkPDFDict>>* pages) {
// 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 @@ static sk_sp<SkPDFDict> generate_page_tree(SkTArray<sk_sp<SkPDFDict>>* pages) {
}
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 5627304956..bd15834775 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 @@ void copyFT2LCD16(const FT_Bitmap& bitmap, const SkMask& mask, int lcdIsBGR,
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 4c06e960a6..18d09b4ec0 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 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) {
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 0000fd9a15..8f061e2eee 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 @@ LinearGradient4fContext::shadeSpan(int x, int y, SkPMColor dst[], int count) {
bias1 = dither_cell[rowIndex + 1];
if (x & 1) {
- SkTSwap(bias0, bias1);
+ using std::swap;
+ swap(bias0, bias1);
}
}
@@ -262,7 +264,8 @@ LinearGradient4fContext::shadeSpanInternal(int x, int y, dstType dst[], int coun
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 7d5026bc22..5739a8003a 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 @@ sk_sp<SkFlattenable> SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer)
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 e4840c84b6..fc73c9f5a7 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 @@ static bool clip_line(SkPoint pts[2], const SkRect& bounds, SkScalar intervalLen
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 @@ static bool clip_line(SkPoint pts[2], const SkRect& bounds, SkScalar intervalLen
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 @@ static bool cull_path(const SkPath& srcPath, const SkStrokeRec& rec,
SkScalar maxX = pts[1].fX;
if (dx < 0) {
- SkTSwap(minX, maxX);
+ using std::swap;
+ swap(minX, maxX);
}
SkASSERT(minX <= maxX);
@@ -219,7 +224,8 @@ static bool cull_path(const SkPath& srcPath, const SkStrokeRec& rec,
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 930012c33f..905ff4490e 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 @@ DEF_TEST(GrShape_lines, r) {
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 c3d4a2afe3..8a96519815 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 @@ static int doIntersect(SkIntersections& intersections, const SkDConic& conic, co
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 @@ static int doIntersect(SkIntersections& intersections, const SkDConic& conic, co
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 a6ae5e6441..87e6cea51d 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 @@ static int doIntersect(SkIntersections& intersections, const SkDCubic& cubic, co
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 @@ static int doIntersect(SkIntersections& intersections, const SkDCubic& cubic, co
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 f24b2e4d7a..5bbd845d0b 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 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
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 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
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 a82ac28fde..c61589469f 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 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
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 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
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 d7db579d9c..c067d1d3e2 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 @@ void CubicPathToSimple(const SkPath& cubicPath, SkPath* simplePath) {
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 30d27c1e1b..a742bcbbee 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 @@ static void test_conservativelyContains(skiatest::Reporter* reporter) {
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 check_simple_closed_rect(skiatest::Reporter* reporter, const SkPath&
}
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 void test_is_simple_closed_rect(skiatest::Reporter* reporter) {
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 5845b61f93..f80f6726e5 100644
--- a/tests/TArrayTest.cpp
+++ b/tests/TArrayTest.cpp
@@ -79,7 +79,7 @@ template <typename T> static void test_swap(skiatest::Reporter* reporter,
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 @@ template <typename T> static void test_swap(skiatest::Reporter* reporter,
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 38ab3c3ffd..0239ef2b0d 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 @@ bool BisectSlide::onChar(SkUnichar c) {
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 41bff87b79..0cc1230b38 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 @@ public:
void startUnfocus() {
SkASSERT(fTarget);
- SkTSwap(fM0, fM1);
- SkTSwap(fOpacity0, fOpacity1);
+ using std::swap;
+ swap(fM0, fM1);
+ swap(fOpacity0, fOpacity1);
fTimeBase = 0;
fState = State::kUnfocusing;