summaryrefslogtreecommitdiff
path: root/chromium/third_party/skia/gm/circulararcs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/gm/circulararcs.cpp')
-rw-r--r--chromium/third_party/skia/gm/circulararcs.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/chromium/third_party/skia/gm/circulararcs.cpp b/chromium/third_party/skia/gm/circulararcs.cpp
index fbe3fe8d408..13dae6d850a 100644
--- a/chromium/third_party/skia/gm/circulararcs.cpp
+++ b/chromium/third_party/skia/gm/circulararcs.cpp
@@ -20,6 +20,13 @@
#include <functional>
+#include "include/effects/SkStrokeAndFillPathEffect.h"
+static void set_strokeandfill(SkPaint* paint) {
+ SkASSERT(paint->getPathEffect() == nullptr);
+ paint->setPathEffect(SkStrokeAndFillPathEffect::Make());
+ paint->setStroke(true);
+}
+
constexpr SkScalar kStarts[] = {0.f, 10.f, 30.f, 45.f, 90.f, 165.f, 180.f, 270.f};
constexpr SkScalar kSweeps[] = {1.f, 45.f, 90.f, 130.f, 180.f, 184.f, 300.f, 355.f};
constexpr SkScalar kDiameter = 40.f;
@@ -77,13 +84,13 @@ void draw_arcs(SkCanvas* canvas, std::function<void(SkPaint*)> configureStyle) {
#define DEF_ARC_GM(name) DEF_SIMPLE_GM(circular_arcs_##name, canvas, kW, kH)
DEF_ARC_GM(fill) {
- auto setFill = [] (SkPaint*p) { p->setStyle(SkPaint::kFill_Style); };
+ auto setFill = [] (SkPaint*p) { p->setStroke(false); };
draw_arcs(canvas, setFill);
}
DEF_ARC_GM(hairline) {
auto setHairline = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStroke_Style);
+ p->setStroke(true);
p->setStrokeWidth(0.f);
};
draw_arcs(canvas, setHairline);
@@ -91,7 +98,7 @@ DEF_ARC_GM(hairline) {
DEF_ARC_GM(stroke_butt) {
auto setStroke = [](SkPaint* p) {
- p->setStyle(SkPaint::kStroke_Style);
+ p->setStroke(true);
p->setStrokeCap(SkPaint::kButt_Cap);
};
draw_arcs(canvas, setStroke);
@@ -99,7 +106,7 @@ DEF_ARC_GM(stroke_butt) {
DEF_ARC_GM(stroke_square) {
auto setStroke = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStroke_Style);
+ p->setStroke(true);
p->setStrokeCap(SkPaint::kSquare_Cap);
};
draw_arcs(canvas, setStroke);
@@ -107,7 +114,7 @@ DEF_ARC_GM(stroke_square) {
DEF_ARC_GM(stroke_round) {
auto setStroke = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStroke_Style);
+ p->setStroke(true);
p->setStrokeCap(SkPaint::kRound_Cap);
};
draw_arcs(canvas, setStroke);
@@ -115,7 +122,7 @@ DEF_ARC_GM(stroke_round) {
DEF_ARC_GM(stroke_and_fill_butt) {
auto setStroke = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStrokeAndFill_Style);
+ set_strokeandfill(p);
p->setStrokeCap(SkPaint::kButt_Cap);
};
draw_arcs(canvas, setStroke);
@@ -123,7 +130,7 @@ DEF_ARC_GM(stroke_and_fill_butt) {
DEF_ARC_GM(stroke_and_fill_square) {
auto setStroke = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStrokeAndFill_Style);
+ set_strokeandfill(p);
p->setStrokeCap(SkPaint::kSquare_Cap);
};
draw_arcs(canvas, setStroke);
@@ -131,7 +138,7 @@ DEF_ARC_GM(stroke_and_fill_square) {
DEF_ARC_GM(stroke_and_fill_round) {
auto setStroke = [] (SkPaint* p) {
- p->setStyle(SkPaint::kStrokeAndFill_Style);
+ set_strokeandfill(p);
p->setStrokeCap(SkPaint::kRound_Cap);
};
draw_arcs(canvas, setStroke);
@@ -174,16 +181,16 @@ DEF_SIMPLE_GM(circular_arcs_weird, canvas, 1000, 400) {
// fill
paints.push_back();
// stroke
- paints.push_back().setStyle(SkPaint::kStroke_Style);
+ paints.push_back().setStroke(true);
paints.back().setStrokeWidth(kS / 6.f);
// hairline
- paints.push_back().setStyle(SkPaint::kStroke_Style);
+ paints.push_back().setStroke(true);
paints.back().setStrokeWidth(0.f);
// stroke and fill
paints.push_back().setStyle(SkPaint::kStrokeAndFill_Style);
paints.back().setStrokeWidth(kS / 6.f);
// dash effect
- paints.push_back().setStyle(SkPaint::kStroke_Style);
+ paints.push_back().setStroke(true);
paints.back().setStrokeWidth(kS / 6.f);
constexpr SkScalar kDashIntervals[] = {kS / 15, 2 * kS / 15};
paints.back().setPathEffect(SkDashPathEffect::Make(kDashIntervals, 2, 0.f));
@@ -235,7 +242,7 @@ DEF_SIMPLE_GM(onebadarc, canvas, 100, 100) {
SkPaint p0;
p0.setColor(SK_ColorRED);
p0.setStrokeWidth(15.f);
- p0.setStyle(SkPaint::kStroke_Style);
+ p0.setStroke(true);
p0.setAlpha(100);
canvas->translate(20, 0);
canvas->drawPath(path, p0);
@@ -251,7 +258,7 @@ DEF_SIMPLE_GM(crbug_888453, canvas, 480, 150) {
SkPaint fill;
fill.setAntiAlias(true);
SkPaint hairline = fill;
- hairline.setStyle(SkPaint::kStroke_Style);
+ hairline.setStroke(true);
SkPaint stroke = hairline;
stroke.setStrokeWidth(2.0f);
int x = 4;
@@ -323,7 +330,7 @@ DEF_SIMPLE_GM(circular_arc_stroke_matrix, canvas, 820, 1090) {
SkPaint paint;
paint.setStrokeCap(cap);
paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStroke(true);
paint.setStrokeWidth(kStrokeWidth);
canvas->save();
canvas->translate(x * (2*kRadius + kPad), y * (2*kRadius + kPad));