aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/emptypath.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-09-04 10:03:26 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-04 10:03:26 -0700
commit58e524c98c1d575d37d7ef55f0e2498192ca880f (patch)
treebef31601b2293574fb6730044504fc5ed155cfb8 /gm/emptypath.cpp
parentf4a6d30044309aceef48ae4926c6cc6f57d06ffa (diff)
draw 3 moveTos followed by various others [moves, lines, closes]
Diffstat (limited to 'gm/emptypath.cpp')
-rw-r--r--gm/emptypath.cpp79
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; )
}