aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-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
30 files changed, 202 insertions, 97 deletions
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);