Replace SK_ARRAY_COUNT with std::size() for skia/docs

Change-Id: I9569ba4760546be6302c24658e64cb58c7db86e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/550697
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-06-16 15:03:00 -04:00 committed by SkCQ
parent 4f050c8528
commit 5623d9e36f
101 changed files with 133 additions and 133 deletions

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } }; SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; SkPaint paint;
paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); std::size(gradColors), SkTileMode::kClamp));
SkBitmap bitmap; SkBitmap bitmap;
bitmap.allocPixels(srcInfo); bitmap.allocPixels(srcInfo);
SkCanvas srcCanvas(bitmap); SkCanvas srcCanvas(bitmap);

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
SkPath path; SkPath path;
SkPoint poly[] = {{20, 20}, { 80, 20}, { 80, 80}, {40, 80}, SkPoint poly[] = {{20, 20}, { 80, 20}, { 80, 80}, {40, 80},
{40, 40}, {100, 40}, {100, 100}, {20, 100}}; {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); path.setFillType(SkPathFillType::kWinding);
canvas->save(); canvas->save();
canvas->clipPath(path, SkClipOp::kIntersect); canvas->clipPath(path, SkClipOp::kIntersect);

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
SkRect bounds = SkRect::MakeWH(80, 70); SkRect bounds = SkRect::MakeWH(80, 70);
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); 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)); SkTileMode::kClamp));
canvas->drawOval(bounds , paint); canvas->drawOval(bounds , paint);
} }

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 }; SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint; 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); canvas->drawPaint(paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
for (auto style : { SkPaint::kStroke_Style, SkPaint::kFill_Style } ) { for (auto style : { SkPaint::kStroke_Style, SkPaint::kFill_Style } ) {
paint.setStyle(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->drawRoundRect({10, 10, 60, 40}, radii[i].fX, radii[i].fY, paint);
canvas->translate(0, 60); canvas->translate(0, 60);
} }

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
char alphabet[iterations]; char alphabet[iterations];
SkScalar angle = 0; SkScalar angle = 0;
SkScalar scale = 1; 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 s = SkScalarSin(angle) * scale;
const SkScalar c = SkScalarCos(angle) * scale; const SkScalar c = SkScalarCos(angle) * scale;
transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16); transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16);

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } }; SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } };
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode, 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); canvas->drawVertices(vertices.get(), SkBlendMode::kSrc, paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4, SkTileMode::kClamp)); paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4, SkTileMode::kClamp));
auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode, 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); canvas->drawVertices(vertices, SkBlendMode::kDarken, paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath clipPath; SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); clipPath.addPoly(clipPoints, std::size(clipPoints), true);
canvas->save(); canvas->save();
canvas->clipPath(clipPath); canvas->clipPath(clipPath);
bounds = canvas->getDeviceClipBounds(); bounds = canvas->getDeviceClipBounds();

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath clipPath; SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); clipPath.addPoly(clipPoints, std::size(clipPoints), true);
canvas->clipPath(clipPath); canvas->clipPath(clipPath);
bounds = canvas->getLocalClipBounds(); bounds = canvas->getLocalClipBounds();
SkDebugf("left:%g top:%g right:%g bottom:%g\n", SkDebugf("left:%g top:%g right:%g bottom:%g\n",

View File

@ -7,8 +7,8 @@ void draw(SkCanvas* canvas) {
SkPoint testPoints[] = {{30, 30}, {120, 30}, {120, 129} }; SkPoint testPoints[] = {{30, 30}, {120, 30}, {120, 129} };
SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
SkPath testPath, clipPath; SkPath testPath, clipPath;
testPath.addPoly(testPoints, SK_ARRAY_COUNT(testPoints), true); testPath.addPoly(testPoints, std::size(testPoints), true);
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); clipPath.addPoly(clipPoints, std::size(clipPoints), true);
canvas->save(); canvas->save();
canvas->clipPath(clipPath); canvas->clipPath(clipPath);
SkDebugf("quickReject %s\n", canvas->quickReject(testPath) ? "true" : "false"); SkDebugf("quickReject %s\n", canvas->quickReject(testPath) ? "true" : "false");

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) { for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
SkColor colors[] = { color, SkColorSetA(color, 0) }; SkColor colors[] = { color, SkColorSetA(color, 0) };
paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, 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->drawCircle(64, 64, 100, paint);
canvas->translate(64, 64); canvas->translate(64, 64);
} }

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
SkPoint cubicPts[] = {{20, 150}, {90, 10}, {160, 150}, {230, 10}}; SkPoint cubicPts[] = {{20, 150}, {90, 10}, {160, 150}, {230, 10}};
SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; 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.setColor(0x7fffffff & colors[i]);
paint.setStrokeWidth(1); paint.setStrokeWidth(1);
for (unsigned j = 0; j < 3; ++j) { for (unsigned j = 0; j < 3; ++j) {

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorWHITE, SK_ColorBLACK }; SkColor colors[] = { SK_ColorWHITE, SK_ColorBLACK };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
paint.setBlendMode(SkBlendMode::kDarken); paint.setBlendMode(SkBlendMode::kDarken);
canvas->drawPaint(paint); canvas->drawPaint(paint);

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = {0xFF334455, 0xFF662211 }; SkColor colors[] = {0xFF334455, 0xFF662211 };
SkPaint paint; SkPaint paint;
paint.setShader(SkGradientShader::MakeLinear( paint.setShader(SkGradientShader::MakeLinear(
points, colors, nullptr, SK_ARRAY_COUNT(colors), points, colors, nullptr, std::size(colors),
SkTileMode::kClamp)); SkTileMode::kClamp));
paint.setDither(true); paint.setDither(true);
auto img = bm32.asImage(); auto img = bm32.asImage();

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
SkPaint paint; SkPaint paint;
paint.setBlendMode(SkBlendMode::kHardLight); paint.setBlendMode(SkBlendMode::kHardLight);
paint.setShader(SkGradientShader::MakeRadial({ 128, 128}, 100, colors, 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->clipRect({0, 128, 256, 256});
canvas->drawPaint(paint); canvas->drawPaint(paint);
} }

View File

@ -17,7 +17,7 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15); canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
SkIPoint mod = {4, 1}; SkIPoint mod = {4, 1};
for (auto& point : points) { for (auto& point : points) {
point = point + mod; point = point + mod;
@ -25,6 +25,6 @@ void draw(SkCanvas* canvas) {
mod.fY += 1; mod.fY += 1;
} }
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15); canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
points[1] += {1, 1}; points[1] += {1, 1};
points[2] += {-1, -1}; points[2] += {-1, -1};
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15); 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[1] += points[0] - points[3];
points[2] -= points[1] - points[0]; points[2] -= points[1] - points[0];
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -17,10 +17,10 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15); canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
points[1] -= {1, 1}; points[1] -= {1, 1};
points[2] -= {-1, -1}; points[2] -= {-1, -1};
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint); draw_lines(points, std::size(points), paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
SkPoint gradPoints[] = { { 0, 0 }, { width, 0 } }; SkPoint gradPoints[] = { { 0, 0 }, { width, 0 } };
SkPaint gradPaint; SkPaint gradPaint;
gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); std::size(gradColors), SkTileMode::kClamp));
SkBitmap bitmap; SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType)); bitmap.allocPixels(SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType));
SkCanvas offScreen(bitmap); SkCanvas offScreen(bitmap);

