diff --git a/docs/examples/Bitmap_readPixels.cpp b/docs/examples/Bitmap_readPixels.cpp index c5c121e2c2..9e9eeed731 100644 --- a/docs/examples/Bitmap_readPixels.cpp +++ b/docs/examples/Bitmap_readPixels.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, - SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); + std::size(gradColors), SkTileMode::kClamp)); SkBitmap bitmap; bitmap.allocPixels(srcInfo); SkCanvas srcCanvas(bitmap); diff --git a/docs/examples/Canvas_clipPath_3.cpp b/docs/examples/Canvas_clipPath_3.cpp index 3a1c516f73..24d3748330 100644 --- a/docs/examples/Canvas_clipPath_3.cpp +++ b/docs/examples/Canvas_clipPath_3.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { SkPath path; SkPoint poly[] = {{20, 20}, { 80, 20}, { 80, 80}, {40, 80}, {40, 40}, {100, 40}, {100, 100}, {20, 100}}; - path.addPoly(poly, SK_ARRAY_COUNT(poly), true); + path.addPoly(poly, std::size(poly), true); path.setFillType(SkPathFillType::kWinding); canvas->save(); canvas->clipPath(path, SkClipOp::kIntersect); diff --git a/docs/examples/Canvas_drawOval.cpp b/docs/examples/Canvas_drawOval.cpp index 570114cd0c..413de39b39 100644 --- a/docs/examples/Canvas_drawOval.cpp +++ b/docs/examples/Canvas_drawOval.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { SkRect bounds = SkRect::MakeWH(80, 70); SkPaint paint; paint.setAntiAlias(true); - paint.setShader(SkGradientShader::MakeLinear(g1Points, g1Colors, pos, SK_ARRAY_COUNT(g1Colors), + paint.setShader(SkGradientShader::MakeLinear(g1Points, g1Colors, pos, std::size(g1Colors), SkTileMode::kClamp)); canvas->drawOval(bounds , paint); } diff --git a/docs/examples/Canvas_drawPaint.cpp b/docs/examples/Canvas_drawPaint.cpp index 879ab84274..8ca57a48dc 100644 --- a/docs/examples/Canvas_drawPaint.cpp +++ b/docs/examples/Canvas_drawPaint.cpp @@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; SkPaint paint; - paint.setShader(SkGradientShader::MakeSweep(256, 256, colors, pos, SK_ARRAY_COUNT(colors))); + paint.setShader(SkGradientShader::MakeSweep(256, 256, colors, pos, std::size(colors))); canvas->drawPaint(paint); } } // END FIDDLE diff --git a/docs/examples/Canvas_drawRoundRect.cpp b/docs/examples/Canvas_drawRoundRect.cpp index 9bde76c4ea..242a5cf77b 100644 --- a/docs/examples/Canvas_drawRoundRect.cpp +++ b/docs/examples/Canvas_drawRoundRect.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); for (auto style : { SkPaint::kStroke_Style, SkPaint::kFill_Style } ) { paint.setStyle(style ); - for (size_t i = 0; i < SK_ARRAY_COUNT(radii); ++i) { + for (size_t i = 0; i < std::size(radii); ++i) { canvas->drawRoundRect({10, 10, 60, 40}, radii[i].fX, radii[i].fY, paint); canvas->translate(0, 60); } diff --git a/docs/examples/Canvas_drawTextRSXform.cpp b/docs/examples/Canvas_drawTextRSXform.cpp index e94f28cfb2..4461f2ede8 100644 --- a/docs/examples/Canvas_drawTextRSXform.cpp +++ b/docs/examples/Canvas_drawTextRSXform.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { char alphabet[iterations]; SkScalar angle = 0; SkScalar scale = 1; - for (size_t i = 0; i < SK_ARRAY_COUNT(transforms); ++i) { + for (size_t i = 0; i < std::size(transforms); ++i) { const SkScalar s = SkScalarSin(angle) * scale; const SkScalar c = SkScalarCos(angle) * scale; transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16); diff --git a/docs/examples/Canvas_drawVertices.cpp b/docs/examples/Canvas_drawVertices.cpp index a289d573e2..79988c3402 100644 --- a/docs/examples/Canvas_drawVertices.cpp +++ b/docs/examples/Canvas_drawVertices.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN }; auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode, - SK_ARRAY_COUNT(points), points, nullptr, colors); + std::size(points), points, nullptr, colors); canvas->drawVertices(vertices.get(), SkBlendMode::kSrc, paint); } } // END FIDDLE diff --git a/docs/examples/Canvas_drawVertices_2.cpp b/docs/examples/Canvas_drawVertices_2.cpp index 899cc6d76a..ef72e82a6f 100644 --- a/docs/examples/Canvas_drawVertices_2.cpp +++ b/docs/examples/Canvas_drawVertices_2.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN }; paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4, SkTileMode::kClamp)); auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode, - SK_ARRAY_COUNT(points), points, texs, colors); + std::size(points), points, texs, colors); canvas->drawVertices(vertices, SkBlendMode::kDarken, paint); } } // END FIDDLE diff --git a/docs/examples/Canvas_getDeviceClipBounds.cpp b/docs/examples/Canvas_getDeviceClipBounds.cpp index f5394efbce..4b7d36a457 100644 --- a/docs/examples/Canvas_getDeviceClipBounds.cpp +++ b/docs/examples/Canvas_getDeviceClipBounds.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPath clipPath; - clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); + clipPath.addPoly(clipPoints, std::size(clipPoints), true); canvas->save(); canvas->clipPath(clipPath); bounds = canvas->getDeviceClipBounds(); diff --git a/docs/examples/Canvas_getLocalClipBounds.cpp b/docs/examples/Canvas_getLocalClipBounds.cpp index 0469f5f375..fc2368833f 100644 --- a/docs/examples/Canvas_getLocalClipBounds.cpp +++ b/docs/examples/Canvas_getLocalClipBounds.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPath clipPath; - clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); + clipPath.addPoly(clipPoints, std::size(clipPoints), true); canvas->clipPath(clipPath); bounds = canvas->getLocalClipBounds(); SkDebugf("left:%g top:%g right:%g bottom:%g\n", diff --git a/docs/examples/Canvas_quickReject_2.cpp b/docs/examples/Canvas_quickReject_2.cpp index 981dbabc97..24e690b2b3 100644 --- a/docs/examples/Canvas_quickReject_2.cpp +++ b/docs/examples/Canvas_quickReject_2.cpp @@ -7,8 +7,8 @@ void draw(SkCanvas* canvas) { SkPoint testPoints[] = {{30, 30}, {120, 30}, {120, 129} }; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPath testPath, clipPath; - testPath.addPoly(testPoints, SK_ARRAY_COUNT(testPoints), true); - clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); + testPath.addPoly(testPoints, std::size(testPoints), true); + clipPath.addPoly(clipPoints, std::size(clipPoints), true); canvas->save(); canvas->clipPath(clipPath); SkDebugf("quickReject %s\n", canvas->quickReject(testPath) ? "true" : "false"); diff --git a/docs/examples/Clear.cpp b/docs/examples/Clear.cpp index 490968bbe0..c8a0479f7a 100644 --- a/docs/examples/Clear.cpp +++ b/docs/examples/Clear.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) { SkColor colors[] = { color, SkColorSetA(color, 0) }; paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, - colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawCircle(64, 64, 100, paint); canvas->translate(64, 64); } diff --git a/docs/examples/Cubic.cpp b/docs/examples/Cubic.cpp index c2fff6bee0..35f2a0ed7c 100644 --- a/docs/examples/Cubic.cpp +++ b/docs/examples/Cubic.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { paint.setStyle(SkPaint::kStroke_Style); SkPoint cubicPts[] = {{20, 150}, {90, 10}, {160, 150}, {230, 10}}; SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; - for (unsigned i = 0; i < SK_ARRAY_COUNT(colors); ++i) { + for (unsigned i = 0; i < std::size(colors); ++i) { paint.setColor(0x7fffffff & colors[i]); paint.setStrokeWidth(1); for (unsigned j = 0; j < 3; ++j) { diff --git a/docs/examples/Darken.cpp b/docs/examples/Darken.cpp index 7dbb26fc15..b3bf3c9cb3 100644 --- a/docs/examples/Darken.cpp +++ b/docs/examples/Darken.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorWHITE, SK_ColorBLACK }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); paint.setBlendMode(SkBlendMode::kDarken); canvas->drawPaint(paint); diff --git a/docs/examples/Difference.cpp b/docs/examples/Difference.cpp index 1fc0c49574..0200fac7ea 100644 --- a/docs/examples/Difference.cpp +++ b/docs/examples/Difference.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Dither_b.cpp b/docs/examples/Dither_b.cpp index 695ba5c3b5..990b6ecf59 100644 --- a/docs/examples/Dither_b.cpp +++ b/docs/examples/Dither_b.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = {0xFF334455, 0xFF662211 }; SkPaint paint; paint.setShader(SkGradientShader::MakeLinear( - points, colors, nullptr, SK_ARRAY_COUNT(colors), + points, colors, nullptr, std::size(colors), SkTileMode::kClamp)); paint.setDither(true); auto img = bm32.asImage(); diff --git a/docs/examples/Dst_Atop.cpp b/docs/examples/Dst_Atop.cpp index 4db8147c34..0414faf18e 100644 --- a/docs/examples/Dst_Atop.cpp +++ b/docs/examples/Dst_Atop.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Dst_In.cpp b/docs/examples/Dst_In.cpp index ba3a1f7fb3..7b5c2b5347 100644 --- a/docs/examples/Dst_In.cpp +++ b/docs/examples/Dst_In.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Dst_Out.cpp b/docs/examples/Dst_Out.cpp index b6281c7621..5f7a8d0fb5 100644 --- a/docs/examples/Dst_Out.cpp +++ b/docs/examples/Dst_Out.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Dst_Over.cpp b/docs/examples/Dst_Over.cpp index af96e0f787..99ae14173a 100644 --- a/docs/examples/Dst_Over.cpp +++ b/docs/examples/Dst_Over.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Exclusion.cpp b/docs/examples/Exclusion.cpp index 7338c52016..939d3b3663 100644 --- a/docs/examples/Exclusion.cpp +++ b/docs/examples/Exclusion.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Hard_Light.cpp b/docs/examples/Hard_Light.cpp index 3b87d51fe3..8fb1e3970a 100644 --- a/docs/examples/Hard_Light.cpp +++ b/docs/examples/Hard_Light.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { SkPaint paint; paint.setBlendMode(SkBlendMode::kHardLight); paint.setShader(SkGradientShader::MakeRadial({ 128, 128}, 100, colors, - nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + nullptr, std::size(colors), SkTileMode::kClamp)); canvas->clipRect({0, 128, 256, 256}); canvas->drawPaint(paint); } diff --git a/docs/examples/IPoint_add_operator.cpp b/docs/examples/IPoint_add_operator.cpp index 78312858c5..9807f815b0 100644 --- a/docs/examples/IPoint_add_operator.cpp +++ b/docs/examples/IPoint_add_operator.cpp @@ -17,7 +17,7 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); canvas->scale(30, 15); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); SkIPoint mod = {4, 1}; for (auto& point : points) { point = point + mod; @@ -25,6 +25,6 @@ void draw(SkCanvas* canvas) { mod.fY += 1; } paint.setColor(SK_ColorRED); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); } } // END FIDDLE diff --git a/docs/examples/IPoint_addto_operator.cpp b/docs/examples/IPoint_addto_operator.cpp index 7987433c15..e6c0edc35d 100644 --- a/docs/examples/IPoint_addto_operator.cpp +++ b/docs/examples/IPoint_addto_operator.cpp @@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); canvas->scale(30, 15); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); points[1] += {1, 1}; points[2] += {-1, -1}; paint.setColor(SK_ColorRED); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); } } // END FIDDLE diff --git a/docs/examples/IPoint_subtract_operator.cpp b/docs/examples/IPoint_subtract_operator.cpp index 3b026085c1..da9d663eb0 100644 --- a/docs/examples/IPoint_subtract_operator.cpp +++ b/docs/examples/IPoint_subtract_operator.cpp @@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); canvas->scale(30, 15); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); points[1] += points[0] - points[3]; points[2] -= points[1] - points[0]; paint.setColor(SK_ColorRED); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); } } // END FIDDLE diff --git a/docs/examples/IPoint_subtractfrom_operator.cpp b/docs/examples/IPoint_subtractfrom_operator.cpp index 9fbfc6cc5e..68547dd03c 100644 --- a/docs/examples/IPoint_subtractfrom_operator.cpp +++ b/docs/examples/IPoint_subtractfrom_operator.cpp @@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); canvas->scale(30, 15); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); points[1] -= {1, 1}; points[2] -= {-1, -1}; paint.setColor(SK_ColorRED); - draw_lines(points, SK_ARRAY_COUNT(points), paint); + draw_lines(points, std::size(points), paint); } } // END FIDDLE diff --git a/docs/examples/ImageInfo_MakeS32.cpp b/docs/examples/ImageInfo_MakeS32.cpp index b369779070..da3620bc3e 100644 --- a/docs/examples/ImageInfo_MakeS32.cpp +++ b/docs/examples/ImageInfo_MakeS32.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { SkPoint gradPoints[] = { { 0, 0 }, { width, 0 } }; SkPaint gradPaint; gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, - SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); + std::size(gradColors), SkTileMode::kClamp)); SkBitmap bitmap; bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType)); SkCanvas offScreen(bitmap); diff --git a/docs/examples/ImageInfo_gammaCloseToSRGB.cpp b/docs/examples/ImageInfo_gammaCloseToSRGB.cpp index 7b7ec2e715..6c0f8a2660 100644 --- a/docs/examples/ImageInfo_gammaCloseToSRGB.cpp +++ b/docs/examples/ImageInfo_gammaCloseToSRGB.cpp @@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) { SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; SkPaint gradPaint; gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, - SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); + std::size(gradColors), SkShader::kClamp_TileMode)); canvas->drawRect(SkRect::MakeWH(width, height), gradPaint); drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); SkBitmap bitmap; diff --git a/docs/examples/ImageInfo_makeColorSpace.cpp b/docs/examples/ImageInfo_makeColorSpace.cpp index 896a735e0b..9e1b2d7de9 100644 --- a/docs/examples/ImageInfo_makeColorSpace.cpp +++ b/docs/examples/ImageInfo_makeColorSpace.cpp @@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) { SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; SkPaint gradPaint; gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, - SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode)); + std::size(gradColors), SkShader::kClamp_TileMode)); canvas->drawRect(SkRect::MakeWH(width, height), gradPaint); drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); SkBitmap bitmap; diff --git a/docs/examples/Image_scalePixels.cpp b/docs/examples/Image_scalePixels.cpp index 48a7eb3155..e24ead464b 100644 --- a/docs/examples/Image_scalePixels.cpp +++ b/docs/examples/Image_scalePixels.cpp @@ -19,7 +19,7 @@ void draw(SkCanvas* canvas) { SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), SkSamplingOptions({1.0f/3, 1.0f/3}), }; - for (unsigned index = 0; index < SK_ARRAY_COUNT(samplings); ++index) { + for (unsigned index = 0; index < std::size(samplings); ++index) { image->scalePixels(pixmap, samplings[index]); sk_sp filtered = SkImage::MakeFromRaster(pixmap, nullptr, nullptr); canvas->drawImage(filtered, 16 * index, 0); diff --git a/docs/examples/Lighten.cpp b/docs/examples/Lighten.cpp index 0e8a898e69..53c5c980f1 100644 --- a/docs/examples/Lighten.cpp +++ b/docs/examples/Lighten.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); paint.setBlendMode(SkBlendMode::kLighten); canvas->drawPaint(paint); diff --git a/docs/examples/Matrix_mapHomogeneousPoints.cpp b/docs/examples/Matrix_mapHomogeneousPoints.cpp index 2b34458265..cd9724a2c9 100644 --- a/docs/examples/Matrix_mapHomogeneousPoints.cpp +++ b/docs/examples/Matrix_mapHomogeneousPoints.cpp @@ -7,9 +7,9 @@ void draw(SkCanvas* canvas) { SkPoint3 src[] = {{3, 3, 1}, {8, 2, 2}, {5, 0, 4}, {0, 1, 3}, {3, 7, 1}, {8, 6, 2}, {5, 4, 4}, {0, 5, 3}}; int lines[] = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 }; - constexpr int count = SK_ARRAY_COUNT(src); + constexpr int count = std::size(src); auto debugster = [=](SkPoint3 src[]) -> void { - for (size_t i = 0; i < SK_ARRAY_COUNT(lines); i += 2) { + for (size_t i = 0; i < std::size(lines); i += 2) { const SkPoint3& s = src[lines[i]]; const SkPoint3& e = src[lines[i + 1]]; SkPaint paint; diff --git a/docs/examples/Matrix_mapVectors.cpp b/docs/examples/Matrix_mapVectors.cpp index fcacfcec54..545e615ad0 100644 --- a/docs/examples/Matrix_mapVectors.cpp +++ b/docs/examples/Matrix_mapVectors.cpp @@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) { for (int i = 0; i < 4; ++i) { SkVector rScaled[4]; matrix.preScale(1.5f, 2.f); - matrix.mapVectors(rScaled, radii, SK_ARRAY_COUNT(radii)); + matrix.mapVectors(rScaled, radii, std::size(radii)); SkRRect rrect; rrect.setRectRadii({20, 20, 180, 70}, rScaled); canvas->drawRRect(rrect, paint); diff --git a/docs/examples/Matrix_mapVectors_2.cpp b/docs/examples/Matrix_mapVectors_2.cpp index fde774c506..df96bb0ecf 100644 --- a/docs/examples/Matrix_mapVectors_2.cpp +++ b/docs/examples/Matrix_mapVectors_2.cpp @@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) { rrect.setRectRadii({20, 20, 180, 70}, radii); canvas->drawRRect(rrect, paint); canvas->translate(0, 60); - matrix.mapVectors(radii, SK_ARRAY_COUNT(radii)); + matrix.mapVectors(radii, std::size(radii)); } } } // END FIDDLE diff --git a/docs/examples/Matrix_mapXY.cpp b/docs/examples/Matrix_mapXY.cpp index 5993ecc39c..302dbb627e 100644 --- a/docs/examples/Matrix_mapXY.cpp +++ b/docs/examples/Matrix_mapXY.cpp @@ -9,12 +9,12 @@ void draw(SkCanvas* canvas) { SkMatrix matrix; matrix.setRotate(60, 128, 128); SkPoint lines[] = {{50, 50}, {150, 50}, {150, 150}}; - for (size_t i = 0; i < SK_ARRAY_COUNT(lines); ++i) { + for (size_t i = 0; i < std::size(lines); ++i) { SkPoint pt; matrix.mapXY(lines[i].fX, lines[i].fY, &pt); canvas->drawCircle(pt.fX, pt.fY, 3, paint); } canvas->concat(matrix); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(lines), lines, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(lines), lines, paint); } } // END FIDDLE diff --git a/docs/examples/Modulate.cpp b/docs/examples/Modulate.cpp index 8325d4a6d2..eb11f9ac23 100644 --- a/docs/examples/Modulate.cpp +++ b/docs/examples/Modulate.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE }; const SkPoint horz[] = { { 0, 0 }, { 128, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); paint.setBlendMode(mode); canvas->translate(dx, dy); diff --git a/docs/examples/Multiply.cpp b/docs/examples/Multiply.cpp index 338b9da84e..141f812c03 100644 --- a/docs/examples/Multiply.cpp +++ b/docs/examples/Multiply.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Overlay.cpp b/docs/examples/Overlay.cpp index 39aefd1917..e7c88f5034 100644 --- a/docs/examples/Overlay.cpp +++ b/docs/examples/Overlay.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Paint_move_SkPaint.cpp b/docs/examples/Paint_move_SkPaint.cpp index 995892da57..1a37bb7f4d 100644 --- a/docs/examples/Paint_move_SkPaint.cpp +++ b/docs/examples/Paint_move_SkPaint.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Paint_move_SkPaint, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPaint paint; float intervals[] = { 5, 5 }; - paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 2.5f)); + paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 2.5f)); SkPaint dashed(std::move(paint)); SkDebugf("path effect unique: %s\n", dashed.getPathEffect()->unique() ? "true" : "false"); } diff --git a/docs/examples/Paint_refPathEffect.cpp b/docs/examples/Paint_refPathEffect.cpp index 66ca1380e5..9f865454f6 100644 --- a/docs/examples/Paint_refPathEffect.cpp +++ b/docs/examples/Paint_refPathEffect.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Paint_refPathEffect, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPaint paint1, paint2; SkScalar intervals[] = {1, 2}; - paint1.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 10)); + paint1.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 10)); SkDebugf("path effect unique: %s\n", paint1.getPathEffect()->unique() ? "true" : "false"); paint2.setPathEffect(paint1.refPathEffect()); SkDebugf("path effect unique: %s\n", paint1.getPathEffect()->unique() ? "true" : "false"); diff --git a/docs/examples/Paint_setLinearText.cpp b/docs/examples/Paint_setLinearText.cpp index 675fe7fc93..28eed7e3a4 100644 --- a/docs/examples/Paint_setLinearText.cpp +++ b/docs/examples/Paint_setLinearText.cpp @@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) { for (auto linearText : { false, true } ) { paint.setLinearText(linearText); SkString width; - width.appendScalar(paint.measureText(testStr, SK_ARRAY_COUNT(testStr), nullptr)); + width.appendScalar(paint.measureText(testStr, std::size(testStr), nullptr)); canvas->translate(0, textSize + 4); canvas->drawString(testStr, 10, 0, paint); canvas->drawString(width, 128, 0, paint); diff --git a/docs/examples/Path_ConvertToNonInverseFillType.cpp b/docs/examples/Path_ConvertToNonInverseFillType.cpp index d60857f76a..f9880789e5 100644 --- a/docs/examples/Path_ConvertToNonInverseFillType.cpp +++ b/docs/examples/Path_ConvertToNonInverseFillType.cpp @@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) { nameValue(kInverseWinding), nameValue(kInverseEvenOdd), }; - for (unsigned i = 0; i < SK_ARRAY_COUNT(fills); ++i) { + for (unsigned i = 0; i < std::size(fills); ++i) { if (fills[i].fill != (SkPathFillType) i) { SkDebugf("fills array order does not match FillType enum order"); break; diff --git a/docs/examples/Path_Convexity.cpp b/docs/examples/Path_Convexity.cpp index 08d2367a98..cc17900be8 100644 --- a/docs/examples/Path_Convexity.cpp +++ b/docs/examples/Path_Convexity.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { for (SkScalar x : { 40, 100 } ) { SkPath path; quad[0].fX = x; - path.addPoly(quad, SK_ARRAY_COUNT(quad), true); + path.addPoly(quad, std::size(quad), true); canvas->drawPath(path, paint); canvas->drawString(labels[(int) path.getConvexity()], 30, 100, paint); canvas->translate(100, 100); diff --git a/docs/examples/Path_Direction.cpp b/docs/examples/Path_Direction.cpp index bbc74a2dd6..0391f61e02 100644 --- a/docs/examples/Path_Direction.cpp +++ b/docs/examples/Path_Direction.cpp @@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) { rectPaint.setStyle(SkPaint::kStroke_Style); SkPaint arrowPaint(rectPaint); SkPath arrowPath; - arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); + arrowPath.addPoly(arrow, std::size(arrow), true); arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 320, 0, SkPath1DPathEffect::kRotate_Style)); for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { diff --git a/docs/examples/Path_Effect_Methods.cpp b/docs/examples/Path_Effect_Methods.cpp index 3633b52b11..c71b413e82 100644 --- a/docs/examples/Path_Effect_Methods.cpp +++ b/docs/examples/Path_Effect_Methods.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(16); SkScalar intervals[] = {30, 10}; - paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 1)); + paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 1)); canvas->drawRoundRect({20, 20, 120, 120}, 20, 20, paint); } } // END FIDDLE diff --git a/docs/examples/Path_IsLineDegenerate.cpp b/docs/examples/Path_IsLineDegenerate.cpp index fc9bf70588..8bc21e16ad 100644 --- a/docs/examples/Path_IsLineDegenerate.cpp +++ b/docs/examples/Path_IsLineDegenerate.cpp @@ -5,7 +5,7 @@ REG_FIDDLE(Path_IsLineDegenerate, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPoint points[] = { {100, 100}, {100.000001f, 100.000001f}, {100.0001f, 100.0001f} }; - for (size_t i = 0; i < SK_ARRAY_COUNT(points) - 1; ++i) { + for (size_t i = 0; i < std::size(points) - 1; ++i) { for (bool exact : { false, true } ) { SkDebugf("line from (%1.8g,%1.8g) to (%1.8g,%1.8g) is %s" "degenerate, %s\n", points[i].fX, points[i].fY, points[i + 1].fX, points[i + 1].fY, diff --git a/docs/examples/Path_Verb.cpp b/docs/examples/Path_Verb.cpp index e2f6b1a1db..4d4a244730 100644 --- a/docs/examples/Path_Verb.cpp +++ b/docs/examples/Path_Verb.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { path.cubicTo(1, 2, 3, 4, 5, 6); path.conicTo(0, 0, 0, 0, 2); uint8_t verbs[7]; - int count = path.getVerbs(verbs, (int) SK_ARRAY_COUNT(verbs)); + int count = path.getVerbs(verbs, (int) std::size(verbs)); const char* verbStr[] = { "Move", "Line", "Quad", "Conic", "Cubic", "Close" }; SkDebugf("verb count: %d\nverbs: ", count); for (int i = 0; i < count; ++i) { diff --git a/docs/examples/Path_addOval_2.cpp b/docs/examples/Path_addOval_2.cpp index 1af997788c..bb7549d0bd 100644 --- a/docs/examples/Path_addOval_2.cpp +++ b/docs/examples/Path_addOval_2.cpp @@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) { ovalPaint.setStyle(SkPaint::kStroke_Style); SkPaint arrowPaint(ovalPaint); SkPath arrowPath; - arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); + arrowPath.addPoly(arrow, std::size(arrow), true); arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0, SkPath1DPathEffect::kRotate_Style)); for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { diff --git a/docs/examples/Path_addPoly.cpp b/docs/examples/Path_addPoly.cpp index 328f1411a3..46eaf3b3c7 100644 --- a/docs/examples/Path_addPoly.cpp +++ b/docs/examples/Path_addPoly.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { const SkPoint points[] = {{20, 20}, {70, 20}, {40, 90}}; for (bool close : { false, true } ) { SkPath path; - path.addPoly(points, SK_ARRAY_COUNT(points), close); + path.addPoly(points, std::size(points), close); for (auto style : {SkPaint::kStroke_Style, SkPaint::kFill_Style, SkPaint::kStrokeAndFill_Style} ) { paint.setStyle(style); diff --git a/docs/examples/Path_addRect.cpp b/docs/examples/Path_addRect.cpp index 694e420d07..651c5fc4d3 100644 --- a/docs/examples/Path_addRect.cpp +++ b/docs/examples/Path_addRect.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { paint.setStrokeCap(SkPaint::kSquare_Cap); float intervals[] = { 5, 21.75f }; paint.setStyle(SkPaint::kStroke_Style); - paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 0)); SkPath path; path.addRect({20, 20, 100, 100}, SkPathDirection::kCW); canvas->drawPath(path, paint); diff --git a/docs/examples/Path_addRect_2.cpp b/docs/examples/Path_addRect_2.cpp index 798eaae6b5..b78b46020b 100644 --- a/docs/examples/Path_addRect_2.cpp +++ b/docs/examples/Path_addRect_2.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { rectPaint.setStyle(SkPaint::kStroke_Style); SkPaint arrowPaint(rectPaint); SkPath arrowPath; - arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); + arrowPath.addPoly(arrow, std::size(arrow), true); arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0, SkPath1DPathEffect::kRotate_Style)); for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { diff --git a/docs/examples/Path_addRect_3.cpp b/docs/examples/Path_addRect_3.cpp index b5bb877a5d..35f2426559 100644 --- a/docs/examples/Path_addRect_3.cpp +++ b/docs/examples/Path_addRect_3.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { paint.setStrokeCap(SkPaint::kSquare_Cap); float intervals[] = { 5, 21.75f }; paint.setStyle(SkPaint::kStroke_Style); - paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 0)); for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { SkPath path; path.addRect(20, 20, 100, 100, direction); diff --git a/docs/examples/Path_close.cpp b/docs/examples/Path_close.cpp index 9a72c377e7..f260dff19b 100644 --- a/docs/examples/Path_close.cpp +++ b/docs/examples/Path_close.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { paint.setStrokeCap(SkPaint::kRound_Cap); SkPath path; const SkPoint points[] = {{20, 20}, {70, 20}, {40, 90}}; - path.addPoly(points, SK_ARRAY_COUNT(points), false); + path.addPoly(points, std::size(points), false); for (int loop = 0; loop < 2; ++loop) { for (auto style : {SkPaint::kStroke_Style, SkPaint::kFill_Style, SkPaint::kStrokeAndFill_Style} ) { diff --git a/docs/examples/Path_conicTo.cpp b/docs/examples/Path_conicTo.cpp index 26a4b71254..fc4a2a51de 100644 --- a/docs/examples/Path_conicTo.cpp +++ b/docs/examples/Path_conicTo.cpp @@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; paint.setStrokeWidth(3); SkScalar weight = 0.5f; - for (unsigned i = 0; i < SK_ARRAY_COUNT(colors); ++i) { + for (unsigned i = 0; i < std::size(colors); ++i) { SkPath path; path.moveTo(conicPts[0]); path.conicTo(conicPts[1], conicPts[2], weight); diff --git a/docs/examples/Path_conservativelyContainsRect.cpp b/docs/examples/Path_conservativelyContainsRect.cpp index 3a1fe6094a..d5a31aa465 100644 --- a/docs/examples/Path_conservativelyContainsRect.cpp +++ b/docs/examples/Path_conservativelyContainsRect.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { { 15, 25, 49, 115 }, { 13, 27, 51, 113 }, }; - for (unsigned i = 0; i < SK_ARRAY_COUNT(tests); ++i) { + for (unsigned i = 0; i < std::size(tests); ++i) { SkPaint paint; paint.setColor(SK_ColorRED); canvas->drawPath(path, paint); diff --git a/docs/examples/Path_isConvex.cpp b/docs/examples/Path_isConvex.cpp index 54bc96e657..e56427deef 100644 --- a/docs/examples/Path_isConvex.cpp +++ b/docs/examples/Path_isConvex.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { for (SkScalar x : { 40, 100 } ) { SkPath path; quad[0].fX = x; - path.addPoly(quad, SK_ARRAY_COUNT(quad), true); + path.addPoly(quad, std::size(quad), true); path.setConvexity(SkPath::kConvex_Convexity); canvas->drawPath(path, paint); canvas->drawString(path.isConvex() ? "convex" : "not convex", 30, 100, paint); diff --git a/docs/examples/Path_isRect.cpp b/docs/examples/Path_isRect.cpp index c099bb9739..5b6e25254d 100644 --- a/docs/examples/Path_isRect.cpp +++ b/docs/examples/Path_isRect.cpp @@ -24,7 +24,7 @@ void draw(SkCanvas* canvas) { debugster("lineTo", path); path.reset(); const SkPoint pts[] = { {0, 0}, {0, 80}, {80, 80}, {80, 0}, {40, 0}, {20, 0} }; - path.addPoly(pts, SK_ARRAY_COUNT(pts), false); + path.addPoly(pts, std::size(pts), false); debugster("addPoly", path); } } // END FIDDLE diff --git a/docs/examples/Path_lineTo.cpp b/docs/examples/Path_lineTo.cpp index 657f055290..125929dea5 100644 --- a/docs/examples/Path_lineTo.cpp +++ b/docs/examples/Path_lineTo.cpp @@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) { SkPoint hash[] = {{58, 28}, {43, 80}, {37, 45}, {85, 45}}; SkVector offsets[] = {{0, 0}, {17, 0}, {0, 0}, {-5, 17}}; unsigned o = 0; - for (unsigned i = 0; i < SK_ARRAY_COUNT(hash); i += 2) { + for (unsigned i = 0; i < std::size(hash); i += 2) { for (unsigned j = 0; j < 2; o++, j++) { path.moveTo(hash[i].fX + offsets[o].fX, hash[i].fY + offsets[o].fY); path.lineTo(hash[i + 1].fX + offsets[o].fX, hash[i + 1].fY + offsets[o].fY); diff --git a/docs/examples/Path_lineTo_2.cpp b/docs/examples/Path_lineTo_2.cpp index 0534d5aa08..7c6a4eb170 100644 --- a/docs/examples/Path_lineTo_2.cpp +++ b/docs/examples/Path_lineTo_2.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { SkVector oxo[] = {{25, 25}, {35, 35}, {25, 35}, {35, 25}, {40, 20}, {40, 80}, {60, 20}, {60, 80}, {20, 40}, {80, 40}, {20, 60}, {80, 60}}; - for (unsigned i = 0; i < SK_ARRAY_COUNT(oxo); i += 2) { + for (unsigned i = 0; i < std::size(oxo); i += 2) { path.moveTo(oxo[i]); path.lineTo(oxo[i + 1]); } diff --git a/docs/examples/Path_moveTo_2.cpp b/docs/examples/Path_moveTo_2.cpp index 88432250be..d1a4aa785c 100644 --- a/docs/examples/Path_moveTo_2.cpp +++ b/docs/examples/Path_moveTo_2.cpp @@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) { SkPoint data[][3] = {{{30,40},{60,60},{90,30}}, {{30,120},{60,100},{90,120}}, {{60,100},{60,40},{70,30}}, {{60,40},{50,20},{70,30}}}; SkPath path; - for (unsigned i = 0; i < SK_ARRAY_COUNT(data); ++i) { + for (unsigned i = 0; i < std::size(data); ++i) { path.moveTo(data[i][0]); path.lineTo(data[i][1]); path.lineTo(data[i][2]); diff --git a/docs/examples/Path_rMoveTo.cpp b/docs/examples/Path_rMoveTo.cpp index f59b579345..178ab1f0db 100644 --- a/docs/examples/Path_rMoveTo.cpp +++ b/docs/examples/Path_rMoveTo.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { path.addRect({20, 20, 80, 80}, SkPathDirection::kCW, 2); path.rMoveTo(25, 2); SkVector arrow[] = {{0, -4}, {-20, 0}, {0, -3}, {-5, 5}, {5, 5}, {0, -3}, {20, 0}}; - for (unsigned i = 0; i < SK_ARRAY_COUNT(arrow); ++i) { + for (unsigned i = 0; i < std::size(arrow); ++i) { path.rLineTo(arrow[i].fX, arrow[i].fY); } SkPaint paint; diff --git a/docs/examples/Pixmap_readPixels.cpp b/docs/examples/Pixmap_readPixels.cpp index f8446c819f..f950ef2f5d 100644 --- a/docs/examples/Pixmap_readPixels.cpp +++ b/docs/examples/Pixmap_readPixels.cpp @@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) { SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, - SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); + std::size(gradColors), SkTileMode::kClamp)); SkBitmap bitmap; bitmap.installPixels(srcPixmap); SkCanvas srcCanvas(bitmap); diff --git a/docs/examples/Plus.cpp b/docs/examples/Plus.cpp index 1d10fc1b1f..c1e676c177 100644 --- a/docs/examples/Plus.cpp +++ b/docs/examples/Plus.cpp @@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128), SkColorSetA(color, 0) }; paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, - colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawCircle(64, 64, 100, paint); canvas->translate(64, 64); } diff --git a/docs/examples/Point_Offset.cpp b/docs/examples/Point_Offset.cpp index 5447cad0e2..0342979c0e 100644 --- a/docs/examples/Point_Offset.cpp +++ b/docs/examples/Point_Offset.cpp @@ -12,8 +12,8 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } ); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); + SkPoint::Offset(points, std::size(points), { 1, 9 } ); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_Offset_2.cpp b/docs/examples/Point_Offset_2.cpp index b497481b17..784e7702ab 100644 --- a/docs/examples/Point_Offset_2.cpp +++ b/docs/examples/Point_Offset_2.cpp @@ -12,8 +12,8 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); - SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); + SkPoint::Offset(points, std::size(points), 1, 9); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_add_operator.cpp b/docs/examples/Point_add_operator.cpp index ed5ee7edbe..a6065592bd 100644 --- a/docs/examples/Point_add_operator.cpp +++ b/docs/examples/Point_add_operator.cpp @@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); SkVector mod = {1, 1}; for (auto& point : points) { point = point + mod; @@ -20,6 +20,6 @@ void draw(SkCanvas* canvas) { mod.fY += .2f; } paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_addto_operator.cpp b/docs/examples/Point_addto_operator.cpp index 4db6ed1e1d..2ca69fc2e8 100644 --- a/docs/examples/Point_addto_operator.cpp +++ b/docs/examples/Point_addto_operator.cpp @@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); points[1] += {1, 1}; points[2] += {-1, -1}; paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_multiply_operator.cpp b/docs/examples/Point_multiply_operator.cpp index cded6b8005..4963a31be0 100644 --- a/docs/examples/Point_multiply_operator.cpp +++ b/docs/examples/Point_multiply_operator.cpp @@ -12,11 +12,11 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(15, 10); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); for (auto& point : points) { point = point * 1.5f; } paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_multiplyby_operator.cpp b/docs/examples/Point_multiplyby_operator.cpp index e02d8b066a..12631b791c 100644 --- a/docs/examples/Point_multiplyby_operator.cpp +++ b/docs/examples/Point_multiplyby_operator.cpp @@ -12,11 +12,11 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(15, 10); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); for (auto& point : points) { point *= 2; } paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_offset_3.cpp b/docs/examples/Point_offset_3.cpp index 6c3ea100ce..77f720d356 100644 --- a/docs/examples/Point_offset_3.cpp +++ b/docs/examples/Point_offset_3.cpp @@ -12,9 +12,9 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); points[1].offset(1, 1); paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_subtract_operator.cpp b/docs/examples/Point_subtract_operator.cpp index 65c6a28357..ae5783611b 100644 --- a/docs/examples/Point_subtract_operator.cpp +++ b/docs/examples/Point_subtract_operator.cpp @@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); points[1] += points[0] - points[2]; points[2] -= points[3] - points[5]; paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Point_subtractfrom_operator.cpp b/docs/examples/Point_subtractfrom_operator.cpp index 822da86069..85b2ca6244 100644 --- a/docs/examples/Point_subtractfrom_operator.cpp +++ b/docs/examples/Point_subtractfrom_operator.cpp @@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) { { 2, 4 }, { 1, 3 }, { 3, 1 } }; canvas->scale(30, 15); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); points[1] -= {1, 1}; points[2] -= {-1, -1}; paint.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); + canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint); } } // END FIDDLE diff --git a/docs/examples/Quad_b.cpp b/docs/examples/Quad_b.cpp index 2def26498b..89d2b44d96 100644 --- a/docs/examples/Quad_b.cpp +++ b/docs/examples/Quad_b.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { paint.setStyle(SkPaint::kStroke_Style); SkPoint quadPts[] = {{20, 150}, {120, 10}, {220, 150}}; SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; - for (unsigned i = 0; i < SK_ARRAY_COUNT(colors); ++i) { + for (unsigned i = 0; i < std::size(colors); ++i) { paint.setColor(0x7fffffff & colors[i]); paint.setStrokeWidth(1); canvas->drawLine(quadPts[0], quadPts[1], paint); diff --git a/docs/examples/RRect_setRectRadii.cpp b/docs/examples/RRect_setRectRadii.cpp index 86f35c7bca..22c94c8fc1 100644 --- a/docs/examples/RRect_setRectRadii.cpp +++ b/docs/examples/RRect_setRectRadii.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { paint.setAntiAlias(true); float intervals[] = { 5, 21.75f }; paint.setStyle(SkPaint::kStroke_Style); - paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 0)); SkPath path; SkRRect rrect; SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}}; diff --git a/docs/examples/Rect_setBounds.cpp b/docs/examples/Rect_setBounds.cpp index 74aa2d3c6f..dd5f9d821e 100644 --- a/docs/examples/Rect_setBounds.cpp +++ b/docs/examples/Rect_setBounds.cpp @@ -5,7 +5,7 @@ REG_FIDDLE(Rect_setBounds, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; - for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { + for (int count = 0; count <= (int) std::size(points); ++count) { SkRect rect; rect.setBounds(points, count); if (count > 0) { diff --git a/docs/examples/Rect_setBoundsCheck.cpp b/docs/examples/Rect_setBoundsCheck.cpp index 7945caf991..49151ce8be 100644 --- a/docs/examples/Rect_setBoundsCheck.cpp +++ b/docs/examples/Rect_setBoundsCheck.cpp @@ -5,7 +5,7 @@ REG_FIDDLE(Rect_setBoundsCheck, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; - for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { + for (int count = 0; count <= (int) std::size(points); ++count) { SkRect rect; bool success = rect.setBoundsCheck(points, count); if (count > 0) { diff --git a/docs/examples/Rect_setBoundsNoCheck.cpp b/docs/examples/Rect_setBoundsNoCheck.cpp index 247a731178..5303df6cbe 100644 --- a/docs/examples/Rect_setBoundsNoCheck.cpp +++ b/docs/examples/Rect_setBoundsNoCheck.cpp @@ -5,7 +5,7 @@ REG_FIDDLE(Rect_setBoundsNoCheck, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkPoint points[] = {{3, 4}, {1, 2}, {SK_ScalarInfinity, 6}, {SK_ScalarNaN, 8}}; - for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { + for (int count = 0; count <= (int) std::size(points); ++count) { SkRect rect; rect.setBoundsNoCheck(points, count); if (count > 0) { diff --git a/docs/examples/Region_Cliperator_next.cpp b/docs/examples/Region_Cliperator_next.cpp index c621fcd99a..6544b6eb65 100644 --- a/docs/examples/Region_Cliperator_next.cpp +++ b/docs/examples/Region_Cliperator_next.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_Cliperator_next, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkRegion region; SkIRect rects[] = {{1, 2, 3, 4}, {5, 6, 7, 8}}; - region.setRects(rects, SK_ARRAY_COUNT(rects)); + region.setRects(rects, std::size(rects)); SkRegion::Cliperator clipper(region, {0, 3, 8, 7}); do { auto r2 = clipper.rect(); diff --git a/docs/examples/Region_Iterator_next.cpp b/docs/examples/Region_Iterator_next.cpp index 3faba5a61c..db59355706 100644 --- a/docs/examples/Region_Iterator_next.cpp +++ b/docs/examples/Region_Iterator_next.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_Iterator_next, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkRegion region; SkIRect rects[] = {{1, 2, 3, 4}, {5, 6, 7, 8}}; - region.setRects(rects, SK_ARRAY_COUNT(rects)); + region.setRects(rects, std::size(rects)); SkRegion::Iterator iter(region); do { auto r2 = iter.rect(); diff --git a/docs/examples/Region_Iterator_rgn.cpp b/docs/examples/Region_Iterator_rgn.cpp index 81b2933fa6..ab2c3cdcea 100644 --- a/docs/examples/Region_Iterator_rgn.cpp +++ b/docs/examples/Region_Iterator_rgn.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_Iterator_rgn, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkRegion region; SkIRect rects[] = {{1, 2, 3, 4}, {3, 4, 5, 6}}; - region.setRects(rects, SK_ARRAY_COUNT(rects)); + region.setRects(rects, std::size(rects)); SkRegion::Iterator iter(region); auto r = iter.rect(); SkDebugf("rect={%d,%d,%d,%d}\n", r.fLeft, r.fTop, r.fRight, r.fBottom); diff --git a/docs/examples/Region_quickReject_2.cpp b/docs/examples/Region_quickReject_2.cpp index 9d06ae6ea8..42ae1377a2 100644 --- a/docs/examples/Region_quickReject_2.cpp +++ b/docs/examples/Region_quickReject_2.cpp @@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) { SkRegion region({1, 2, 3, 4}); SkRegion test; SkIRect rects[] = {{4, 2, 5, 3}, {7, 2, 8, 3}}; - test.setRects(rects, SK_ARRAY_COUNT(rects)); + test.setRects(rects, std::size(rects)); SkDebugf("quickReject 1: %s\n", region.quickReject(test) ? "true" : "false"); region.op({1, 4, 3, 6}, SkRegion::kUnion_Op); SkDebugf("quickReject 2: %s\n", region.quickReject(test) ? "true" : "false"); diff --git a/docs/examples/Region_setRects.cpp b/docs/examples/Region_setRects.cpp index 2ea73308ab..231523012d 100644 --- a/docs/examples/Region_setRects.cpp +++ b/docs/examples/Region_setRects.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_setRects, 256, 70, false, 0) { void draw(SkCanvas* canvas) { SkIRect rects[] = { {10, 10, 40, 40}, {20, 20, 50, 50}, {30, 30, 60, 60} }; SkRegion region; - region.setRects(rects, SK_ARRAY_COUNT(rects)); + region.setRects(rects, std::size(rects)); canvas->drawRegion(region, SkPaint()); region.setEmpty(); for (auto add : rects) { diff --git a/docs/examples/Region_translate.cpp b/docs/examples/Region_translate.cpp index 000c5bdcec..5afc2f911e 100644 --- a/docs/examples/Region_translate.cpp +++ b/docs/examples/Region_translate.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_translate, 256, 90, false, 0) { void draw(SkCanvas* canvas) { SkRegion test; SkIRect rects[] = {{40, 20, 50, 30}, {70, 40, 80, 50}, { 60, 10, 70, 20}}; - test.setRects(rects, SK_ARRAY_COUNT(rects)); + test.setRects(rects, std::size(rects)); SkPaint paint; for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) { paint.setColor(color); diff --git a/docs/examples/Region_translate_2.cpp b/docs/examples/Region_translate_2.cpp index afa5eb5fb0..15293f65d9 100644 --- a/docs/examples/Region_translate_2.cpp +++ b/docs/examples/Region_translate_2.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(Region_translate_2, 256, 256, false, 0) { void draw(SkCanvas* canvas) { SkRegion test; SkIRect rects[] = {{40, 20, 50, 30}, {70, 40, 80, 50}, { 60, 10, 70, 20}}; - test.setRects(rects, SK_ARRAY_COUNT(rects)); + test.setRects(rects, std::size(rects)); SkPaint paint; for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) { paint.setColor(color); diff --git a/docs/examples/Screen.cpp b/docs/examples/Screen.cpp index 63c04d5c98..8bc21269ac 100644 --- a/docs/examples/Screen.cpp +++ b/docs/examples/Screen.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstATop); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Shader_Methods_a.cpp b/docs/examples/Shader_Methods_a.cpp index 8a2a39c321..5f5bc12adf 100644 --- a/docs/examples/Shader_Methods_a.cpp +++ b/docs/examples/Shader_Methods_a.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { SkScalar radius = 50; const SkColor colors[] = { 0xFFFFFFFF, 0xFF000000 }; paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, - nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + nullptr, std::size(colors), SkTileMode::kClamp)); for (SkScalar a : { 0.3f, 0.6f, 1.0f } ) { paint.setAlpha((int) (a * 255)); canvas->drawCircle(center.fX, center.fY, radius, paint); diff --git a/docs/examples/SmoothBezierSplineInterpolation.cpp b/docs/examples/SmoothBezierSplineInterpolation.cpp index 4486815b63..5dbe700ac1 100644 --- a/docs/examples/SmoothBezierSplineInterpolation.cpp +++ b/docs/examples/SmoothBezierSplineInterpolation.cpp @@ -73,10 +73,10 @@ void draw(SkCanvas* canvas) { {562, 58}, {662, 272}, {762, 99}, {862, 759}, {962, 945}, }; - canvas->drawPath(MakeCubicSplineInterpolation(pts, SK_ARRAY_COUNT(pts)), p); + canvas->drawPath(MakeCubicSplineInterpolation(pts, std::size(pts)), p); p.setStrokeWidth(10); p.setColor(SK_ColorBLACK); - canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(pts), pts, p); + canvas->drawPoints(SkCanvas::kPoints_PointMode, std::size(pts), pts, p); } } // END FIDDLE diff --git a/docs/examples/Soft_Light.cpp b/docs/examples/Soft_Light.cpp index 62c978f7b4..4c20d7fc75 100644 --- a/docs/examples/Soft_Light.cpp +++ b/docs/examples/Soft_Light.cpp @@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) { SkPaint paint; paint.setBlendMode(SkBlendMode::kSoftLight); paint.setShader(SkGradientShader::MakeRadial({ 128, 128}, 100, colors, - nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawImage(image, 0, 0); canvas->drawCircle(128, 128, 100, paint); } diff --git a/docs/examples/Src_Atop.cpp b/docs/examples/Src_Atop.cpp index e88d480476..61a829b793 100644 --- a/docs/examples/Src_Atop.cpp +++ b/docs/examples/Src_Atop.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Src_In.cpp b/docs/examples/Src_In.cpp index c3a290601f..6b1f42079e 100644 --- a/docs/examples/Src_In.cpp +++ b/docs/examples/Src_In.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Src_Out.cpp b/docs/examples/Src_Out.cpp index 772c751823..a4559d39c1 100644 --- a/docs/examples/Src_Out.cpp +++ b/docs/examples/Src_Out.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Src_Over.cpp b/docs/examples/Src_Over.cpp index f320cea486..52ebed5ce6 100644 --- a/docs/examples/Src_Over.cpp +++ b/docs/examples/Src_Over.cpp @@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPaint paint; - paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), + paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawPaint(paint); paint.setBlendMode(SkBlendMode::kDstIn); SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; - paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), + paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, std::size(alphas), SkTileMode::kClamp)); canvas->drawPaint(paint); canvas->clipRect( { 30, 30, 226, 226 } ); diff --git a/docs/examples/Text_Encoding.cpp b/docs/examples/Text_Encoding.cpp index 483c3f2e32..1fcb3935d5 100644 --- a/docs/examples/Text_Encoding.cpp +++ b/docs/examples/Text_Encoding.cpp @@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) { canvas->drawText(hello16, sizeof(hello16), 10, 60, paint); paint.setTextEncoding(SkTextEncoding::kUTF32); canvas->drawText(hello32, sizeof(hello32), 10, 90, paint); - uint16_t glyphs[SK_ARRAY_COUNT(hello32)]; + uint16_t glyphs[std::size(hello32)]; paint.textToGlyphs(hello32, sizeof(hello32), glyphs); paint.setTextEncoding(SkTextEncoding::kGlyphID); canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint); diff --git a/docs/examples/Xor.cpp b/docs/examples/Xor.cpp index 72efa999ff..b3f9edf1d1 100644 --- a/docs/examples/Xor.cpp +++ b/docs/examples/Xor.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128), SkColorSetA(color, 0) }; paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, - colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp)); + colors, nullptr, std::size(colors), SkTileMode::kClamp)); canvas->drawCircle(64, 64, 100, paint); canvas->translate(64, 64); } diff --git a/docs/examples/draw_patch.cpp b/docs/examples/draw_patch.cpp index 97f9a23515..5f7a0fdc58 100644 --- a/docs/examples/draw_patch.cpp +++ b/docs/examples/draw_patch.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { const SkColor colors[] = {SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW}; const SkPoint pts[] = {{100.f / 4.f, 0.f}, {3.f * 100.f / 4.f, 100.f}}; - p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), + p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, std::size(colors), SkTileMode::kMirror)); const SkPoint cubics[] = {{100, 100}, {150, 50}, {250, 150}, {300, 100}, {250, 150}, {350, 250}, {300, 300}, {250, 250}, diff --git a/docs/examples/getLocalBounds_broken.cpp b/docs/examples/getLocalBounds_broken.cpp index 22f86caa43..fc0f6954ac 100644 --- a/docs/examples/getLocalBounds_broken.cpp +++ b/docs/examples/getLocalBounds_broken.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { bounds.fBottom); SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}}; SkPath clipPath; - clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); + clipPath.addPoly(clipPoints, std::size(clipPoints), true); canvas->clipPath(clipPath); bounds = canvas->getLocalClipBounds(); SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight, diff --git a/docs/examples/getLocalBounds_working.cpp b/docs/examples/getLocalBounds_working.cpp index 390700cea8..90cea786f8 100644 --- a/docs/examples/getLocalBounds_working.cpp +++ b/docs/examples/getLocalBounds_working.cpp @@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) { bounds.fBottom); SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}}; SkPath clipPath; - clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); + clipPath.addPoly(clipPoints, std::size(clipPoints), true); canvas->clipPath(clipPath); bounds = canvas->getLocalClipBounds(); SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight, diff --git a/docs/examples/homogeneous.cpp b/docs/examples/homogeneous.cpp index cbf11192ed..c01c4e3561 100644 --- a/docs/examples/homogeneous.cpp +++ b/docs/examples/homogeneous.cpp @@ -6,9 +6,9 @@ void draw(SkCanvas* canvas) { SkPoint3 src[] = {{3, 3, 1}, {8, 2, 2}, {5, 0, 4}, {0, 1, 3}, {3, 7, 1}, {8, 6, 2}, {5, 4, 4}, {0, 5, 3}}; int lines[] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7}; - constexpr int count = SK_ARRAY_COUNT(src); + constexpr int count = std::size(src); auto debugster = [=](SkPoint3 src[]) -> void { - for (size_t i = 0; i < SK_ARRAY_COUNT(lines); i += 2) { + for (size_t i = 0; i < std::size(lines); i += 2) { const SkPoint3& s = src[lines[i]]; const SkPoint3& e = src[lines[i + 1]]; SkPaint paint; diff --git a/docs/examples/picture_shader.cpp b/docs/examples/picture_shader.cpp index ed615e4df9..72fe84034e 100644 --- a/docs/examples/picture_shader.cpp +++ b/docs/examples/picture_shader.cpp @@ -30,7 +30,7 @@ void draw_wheel(SkCanvas* c) { SkMatrix rot; rot.setRotate(90.0f); p.setShader(SkGradientShader::MakeSweep(0, 0, sweep_colors, nullptr, - SK_ARRAY_COUNT(sweep_colors), 0, &rot)); + std::size(sweep_colors), 0, &rot)); p.setStrokeWidth(0.05f * scale); p.setStyle(SkPaint::kStroke_Style); c->drawCircle(0.0f, 0.0f, 0.475f * scale, p); diff --git a/docs/examples/pong2.cpp b/docs/examples/pong2.cpp index 0cf5630b16..ca815f10b3 100644 --- a/docs/examples/pong2.cpp +++ b/docs/examples/pong2.cpp @@ -25,7 +25,7 @@ void draw(SkCanvas* canvas) { const float intervals[] = { 12, 6 }; p.setStrokeWidth(5); - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + p.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 0)); canvas->drawLine({256,0}, {256, 256}, p); } } // END FIDDLE diff --git a/docs/examples/strokerect_gm.cpp b/docs/examples/strokerect_gm.cpp index 604ac6a402..d98a65c5aa 100644 --- a/docs/examples/strokerect_gm.cpp +++ b/docs/examples/strokerect_gm.cpp @@ -25,13 +25,13 @@ void draw(SkCanvas* canvas) { canvas->translate(kStrokeWidth * 3 / 2, kStrokeWidth * 3 / 2); for (int doFill = 0; doFill <= 1; ++doFill) { SkPaint::Style style = doFill ? SkPaint::kStrokeAndFill_Style : SkPaint::kStroke_Style; - for (size_t i = 0; i < SK_ARRAY_COUNT(gJoins); ++i) { + for (size_t i = 0; i < std::size(gJoins); ++i) { SkPaint::Join join = gJoins[i]; - for (size_t j = 0; j < SK_ARRAY_COUNT(gRects); ++j) { + for (size_t j = 0; j < std::size(gRects); ++j) { SkAutoCanvasRestore acr(canvas, true); canvas->translate( j * (W + 2 * kStrokeWidth), - (i + doFill * SK_ARRAY_COUNT(gJoins)) * (H + 2 * kStrokeWidth)); + (i + doFill * std::size(gJoins)) * (H + 2 * kStrokeWidth)); const SkRect& rect = gRects[j]; SkPath path, fillPath;