Replace SK_ARRAY_COUNT with std::size() for skia/samplecode
Change-Id: Ibfa2c0efa3e4addf21aa400e3d323675ac0185ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/551886
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/samplecode/Sample3D.cpp b/samplecode/Sample3D.cpp
index ec1fa62..f9f4df8 100644
--- a/samplecode/Sample3D.cpp
+++ b/samplecode/Sample3D.cpp
@@ -452,7 +452,7 @@
"skottie/skottie-motiontile-effect-phase.json",
};
- for (unsigned i = 0; i < SK_ARRAY_COUNT(files); ++i) {
+ for (unsigned i = 0; i < std::size(files); ++i) {
if (auto stream = GetResourceAsStream(files[i])) {
fAnim[i] = skottie::Animation::Make(stream.get());
}
diff --git a/samplecode/SampleAARectModes.cpp b/samplecode/SampleAARectModes.cpp
index 99d8f77..5d3c5e7 100644
--- a/samplecode/SampleAARectModes.cpp
+++ b/samplecode/SampleAARectModes.cpp
@@ -84,7 +84,7 @@
for (int alpha = 0; alpha < 4; ++alpha) {
canvas->save();
canvas->save();
- for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); ++i) {
+ for (size_t i = 0; i < std::size(gModes); ++i) {
if (6 == i) {
canvas->restore();
canvas->translate(W * 5, 0);
diff --git a/samplecode/SampleAARects.cpp b/samplecode/SampleAARects.cpp
index b7cc5e8..1f15f06 100644
--- a/samplecode/SampleAARects.cpp
+++ b/samplecode/SampleAARects.cpp
@@ -61,7 +61,7 @@
SkScalar dx = SkIntToScalar(80);
SkScalar dy = SkIntToScalar(100);
SkMatrix matrix;
- for (size_t p = 0; p < SK_ARRAY_COUNT(paints); ++p) {
+ for (size_t p = 0; p < std::size(paints); ++p) {
for (int stroke = 0; stroke < 2; ++stroke) {
paints[p].setStyle(stroke ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
for (int a = 0; a < 3; ++ a) {
diff --git a/samplecode/SampleAnimBlur.cpp b/samplecode/SampleAnimBlur.cpp
index c946a2a..21cec90 100644
--- a/samplecode/SampleAnimBlur.cpp
+++ b/samplecode/SampleAnimBlur.cpp
@@ -36,7 +36,7 @@
};
SkRandom random;
- for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) {
+ for (size_t i = 0; i < std::size(gStyles); ++i) {
SkPaint paint;
paint.setMaskFilter(SkMaskFilter::MakeBlur(gStyles[i],
fBlurSigma));
diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp
index 4662956..3b620d5 100644
--- a/samplecode/SampleArc.cpp
+++ b/samplecode/SampleArc.cpp
@@ -131,7 +131,7 @@
225, 90
};
- for (size_t i = 0; i < SK_ARRAY_COUNT(gAngles); i += 2) {
+ for (size_t i = 0; i < std::size(gAngles); i += 2) {
paint.setColor(SK_ColorBLACK);
DrawRectWithLines(canvas, r, paint);
diff --git a/samplecode/SampleClip.cpp b/samplecode/SampleClip.cpp
index 2d0fdfd..192b5fe 100644
--- a/samplecode/SampleClip.cpp
+++ b/samplecode/SampleClip.cpp
@@ -117,7 +117,7 @@
for (int aa = 0; aa <= 1; ++aa) {
canvas->save();
- for (size_t i = 0; i < SK_ARRAY_COUNT(gProc); ++i) {
+ for (size_t i = 0; i < std::size(gProc); ++i) {
canvas->save();
canvas->clipPath(clipPath, SkClipOp::kIntersect, SkToBool(aa));
// canvas->drawColor(SK_ColorWHITE);
diff --git a/samplecode/SampleComplexClip.cpp b/samplecode/SampleComplexClip.cpp
index 64e7af5..6e8930b 100644
--- a/samplecode/SampleComplexClip.cpp
+++ b/samplecode/SampleComplexClip.cpp
@@ -86,8 +86,8 @@
canvas->save();
for (int invA = 0; invA < 2; ++invA) {
- for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
- size_t idx = invA * SK_ARRAY_COUNT(gOps) + op;
+ for (size_t op = 0; op < std::size(gOps); ++op) {
+ size_t idx = invA * std::size(gOps) + op;
if (!(idx % 3)) {
canvas->restore();
canvas->translate(0, SkIntToScalar(250));
diff --git a/samplecode/SampleCusp.cpp b/samplecode/SampleCusp.cpp
index 543a3a3..26c4c84 100644
--- a/samplecode/SampleCusp.cpp
+++ b/samplecode/SampleCusp.cpp
@@ -97,7 +97,7 @@
{{{0x43480000,0x43960000},{0x436f0222,0x4328051c},{0x435c2222,0x43810f5c},{0x435ae000,0x4351e664},}},
};
-size_t datCount = SK_ARRAY_COUNT(dat);
+size_t datCount = std::size(dat);
class CuspView : public Sample {
public:
diff --git a/samplecode/SampleDegenerateTwoPtRadials.cpp b/samplecode/SampleDegenerateTwoPtRadials.cpp
index f0c74be..16c0887 100644
--- a/samplecode/SampleDegenerateTwoPtRadials.cpp
+++ b/samplecode/SampleDegenerateTwoPtRadials.cpp
@@ -28,7 +28,7 @@
SkScalar r1 = 2 * w / 5;
SkPaint paint;
paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
- pos, SK_ARRAY_COUNT(pos),
+ pos, std::size(pos),
SkTileMode::kClamp));
canvas->drawRect(rect, paint);
}
diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp
index 5a49ded..134eba7 100644
--- a/samplecode/SampleEffects.cpp
+++ b/samplecode/SampleEffects.cpp
@@ -35,7 +35,7 @@
static void paint_proc3(SkPaint* paint) {
SkColor colors[] = { SK_ColorRED, COLOR, SK_ColorBLUE };
SkPoint pts[] = { { 3, 0 }, { 7, 5 } };
- paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
+ paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors),
SkTileMode::kMirror));
}
@@ -58,7 +58,7 @@
class EffectsView : public Sample {
public:
SkPath fPath;
- SkPaint fPaint[SK_ARRAY_COUNT(gPaintProcs)];
+ SkPaint fPaint[std::size(gPaintProcs)];
EffectsView() {
size_t i;
@@ -72,11 +72,11 @@
0, -10
};
fPath.moveTo(pts[0], pts[1]);
- for (i = 2; i < SK_ARRAY_COUNT(pts); i += 2) {
+ for (i = 2; i < std::size(pts); i += 2) {
fPath.lineTo(pts[i], pts[i+1]);
}
- for (i = 0; i < SK_ARRAY_COUNT(gPaintProcs); i++) {
+ for (i = 0; i < std::size(gPaintProcs); i++) {
fPaint[i].setAntiAlias(true);
fPaint[i].setColor(COLOR);
gPaintProcs[i](&fPaint[i]);
@@ -91,7 +91,7 @@
void onDrawContent(SkCanvas* canvas) override {
canvas->scale(3, 3);
canvas->translate(10, 30);
- for (size_t i = 0; i < SK_ARRAY_COUNT(fPaint); i++) {
+ for (size_t i = 0; i < std::size(fPaint); i++) {
canvas->drawPath(fPath, fPaint[i]);
canvas->translate(32, 0);
}
diff --git a/samplecode/SampleFilterBounds.cpp b/samplecode/SampleFilterBounds.cpp
index 5406b92..5660c59 100644
--- a/samplecode/SampleFilterBounds.cpp
+++ b/samplecode/SampleFilterBounds.cpp
@@ -106,7 +106,7 @@
{ 0.8f, 0.1f, 0.f, 1.f } }; // Severe upscaling, s > 8, log(s) > 3
static const SkScalar kLogScaleFactors[] = { -3.f, -1.f, 0.f, 1.f, 3.f };
static const SkScalar kGradientStops[] = { 0.f, 0.33333f, 0.5f, 0.66667f, 1.f };
-static const int kStopCount = (int) SK_ARRAY_COUNT(kScaleGradientColors);
+static const int kStopCount = (int) std::size(kScaleGradientColors);
static void draw_scale_key(SkCanvas* canvas, float y) {
SkRect key = SkRect::MakeXYWH(15.f, y + 30.f, 15.f, 100.f);
diff --git a/samplecode/SampleGradients.cpp b/samplecode/SampleGradients.cpp
index a101ec3..3ea30bf 100644
--- a/samplecode/SampleGradients.cpp
+++ b/samplecode/SampleGradients.cpp
@@ -133,9 +133,9 @@
for (int tm = 0; tm < kSkTileModeCount; ++tm) {
canvas->save();
- for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
+ for (size_t i = 0; i < std::size(gGradData); i++) {
canvas->save();
- for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
+ for (size_t j = 0; j < std::size(gGradMakers); j++) {
paint.setShader(gGradMakers[j](pts, gGradData[i], (SkTileMode)tm));
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
@@ -144,7 +144,7 @@
canvas->translate(SkIntToScalar(120), 0);
}
canvas->restore();
- canvas->translate(SK_ARRAY_COUNT(gGradData)*SkIntToScalar(120), 0);
+ canvas->translate(std::size(gGradData)*SkIntToScalar(120), 0);
}
canvas->restore();
diff --git a/samplecode/SampleHairModes.cpp b/samplecode/SampleHairModes.cpp
index 6e05fbc..4748850 100644
--- a/samplecode/SampleHairModes.cpp
+++ b/samplecode/SampleHairModes.cpp
@@ -84,7 +84,7 @@
for (int alpha = 0; alpha < 4; ++alpha) {
canvas->save();
canvas->save();
- for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); ++i) {
+ for (size_t i = 0; i < std::size(gModes); ++i) {
if (6 == i) {
canvas->restore();
canvas->translate(W * 5, 0);
diff --git a/samplecode/SampleImageFilterDAG.cpp b/samplecode/SampleImageFilterDAG.cpp
index 320af13..8e9cb05 100644
--- a/samplecode/SampleImageFilterDAG.cpp
+++ b/samplecode/SampleImageFilterDAG.cpp
@@ -138,7 +138,7 @@
static const SkColor kColors[2] = {SK_ColorGREEN, SK_ColorWHITE};
SkPoint points[2] = { {content.fLeft + 15.f, content.fTop + 15.f},
{content.fRight - 15.f, content.fBottom - 15.f} };
- paint.setShader(SkGradientShader::MakeLinear(points, kColors, nullptr, SK_ARRAY_COUNT(kColors),
+ paint.setShader(SkGradientShader::MakeLinear(points, kColors, nullptr, std::size(kColors),
SkTileMode::kRepeat));
SkPaint line;
diff --git a/samplecode/SampleMaterialShadows.cpp b/samplecode/SampleMaterialShadows.cpp
index 8cb951f..74a243a 100644
--- a/samplecode/SampleMaterialShadows.cpp
+++ b/samplecode/SampleMaterialShadows.cpp
@@ -72,7 +72,7 @@
paint.setColor(SK_ColorWHITE);
canvas->save();
canvas->translate(80, 80);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
zPlaneParams.fZ = elevations[i];
this->drawShadowedPath(canvas, fCirclePath, zPlaneParams, paint, kAmbientAlpha,
lightPos, kLightRadius, kSpotAlpha);
@@ -82,7 +82,7 @@
canvas->save();
canvas->translate(120, 175);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
zPlaneParams.fZ = elevations[i];
this->drawShadowedPath(canvas, fCapsulePath, zPlaneParams, paint, kAmbientAlpha,
lightPos, kLightRadius, kSpotAlpha);
@@ -92,7 +92,7 @@
canvas->save();
canvas->translate(120, 320);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
zPlaneParams.fZ = elevations[i];
this->drawShadowedPath(canvas, fLargeRRPath, zPlaneParams, paint, kAmbientAlpha,
lightPos, kLightRadius, kSpotAlpha);
@@ -102,7 +102,7 @@
canvas->save();
canvas->translate(100, 475);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
zPlaneParams.fZ = elevations[i];
this->drawShadowedPath(canvas, fSmallRRPath, zPlaneParams, paint, kAmbientAlpha,
lightPos, kLightRadius, kSpotAlpha);
@@ -112,7 +112,7 @@
canvas->save();
canvas->translate(100, 600);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
canvas->save();
zPlaneParams.fZ = elevations[i];
canvas->rotate(10);
@@ -125,7 +125,7 @@
canvas->save();
canvas->translate(100, 725);
- for (unsigned int i = 0; i < SK_ARRAY_COUNT(elevations); ++i) {
+ for (unsigned int i = 0; i < std::size(elevations); ++i) {
canvas->save();
zPlaneParams.fZ = elevations[i];
canvas->rotate(45);
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 98dde31..e5681c8 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -42,7 +42,7 @@
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::MakeLinear(pts, colors, nullptr,
- SK_ARRAY_COUNT(colors), SkTileMode::kMirror);
+ std::size(colors), SkTileMode::kMirror);
}
class Patch {
@@ -261,7 +261,7 @@
paint.setShader(nullptr);
paint.setAntiAlias(true);
paint.setStrokeWidth(SkIntToScalar(5));
- canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fPts, paint);
+ canvas->drawPoints(SkCanvas::kPoints_PointMode, std::size(fPts), fPts, paint);
canvas->translate(0, SkIntToScalar(300));
@@ -299,7 +299,7 @@
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
x -= DX;
y -= DY;
- for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
+ for (size_t i = 0; i < std::size(fPts); i++) {
if (hittest(fPts[i], x, y)) {
return new PtClick((int)i);
}
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index ac725d9..4320384 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -165,9 +165,9 @@
SkPaint::kRound_Join
};
- for (size_t i = 0; i < SK_ARRAY_COUNT(gJoins); i++) {
+ for (size_t i = 0; i < std::size(gJoins); i++) {
canvas->save();
- for (size_t j = 0; j < SK_ARRAY_COUNT(fPath); j++) {
+ for (size_t j = 0; j < std::size(fPath); j++) {
this->drawPath(canvas, fPath[j], gJoins[i]);
canvas->translate(200, 0);
}
diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp
index 8db008d..103fd4f 100644
--- a/samplecode/SamplePathClip.cpp
+++ b/samplecode/SamplePathClip.cpp
@@ -250,7 +250,7 @@
public:
DragPolyClick(SkPoint poly[], int count) : fPoly(poly), fCount(count)
{
- SkASSERT((size_t)count <= SK_ARRAY_COUNT(fSrc));
+ SkASSERT((size_t)count <= std::size(fSrc));
memcpy(fSrc, poly, count * sizeof(SkPoint));
}
void handleMove() override {
diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
index 5ed3241..bde7f25 100644
--- a/samplecode/SamplePathEffects.cpp
+++ b/samplecode/SamplePathEffects.cpp
@@ -32,7 +32,7 @@
SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
- for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
+ for (unsigned i = 2; i < std::size(gXY); i += 2)
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
path.close();
path.offset(SkIntToScalar(-6), 0);
@@ -50,7 +50,7 @@
static sk_sp<SkPathEffect> make_warp_pe(SkScalar phase) {
SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
- for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) {
+ for (unsigned i = 2; i < std::size(gXY); i += 2) {
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
}
path.close();
diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp
index bd98ad7..0993fbe 100644
--- a/samplecode/SampleQuadStroker.cpp
+++ b/samplecode/SampleQuadStroker.cpp
@@ -715,55 +715,55 @@
};
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
- for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) {
+ for (size_t i = 0; i < std::size(fPts); ++i) {
if (hittest(fPts[i], x, y)) {
return new MyClick((int)i);
}
}
const SkRect& rectPt = SkRect::MakeXYWH(x, y, 1, 1);
if (fWeightControl.contains(rectPt)) {
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 1);
+ return new MyClick((int) std::size(fPts) + 1);
}
if (fRadiusControl.contains(rectPt)) {
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 2);
+ return new MyClick((int) std::size(fPts) + 2);
}
#ifdef SK_DEBUG
if (fErrorControl.contains(rectPt)) {
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 3);
+ return new MyClick((int) std::size(fPts) + 3);
}
#endif
if (fWidthControl.contains(rectPt)) {
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 4);
+ return new MyClick((int) std::size(fPts) + 4);
}
if (fCubicButton.fBounds.contains(rectPt)) {
fCubicButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 5);
+ return new MyClick((int) std::size(fPts) + 5);
}
if (fConicButton.fBounds.contains(rectPt)) {
fConicButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 6);
+ return new MyClick((int) std::size(fPts) + 6);
}
if (fQuadButton.fBounds.contains(rectPt)) {
fQuadButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 7);
+ return new MyClick((int) std::size(fPts) + 7);
}
if (fArcButton.fBounds.contains(rectPt)) {
fArcButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 8);
+ return new MyClick((int) std::size(fPts) + 8);
}
if (fRRectButton.fBounds.contains(rectPt)) {
fRRectButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 9);
+ return new MyClick((int) std::size(fPts) + 9);
}
if (fCircleButton.fBounds.contains(rectPt)) {
bool wasEnabled = fCircleButton.fEnabled;
fCircleButton.fEnabled = !fCircleButton.fFill;
fCircleButton.fFill = wasEnabled && !fCircleButton.fFill;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 10);
+ return new MyClick((int) std::size(fPts) + 10);
}
if (fTextButton.fBounds.contains(rectPt)) {
fTextButton.fEnabled ^= true;
- return new MyClick((int) SK_ARRAY_COUNT(fPts) + 11);
+ return new MyClick((int) std::size(fPts) + 11);
}
return nullptr;
}
@@ -775,22 +775,22 @@
bool onClick(Click* click) override {
int index = ((MyClick*)click)->fIndex;
- if (index < (int) SK_ARRAY_COUNT(fPts)) {
+ if (index < (int) std::size(fPts)) {
fPts[index].offset(click->fCurr.fX - click->fPrev.fX,
click->fCurr.fY - click->fPrev.fY);
- } else if (index == (int) SK_ARRAY_COUNT(fPts) + 1) {
+ } else if (index == (int) std::size(fPts) + 1) {
fWeight = MapScreenYtoValue(click->fCurr.fY, fWeightControl, 0, 5);
- } else if (index == (int) SK_ARRAY_COUNT(fPts) + 2) {
+ } else if (index == (int) std::size(fPts) + 2) {
fRadius = MapScreenYtoValue(click->fCurr.fY, fRadiusControl, 0, 500);
}
#ifdef SK_DEBUG
- else if (index == (int) SK_ARRAY_COUNT(fPts) + 3) {
+ else if (index == (int) std::size(fPts) + 3) {
gDebugStrokerError = std::max(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY,
fErrorControl, kStrokerErrorMin, kStrokerErrorMax));
gDebugStrokerErrorSet = true;
}
#endif
- else if (index == (int) SK_ARRAY_COUNT(fPts) + 4) {
+ else if (index == (int) std::size(fPts) + 4) {
fWidth = std::max(FLT_EPSILON, MapScreenYtoValue(click->fCurr.fY, fWidthControl,
kWidthMin, kWidthMax));
fAnimate = fWidth <= kWidthMin;
diff --git a/samplecode/SampleSBIX.cpp b/samplecode/SampleSBIX.cpp
index 21bf2d0..2486b92 100644
--- a/samplecode/SampleSBIX.cpp
+++ b/samplecode/SampleSBIX.cpp
@@ -334,7 +334,7 @@
canvas->drawPoint(advance, 0, paint);
paint.setStrokeWidth(SkIntToScalar(kPointSize));
- canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fPts, paint);
+ canvas->drawPoints(SkCanvas::kPoints_PointMode, std::size(fPts), fPts, paint);
canvas->translate(kFontSize, 0);
}
@@ -353,7 +353,7 @@
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey modi) override {
x -= DX;
y -= DY;
- for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
+ for (size_t i = 0; i < std::size(fPts); i++) {
if (hittest(fPts[i], x, y)) {
return new PtClick((int)i);
}
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index a17a674..11bea6d 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -56,7 +56,7 @@
static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12);
- paint->setPathEffect(SkDashPathEffect::Make(inter, SK_ARRAY_COUNT(inter), 0));
+ paint->setPathEffect(SkDashPathEffect::Make(inter, std::size(inter), 0));
compose_pe(paint);
}
@@ -73,7 +73,7 @@
static void one_d_pe(SkPaint* paint) {
SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
- for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
+ for (unsigned i = 2; i < std::size(gXY); i += 2)
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
path.close();
path.offset(SkIntToScalar(-6), 0);
@@ -126,7 +126,7 @@
size_t i;
canvas->save();
- for (i = 0; i < SK_ARRAY_COUNT(gPE); i++) {
+ for (i = 0; i < std::size(gPE); i++) {
gPE[i](&paint);
canvas->drawPath(path, paint);
canvas->translate(0, 75);
@@ -140,7 +140,7 @@
path.addRect(r, SkPathDirection::kCCW);
canvas->translate(320, 20);
- for (i = 0; i < SK_ARRAY_COUNT(gPE2); i++) {
+ for (i = 0; i < std::size(gPE2); i++) {
gPE2[i](&paint);
canvas->drawPath(path, paint);
canvas->translate(0, 160);
@@ -221,9 +221,9 @@
paint.setDither(true);
canvas->translate(SkIntToScalar(20), SkIntToScalar(10));
- for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
+ for (size_t i = 0; i < std::size(gGradData); i++) {
canvas->save();
- for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
+ for (size_t j = 0; j < std::size(gGradMakers); j++) {
paint.setShader(gGradMakers[j](pts, gGradData[i], tm));
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
@@ -253,7 +253,7 @@
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::MakeLinear(pts, colors, nullptr,
- SK_ARRAY_COUNT(colors), SkTileMode::kMirror);
+ std::size(colors), SkTileMode::kMirror);
}
class Rec {
@@ -363,7 +363,7 @@
SkPaint paint;
paint.setDither(true);
- for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
+ for (size_t i = 0; i < std::size(fRecs); i++) {
auto verts = SkVertices::MakeCopy(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs, nullptr);
canvas->save();
@@ -421,7 +421,7 @@
SkCanvas canvas(bm);
SkScalar s = SkIntToScalar(1024) / 640;
canvas.scale(s, s);
- for (size_t i = 0; i < SK_ARRAY_COUNT(gProc); i++) {
+ for (size_t i = 0; i < std::size(gProc); i++) {
canvas.save();
canvas.drawColor(BG_COLOR);
gProc[i](&canvas);
@@ -443,7 +443,7 @@
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override {
this->init();
- fIndex = (fIndex + 1) % SK_ARRAY_COUNT(gProc);
+ fIndex = (fIndex + 1) % std::size(gProc);
return nullptr;
}
diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp
index 5feb87c..c7c6918 100644
--- a/samplecode/SampleStrokePath.cpp
+++ b/samplecode/SampleStrokePath.cpp
@@ -128,7 +128,7 @@
void drawSet(SkCanvas* canvas, SkPaint* paint) {
SkAutoCanvasRestore acr(canvas, true);
- for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
+ for (size_t i = 0; i < std::size(gRec); i++) {
paint->setStyle(gRec[i].fStyle);
paint->setStrokeJoin(gRec[i].fJoin);
paint->setStrokeWidth(SkIntToScalar(gRec[i].fStrokeWidth));
diff --git a/samplecode/SampleStrokeRect.cpp b/samplecode/SampleStrokeRect.cpp
index d4cc4ae..680a84d 100644
--- a/samplecode/SampleStrokeRect.cpp
+++ b/samplecode/SampleStrokeRect.cpp
@@ -39,11 +39,11 @@
};
canvas->translate(paint.getStrokeWidth(), paint.getStrokeWidth());
- for (size_t i = 0; i < SK_ARRAY_COUNT(gJoin); ++i) {
+ for (size_t i = 0; i < std::size(gJoin); ++i) {
paint.setStrokeJoin(gJoin[i]);
canvas->save();
- for (size_t j = 0; j < SK_ARRAY_COUNT(gSize); ++j) {
+ for (size_t j = 0; j < std::size(gSize); ++j) {
SkRect r = SkRect::MakeWH(SkIntToScalar(gSize[j].fWidth),
SkIntToScalar(gSize[j].fHeight));
canvas->drawRect(r, paint);
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index d2c7fea..5797a0c 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -43,7 +43,7 @@
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::MakeLinear(pts, colors, nullptr,
- SK_ARRAY_COUNT(colors), SkTileMode::kMirror);
+ std::size(colors), SkTileMode::kMirror);
}
class VerticesView : public Sample {
@@ -75,7 +75,7 @@
SkPaint paint;
paint.setDither(true);
- for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
+ for (size_t i = 0; i < std::size(fRecs); i++) {
auto verts = SkVertices::MakeCopy(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
nullptr);
diff --git a/samplecode/SampleXfer.cpp b/samplecode/SampleXfer.cpp
index 0d57cf4..e15d90c 100644
--- a/samplecode/SampleXfer.cpp
+++ b/samplecode/SampleXfer.cpp
@@ -28,7 +28,7 @@
SkBlendMode::kDstOut,
SkBlendMode::kDstATop,
};
-const int N_Modes = SK_ARRAY_COUNT(gModes);
+const int N_Modes = std::size(gModes);
static SkRandom gRand;
diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp
index bd603d5..5a5a1e8 100644
--- a/samplecode/SampleXfermodesBlur.cpp
+++ b/samplecode/SampleXfermodesBlur.cpp
@@ -109,7 +109,7 @@
SkScalar x0 = 0;
for (int twice = 0; twice < 2; twice++) {
SkScalar x = x0, y = 0;
- for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
+ for (size_t i = 0; i < std::size(gModes); i++) {
SkRect r;
r.setLTRB(x, y, x+w, y+h);