View File

@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } };
SkPaint gradPaint; SkPaint gradPaint;
gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, 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); canvas->drawRect(SkRect::MakeWH(width, height), gradPaint);
drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB());
SkBitmap bitmap; SkBitmap bitmap;

View File

@ -18,7 +18,7 @@ void draw(SkCanvas* canvas) {
SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } }; SkPoint gradPoints[] = { { 0, 0 }, { width, 0 }, { width * 2, 0 }, { width * 3, 0 } };
SkPaint gradPaint; SkPaint gradPaint;
gradPaint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, 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); canvas->drawRect(SkRect::MakeWH(width, height), gradPaint);
drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB()); drawLabel("canvas", canvas->imageInfo().gammaCloseToSRGB());
SkBitmap bitmap; SkBitmap bitmap;

View File

@ -19,7 +19,7 @@ void draw(SkCanvas* canvas) {
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear), SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear),
SkSamplingOptions({1.0f/3, 1.0f/3}), 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]); image->scalePixels(pixmap, samplings[index]);
sk_sp<SkImage> filtered = SkImage::MakeFromRaster(pixmap, nullptr, nullptr); sk_sp<SkImage> filtered = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
canvas->drawImage(filtered, 16 * index, 0); canvas->drawImage(filtered, 16 * index, 0);

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE }; SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
paint.setBlendMode(SkBlendMode::kLighten); paint.setBlendMode(SkBlendMode::kLighten);
canvas->drawPaint(paint); canvas->drawPaint(paint);

View File

