diff options
author | reed <reed@google.com> | 2015-09-04 10:03:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-04 10:03:26 -0700 |
commit | 58e524c98c1d575d37d7ef55f0e2498192ca880f (patch) | |
tree | bef31601b2293574fb6730044504fc5ed155cfb8 /gm/emptypath.cpp | |
parent | f4a6d30044309aceef48ae4926c6cc6f57d06ffa (diff) |
draw 3 moveTos followed by various others [moves, lines, closes]
BUG=skia:
Review URL: https://codereview.chromium.org/1311503008
Diffstat (limited to 'gm/emptypath.cpp')
-rw-r--r-- | gm/emptypath.cpp | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp index 36edf4e50f..d1b276157a 100644 --- a/gm/emptypath.cpp +++ b/gm/emptypath.cpp @@ -126,10 +126,85 @@ protected: private: typedef GM INHERITED; }; +DEF_GM( return new EmptyPathGM; ) ////////////////////////////////////////////////////////////////////////////// -static GM* MyFactory(void*) { return new EmptyPathGM; } -static GMRegistry reg(MyFactory); +static void make_path_move(SkPath* path, const SkPoint pts[3]) { + for (int i = 0; i < 3; ++i) { + path->moveTo(pts[i]); + } +} + +static void make_path_move_close(SkPath* path, const SkPoint pts[3]) { + for (int i = 0; i < 3; ++i) { + path->moveTo(pts[i]); + path->close(); + } +} + +static void make_path_move_line(SkPath* path, const SkPoint pts[3]) { + for (int i = 0; i < 3; ++i) { + path->moveTo(pts[i]); + path->lineTo(pts[i]); + } +} + +typedef void (*MakePathProc)(SkPath*, const SkPoint pts[3]); + +static void make_path_move_mix(SkPath* path, const SkPoint pts[3]) { + path->moveTo(pts[0]); + path->moveTo(pts[1]); path->close(); + path->moveTo(pts[2]); path->lineTo(pts[2]); +} + +class EmptyStrokeGM : public GM { + SkPoint fPts[3]; + +public: + EmptyStrokeGM() { + fPts[0].set(40, 40); + fPts[1].set(80, 40); + fPts[2].set(120, 40); + } + +protected: + SkString onShortName() { + return SkString("emptystroke"); + } + + SkISize onISize() override { return SkISize::Make(200, 240); } + + void onDraw(SkCanvas* canvas) override { + const MakePathProc procs[] = { + make_path_move, // expect red red red + make_path_move_close, // expect black black black + make_path_move_line, // expect black black black + make_path_move_mix, // expect red black black, + }; + + SkPaint strokePaint; + strokePaint.setStyle(SkPaint::kStroke_Style); + strokePaint.setStrokeWidth(21); + strokePaint.setStrokeCap(SkPaint::kSquare_Cap); + + SkPaint dotPaint; + dotPaint.setColor(SK_ColorRED); + strokePaint.setStyle(SkPaint::kStroke_Style); + dotPaint.setStrokeWidth(7); + + for (size_t i = 0; i < SK_ARRAY_COUNT(procs); ++i) { + SkPath path; + procs[i](&path, fPts); + canvas->drawPoints(SkCanvas::kPoints_PointMode, 3, fPts, dotPaint); + canvas->drawPath(path, strokePaint); + canvas->translate(0, 40); + } + } + +private: + typedef GM INHERITED; +}; +DEF_GM( return new EmptyStrokeGM; ) } |