@ -7,9 +7,9 @@ void draw(SkCanvas* canvas) {
SkPoint3 src[] = {{3, 3, 1}, {8, 2, 2}, {5, 0, 4}, {0, 1, 3}, 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}}; {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 }; 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 { 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& s = src[lines[i]];
const SkPoint3& e = src[lines[i + 1]]; const SkPoint3& e = src[lines[i + 1]];
SkPaint paint; SkPaint paint;

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
SkVector rScaled[4]; SkVector rScaled[4];
matrix.preScale(1.5f, 2.f); matrix.preScale(1.5f, 2.f);
matrix.mapVectors(rScaled, radii, SK_ARRAY_COUNT(radii)); matrix.mapVectors(rScaled, radii, std::size(radii));
SkRRect rrect; SkRRect rrect;
rrect.setRectRadii({20, 20, 180, 70}, rScaled); rrect.setRectRadii({20, 20, 180, 70}, rScaled);
canvas->drawRRect(rrect, paint); canvas->drawRRect(rrect, paint);

View File

@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
rrect.setRectRadii({20, 20, 180, 70}, radii); rrect.setRectRadii({20, 20, 180, 70}, radii);
canvas->drawRRect(rrect, paint); canvas->drawRRect(rrect, paint);
canvas->translate(0, 60); canvas->translate(0, 60);
matrix.mapVectors(radii, SK_ARRAY_COUNT(radii)); matrix.mapVectors(radii, std::size(radii));
} }
} }
} // END FIDDLE } // END FIDDLE

View File

@ -9,12 +9,12 @@ void draw(SkCanvas* canvas) {
SkMatrix matrix; SkMatrix matrix;
matrix.setRotate(60, 128, 128); matrix.setRotate(60, 128, 128);
SkPoint lines[] = {{50, 50}, {150, 50}, {150, 150}}; 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; SkPoint pt;
matrix.mapXY(lines[i].fX, lines[i].fY, &pt); matrix.mapXY(lines[i].fX, lines[i].fY, &pt);
canvas->drawCircle(pt.fX, pt.fY, 3, paint); canvas->drawCircle(pt.fX, pt.fY, 3, paint);
} }
canvas->concat(matrix); 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 } // END FIDDLE

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE }; const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
const SkPoint horz[] = { { 0, 0 }, { 128, 0 } }; const SkPoint horz[] = { { 0, 0 }, { 128, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
paint.setBlendMode(mode); paint.setBlendMode(mode);
canvas->translate(dx, dy); canvas->translate(dx, dy);

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Paint_move_SkPaint, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPaint paint; SkPaint paint;
float intervals[] = { 5, 5 }; 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)); SkPaint dashed(std::move(paint));
SkDebugf("path effect unique: %s\n", dashed.getPathEffect()->unique() ? "true" : "false"); SkDebugf("path effect unique: %s\n", dashed.getPathEffect()->unique() ? "true" : "false");
} }

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Paint_refPathEffect, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPaint paint1, paint2; SkPaint paint1, paint2;
SkScalar intervals[] = {1, 2}; 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"); SkDebugf("path effect unique: %s\n", paint1.getPathEffect()->unique() ? "true" : "false");
paint2.setPathEffect(paint1.refPathEffect()); paint2.setPathEffect(paint1.refPathEffect());
SkDebugf("path effect unique: %s\n", paint1.getPathEffect()->unique() ? "true" : "false"); SkDebugf("path effect unique: %s\n", paint1.getPathEffect()->unique() ? "true" : "false");

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
for (auto linearText : { false, true } ) { for (auto linearText : { false, true } ) {
paint.setLinearText(linearText); paint.setLinearText(linearText);
SkString width; 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->translate(0, textSize + 4);
canvas->drawString(testStr, 10, 0, paint); canvas->drawString(testStr, 10, 0, paint);
canvas->drawString(width, 128, 0, paint); canvas->drawString(width, 128, 0, paint);

View File

@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
nameValue(kInverseWinding), nameValue(kInverseWinding),
nameValue(kInverseEvenOdd), 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) { if (fills[i].fill != (SkPathFillType) i) {
SkDebugf("fills array order does not match FillType enum order"); SkDebugf("fills array order does not match FillType enum order");
break; break;

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
for (SkScalar x : { 40, 100 } ) { for (SkScalar x : { 40, 100 } ) {
SkPath path; SkPath path;
quad[0].fX = x; quad[0].fX = x;
path.addPoly(quad, SK_ARRAY_COUNT(quad), true); path.addPoly(quad, std::size(quad), true);
canvas->drawPath(path, paint); canvas->drawPath(path, paint);
canvas->drawString(labels[(int) path.getConvexity()], 30, 100, paint); canvas->drawString(labels[(int) path.getConvexity()], 30, 100, paint);
canvas->translate(100, 100); canvas->translate(100, 100);

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
rectPaint.setStyle(SkPaint::kStroke_Style); rectPaint.setStyle(SkPaint::kStroke_Style);
SkPaint arrowPaint(rectPaint); SkPaint arrowPaint(rectPaint);
SkPath arrowPath; SkPath arrowPath;
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); arrowPath.addPoly(arrow, std::size(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 320, 0, arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 320, 0,
SkPath1DPathEffect::kRotate_Style)); SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(16); paint.setStrokeWidth(16);
SkScalar intervals[] = {30, 10}; 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); canvas->drawRoundRect({20, 20, 120, 120}, 20, 20, paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -5,7 +5,7 @@
REG_FIDDLE(Path_IsLineDegenerate, 256, 256, true, 0) { REG_FIDDLE(Path_IsLineDegenerate, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPoint points[] = { {100, 100}, {100.000001f, 100.000001f}, {100.0001f, 100.0001f} }; 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 } ) { for (bool exact : { false, true } ) {
SkDebugf("line from (%1.8g,%1.8g) to (%1.8g,%1.8g) is %s" "degenerate, %s\n", 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, points[i].fX, points[i].fY, points[i + 1].fX, points[i + 1].fY,

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
path.cubicTo(1, 2, 3, 4, 5, 6); path.cubicTo(1, 2, 3, 4, 5, 6);
path.conicTo(0, 0, 0, 0, 2); path.conicTo(0, 0, 0, 0, 2);
uint8_t verbs[7]; 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" }; const char* verbStr[] = { "Move", "Line", "Quad", "Conic", "Cubic", "Close" };
SkDebugf("verb count: %d\nverbs: ", count); SkDebugf("verb count: %d\nverbs: ", count);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
ovalPaint.setStyle(SkPaint::kStroke_Style); ovalPaint.setStyle(SkPaint::kStroke_Style);
SkPaint arrowPaint(ovalPaint); SkPaint arrowPaint(ovalPaint);
SkPath arrowPath; SkPath arrowPath;
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); arrowPath.addPoly(arrow, std::size(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0, arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
SkPath1DPathEffect::kRotate_Style)); SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
const SkPoint points[] = {{20, 20}, {70, 20}, {40, 90}}; const SkPoint points[] = {{20, 20}, {70, 20}, {40, 90}};
for (bool close : { false, true } ) { for (bool close : { false, true } ) {
SkPath path; 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, for (auto style : {SkPaint::kStroke_Style, SkPaint::kFill_Style,
SkPaint::kStrokeAndFill_Style} ) { SkPaint::kStrokeAndFill_Style} ) {
paint.setStyle(style); paint.setStyle(style);

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
paint.setStrokeCap(SkPaint::kSquare_Cap); paint.setStrokeCap(SkPaint::kSquare_Cap);
float intervals[] = { 5, 21.75f }; float intervals[] = { 5, 21.75f };
paint.setStyle(SkPaint::kStroke_Style); 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; SkPath path;
path.addRect({20, 20, 100, 100}, SkPathDirection::kCW); path.addRect({20, 20, 100, 100}, SkPathDirection::kCW);
canvas->drawPath(path, paint); canvas->drawPath(path, paint);

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
rectPaint.setStyle(SkPaint::kStroke_Style); rectPaint.setStyle(SkPaint::kStroke_Style);
SkPaint arrowPaint(rectPaint); SkPaint arrowPaint(rectPaint);
SkPath arrowPath; SkPath arrowPath;
arrowPath.addPoly(arrow, SK_ARRAY_COUNT(arrow), true); arrowPath.addPoly(arrow, std::size(arrow), true);
arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0, arrowPaint.setPathEffect(SkPath1DPathEffect::Make(arrowPath, 176, 0,
SkPath1DPathEffect::kRotate_Style)); SkPath1DPathEffect::kRotate_Style));
for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) { for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
paint.setStrokeCap(SkPaint::kSquare_Cap); paint.setStrokeCap(SkPaint::kSquare_Cap);
float intervals[] = { 5, 21.75f }; float intervals[] = { 5, 21.75f };
paint.setStyle(SkPaint::kStroke_Style); 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 } ) { for (auto direction : { SkPathDirection::kCW, SkPathDirection::kCCW } ) {
SkPath path; SkPath path;
path.addRect(20, 20, 100, 100, direction); path.addRect(20, 20, 100, 100, direction);

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
paint.setStrokeCap(SkPaint::kRound_Cap); paint.setStrokeCap(SkPaint::kRound_Cap);
SkPath path; SkPath path;
const SkPoint points[] = {{20, 20}, {70, 20}, {40, 90}}; 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 (int loop = 0; loop < 2; ++loop) {
for (auto style : {SkPaint::kStroke_Style, SkPaint::kFill_Style, for (auto style : {SkPaint::kStroke_Style, SkPaint::kFill_Style,
SkPaint::kStrokeAndFill_Style} ) { SkPaint::kStrokeAndFill_Style} ) {

View File

@ -13,7 +13,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 };
paint.setStrokeWidth(3); paint.setStrokeWidth(3);
SkScalar weight = 0.5f; 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; SkPath path;
path.moveTo(conicPts[0]); path.moveTo(conicPts[0]);
path.conicTo(conicPts[1], conicPts[2], weight); path.conicTo(conicPts[1], conicPts[2], weight);

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
{ 15, 25, 49, 115 }, { 15, 25, 49, 115 },
{ 13, 27, 51, 113 }, { 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; SkPaint paint;
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);
canvas->drawPath(path, paint); canvas->drawPath(path, paint);

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
for (SkScalar x : { 40, 100 } ) { for (SkScalar x : { 40, 100 } ) {
SkPath path; SkPath path;
quad[0].fX = x; quad[0].fX = x;
path.addPoly(quad, SK_ARRAY_COUNT(quad), true); path.addPoly(quad, std::size(quad), true);
path.setConvexity(SkPath::kConvex_Convexity); path.setConvexity(SkPath::kConvex_Convexity);
canvas->drawPath(path, paint); canvas->drawPath(path, paint);
canvas->drawString(path.isConvex() ? "convex" : "not convex", 30, 100, paint); canvas->drawString(path.isConvex() ? "convex" : "not convex", 30, 100, paint);

View File

@ -24,7 +24,7 @@ void draw(SkCanvas* canvas) {
debugster("lineTo", path); debugster("lineTo", path);
path.reset(); path.reset();
const SkPoint pts[] = { {0, 0}, {0, 80}, {80, 80}, {80, 0}, {40, 0}, {20, 0} }; 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); debugster("addPoly", path);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
SkPoint hash[] = {{58, 28}, {43, 80}, {37, 45}, {85, 45}}; SkPoint hash[] = {{58, 28}, {43, 80}, {37, 45}, {85, 45}};
SkVector offsets[] = {{0, 0}, {17, 0}, {0, 0}, {-5, 17}}; SkVector offsets[] = {{0, 0}, {17, 0}, {0, 0}, {-5, 17}};
unsigned o = 0; 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++) { for (unsigned j = 0; j < 2; o++, j++) {
path.moveTo(hash[i].fX + offsets[o].fX, hash[i].fY + offsets[o].fY); 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); path.lineTo(hash[i + 1].fX + offsets[o].fX, hash[i + 1].fY + offsets[o].fY);

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
SkVector oxo[] = {{25, 25}, {35, 35}, {25, 35}, {35, 25}, SkVector oxo[] = {{25, 25}, {35, 35}, {25, 35}, {35, 25},
{40, 20}, {40, 80}, {60, 20}, {60, 80}, {40, 20}, {40, 80}, {60, 20}, {60, 80},
{20, 40}, {80, 40}, {20, 60}, {80, 60}}; {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.moveTo(oxo[i]);
path.lineTo(oxo[i + 1]); path.lineTo(oxo[i + 1]);
} }

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
SkPoint data[][3] = {{{30,40},{60,60},{90,30}}, {{30,120},{60,100},{90,120}}, 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}}}; {{60,100},{60,40},{70,30}}, {{60,40},{50,20},{70,30}}};
SkPath path; 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.moveTo(data[i][0]);
path.lineTo(data[i][1]); path.lineTo(data[i][1]);
path.lineTo(data[i][2]); path.lineTo(data[i][2]);

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
path.addRect({20, 20, 80, 80}, SkPathDirection::kCW, 2); path.addRect({20, 20, 80, 80}, SkPathDirection::kCW, 2);
path.rMoveTo(25, 2); path.rMoveTo(25, 2);
SkVector arrow[] = {{0, -4}, {-20, 0}, {0, -3}, {-5, 5}, {5, 5}, {0, -3}, {20, 0}}; 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); path.rLineTo(arrow[i].fX, arrow[i].fY);
} }
SkPaint paint; SkPaint paint;

View File

@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } }; SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; SkPaint paint;
paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr, paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
SK_ARRAY_COUNT(gradColors), SkTileMode::kClamp)); std::size(gradColors), SkTileMode::kClamp));
SkBitmap bitmap; SkBitmap bitmap;
bitmap.installPixels(srcPixmap); bitmap.installPixels(srcPixmap);
SkCanvas srcCanvas(bitmap); SkCanvas srcCanvas(bitmap);

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128), SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128),
SkColorSetA(color, 0) }; SkColorSetA(color, 0) };
paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, 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->drawCircle(64, 64, 100, paint);
canvas->translate(64, 64); canvas->translate(64, 64);
} }

View File

@ -12,8 +12,8 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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);
SkPoint::Offset(points, SK_ARRAY_COUNT(points), { 1, 9 } ); SkPoint::Offset(points, std::size(points), { 1, 9 } );
canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -12,8 +12,8 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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);
SkPoint::Offset(points, SK_ARRAY_COUNT(points), 1, 9); SkPoint::Offset(points, std::size(points), 1, 9);
canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(points), points, paint); canvas->drawPoints(SkCanvas::kPolygon_PointMode, std::size(points), points, paint);
} }
} // END FIDDLE } // END FIDDLE

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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}; SkVector mod = {1, 1};
for (auto& point : points) { for (auto& point : points) {
point = point + mod; point = point + mod;
@ -20,6 +20,6 @@ void draw(SkCanvas* canvas) {
mod.fY += .2f; mod.fY += .2f;
} }
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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[1] += {1, 1};
points[2] += {-1, -1}; points[2] += {-1, -1};
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,11 +12,11 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(15, 10); canvas->scale(15, 10);
paint.setStyle(SkPaint::kStroke_Style); 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) { for (auto& point : points) {
point = point * 1.5f; point = point * 1.5f;
} }
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,11 +12,11 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(15, 10); canvas->scale(15, 10);
paint.setStyle(SkPaint::kStroke_Style); 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) { for (auto& point : points) {
point *= 2; point *= 2;
} }
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,9 +12,9 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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); points[1].offset(1, 1);
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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[1] += points[0] - points[2];
points[2] -= points[3] - points[5]; points[2] -= points[3] - points[5];
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -12,10 +12,10 @@ void draw(SkCanvas* canvas) {
{ 2, 4 }, { 1, 3 }, { 3, 1 } }; { 2, 4 }, { 1, 3 }, { 3, 1 } };
canvas->scale(30, 15); canvas->scale(30, 15);
paint.setStyle(SkPaint::kStroke_Style); 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[1] -= {1, 1};
points[2] -= {-1, -1}; points[2] -= {-1, -1};
paint.setColor(SK_ColorRED); 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 } // END FIDDLE

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
SkPoint quadPts[] = {{20, 150}, {120, 10}, {220, 150}}; SkPoint quadPts[] = {{20, 150}, {120, 10}, {220, 150}};
SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 }; 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.setColor(0x7fffffff & colors[i]);
paint.setStrokeWidth(1); paint.setStrokeWidth(1);
canvas->drawLine(quadPts[0], quadPts[1], paint); canvas->drawLine(quadPts[0], quadPts[1], paint);

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
paint.setAntiAlias(true); paint.setAntiAlias(true);
float intervals[] = { 5, 21.75f }; float intervals[] = { 5, 21.75f };
paint.setStyle(SkPaint::kStroke_Style); 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; SkPath path;
SkRRect rrect; SkRRect rrect;
SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}}; SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};

View File

@ -5,7 +5,7 @@
REG_FIDDLE(Rect_setBounds, 256, 256, true, 0) { REG_FIDDLE(Rect_setBounds, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; 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; SkRect rect;
rect.setBounds(points, count); rect.setBounds(points, count);
if (count > 0) { if (count > 0) {

View File

@ -5,7 +5,7 @@
REG_FIDDLE(Rect_setBoundsCheck, 256, 256, true, 0) { REG_FIDDLE(Rect_setBoundsCheck, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; 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; SkRect rect;
bool success = rect.setBoundsCheck(points, count); bool success = rect.setBoundsCheck(points, count);
if (count > 0) { if (count > 0) {

View File

@ -5,7 +5,7 @@
REG_FIDDLE(Rect_setBoundsNoCheck, 256, 256, true, 0) { REG_FIDDLE(Rect_setBoundsNoCheck, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkPoint points[] = {{3, 4}, {1, 2}, {SK_ScalarInfinity, 6}, {SK_ScalarNaN, 8}}; 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; SkRect rect;
rect.setBoundsNoCheck(points, count); rect.setBoundsNoCheck(points, count);
if (count > 0) { if (count > 0) {

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_Cliperator_next, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkRegion region; SkRegion region;
SkIRect rects[] = {{1, 2, 3, 4}, {5, 6, 7, 8}}; 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}); SkRegion::Cliperator clipper(region, {0, 3, 8, 7});
do { do {
auto r2 = clipper.rect(); auto r2 = clipper.rect();

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_Iterator_next, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkRegion region; SkRegion region;
SkIRect rects[] = {{1, 2, 3, 4}, {5, 6, 7, 8}}; 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); SkRegion::Iterator iter(region);
do { do {
auto r2 = iter.rect(); auto r2 = iter.rect();

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_Iterator_rgn, 256, 256, true, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkRegion region; SkRegion region;
SkIRect rects[] = {{1, 2, 3, 4}, {3, 4, 5, 6}}; 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); SkRegion::Iterator iter(region);
auto r = iter.rect(); auto r = iter.rect();
SkDebugf("rect={%d,%d,%d,%d}\n", r.fLeft, r.fTop, r.fRight, r.fBottom); SkDebugf("rect={%d,%d,%d,%d}\n", r.fLeft, r.fTop, r.fRight, r.fBottom);

View File

@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) {
SkRegion region({1, 2, 3, 4}); SkRegion region({1, 2, 3, 4});
SkRegion test; SkRegion test;
SkIRect rects[] = {{4, 2, 5, 3}, {7, 2, 8, 3}}; 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"); SkDebugf("quickReject 1: %s\n", region.quickReject(test) ? "true" : "false");
region.op({1, 4, 3, 6}, SkRegion::kUnion_Op); region.op({1, 4, 3, 6}, SkRegion::kUnion_Op);
SkDebugf("quickReject 2: %s\n", region.quickReject(test) ? "true" : "false"); SkDebugf("quickReject 2: %s\n", region.quickReject(test) ? "true" : "false");

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_setRects, 256, 70, false, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkIRect rects[] = { {10, 10, 40, 40}, {20, 20, 50, 50}, {30, 30, 60, 60} }; SkIRect rects[] = { {10, 10, 40, 40}, {20, 20, 50, 50}, {30, 30, 60, 60} };
SkRegion region; SkRegion region;
region.setRects(rects, SK_ARRAY_COUNT(rects)); region.setRects(rects, std::size(rects));
canvas->drawRegion(region, SkPaint()); canvas->drawRegion(region, SkPaint());
region.setEmpty(); region.setEmpty();
for (auto add : rects) { for (auto add : rects) {

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_translate, 256, 90, false, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkRegion test; SkRegion test;
SkIRect rects[] = {{40, 20, 50, 30}, {70, 40, 80, 50}, { 60, 10, 70, 20}}; 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; SkPaint paint;
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) { for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) {
paint.setColor(color); paint.setColor(color);

View File

@ -6,7 +6,7 @@ REG_FIDDLE(Region_translate_2, 256, 256, false, 0) {
void draw(SkCanvas* canvas) { void draw(SkCanvas* canvas) {
SkRegion test; SkRegion test;
SkIRect rects[] = {{40, 20, 50, 30}, {70, 40, 80, 50}, { 60, 10, 70, 20}}; 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; SkPaint paint;
for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) { for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_ColorMAGENTA } ) {
paint.setColor(color); paint.setColor(color);

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstATop); paint.setBlendMode(SkBlendMode::kDstATop);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
SkScalar radius = 50; SkScalar radius = 50;
const SkColor colors[] = { 0xFFFFFFFF, 0xFF000000 }; const SkColor colors[] = { 0xFFFFFFFF, 0xFF000000 };
paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, 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 } ) { for (SkScalar a : { 0.3f, 0.6f, 1.0f } ) {
paint.setAlpha((int) (a * 255)); paint.setAlpha((int) (a * 255));
canvas->drawCircle(center.fX, center.fY, radius, paint); canvas->drawCircle(center.fX, center.fY, radius, paint);

View File

@ -73,10 +73,10 @@ void draw(SkCanvas* canvas) {
{562, 58}, {662, 272}, {762, 99}, {862, 759}, {962, 945}, {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.setStrokeWidth(10);
p.setColor(SK_ColorBLACK); 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 } // END FIDDLE

View File

@ -8,7 +8,7 @@ void draw(SkCanvas* canvas) {
SkPaint paint; SkPaint paint;
paint.setBlendMode(SkBlendMode::kSoftLight); paint.setBlendMode(SkBlendMode::kSoftLight);
paint.setShader(SkGradientShader::MakeRadial({ 128, 128}, 100, colors, 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->drawImage(image, 0, 0);
canvas->drawCircle(128, 128, 100, paint); canvas->drawCircle(128, 128, 100, paint);
} }

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -7,13 +7,13 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; SkPoint horz[] = { { 0, 0 }, { 256, 0 } };
SkPaint paint; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
paint.setBlendMode(SkBlendMode::kDstIn); paint.setBlendMode(SkBlendMode::kDstIn);
SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT };
SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 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)); SkTileMode::kClamp));
canvas->drawPaint(paint); canvas->drawPaint(paint);
canvas->clipRect( { 30, 30, 226, 226 } ); canvas->clipRect( { 30, 30, 226, 226 } );

View File

@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
canvas->drawText(hello16, sizeof(hello16), 10, 60, paint); canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);
paint.setTextEncoding(SkTextEncoding::kUTF32); paint.setTextEncoding(SkTextEncoding::kUTF32);
canvas->drawText(hello32, sizeof(hello32), 10, 90, paint); 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.textToGlyphs(hello32, sizeof(hello32), glyphs);
paint.setTextEncoding(SkTextEncoding::kGlyphID); paint.setTextEncoding(SkTextEncoding::kGlyphID);
canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint); canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128), SkColor colors[] = { color, SkColorSetA(color, 192), SkColorSetA(color, 128),
SkColorSetA(color, 0) }; SkColorSetA(color, 0) };
paint.setShader(SkGradientShader::MakeRadial({ 64, 64}, 100, 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->drawCircle(64, 64, 100, paint);
canvas->translate(64, 64); canvas->translate(64, 64);
} }

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
const SkColor colors[] = {SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, const SkColor colors[] = {SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE,
SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW}; SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW};
const SkPoint pts[] = {{100.f / 4.f, 0.f}, {3.f * 100.f / 4.f, 100.f}}; 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)); SkTileMode::kMirror));
const SkPoint cubics[] = {{100, 100}, {150, 50}, {250, 150}, {300, 100}, const SkPoint cubics[] = {{100, 100}, {150, 50}, {250, 150}, {300, 100},
{250, 150}, {350, 250}, {300, 300}, {250, 250}, {250, 150}, {350, 250}, {300, 300}, {250, 250},

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
bounds.fBottom); bounds.fBottom);
SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}}; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}};
SkPath clipPath; SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); clipPath.addPoly(clipPoints, std::size(clipPoints), true);
canvas->clipPath(clipPath); canvas->clipPath(clipPath);
bounds = canvas->getLocalClipBounds(); bounds = canvas->getLocalClipBounds();
SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight, SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight,

View File

@ -10,7 +10,7 @@ void draw(SkCanvas* canvas) {
bounds.fBottom); bounds.fBottom);
SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}}; SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}};
SkPath clipPath; SkPath clipPath;
clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true); clipPath.addPoly(clipPoints, std::size(clipPoints), true);
canvas->clipPath(clipPath); canvas->clipPath(clipPath);
bounds = canvas->getLocalClipBounds(); bounds = canvas->getLocalClipBounds();
SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight, SkDebugf("left:%g top:%g right:%g bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight,

View File

@ -6,9 +6,9 @@ void draw(SkCanvas* canvas) {
SkPoint3 src[] = {{3, 3, 1}, {8, 2, 2}, {5, 0, 4}, {0, 1, 3}, 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}}; {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}; 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 { 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& s = src[lines[i]];
const SkPoint3& e = src[lines[i + 1]]; const SkPoint3& e = src[lines[i + 1]];
SkPaint paint; SkPaint paint;

View File

@ -30,7 +30,7 @@ void draw_wheel(SkCanvas* c) {
SkMatrix rot; SkMatrix rot;
rot.setRotate(90.0f); rot.setRotate(90.0f);
p.setShader(SkGradientShader::MakeSweep(0, 0, sweep_colors, nullptr, 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.setStrokeWidth(0.05f * scale);
p.setStyle(SkPaint::kStroke_Style); p.setStyle(SkPaint::kStroke_Style);
c->drawCircle(0.0f, 0.0f, 0.475f * scale, p); c->drawCircle(0.0f, 0.0f, 0.475f * scale, p);

View File

@ -25,7 +25,7 @@ void draw(SkCanvas* canvas) {
const float intervals[] = { 12, 6 }; const float intervals[] = { 12, 6 };
p.setStrokeWidth(5); 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); canvas->drawLine({256,0}, {256, 256}, p);
} }
} // END FIDDLE } // END FIDDLE

Some files were not shown because too many files have changed in this diff Show More