Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: gm/emptypath.cpp

Issue 1311503008: draw 3 moveTos followed by various others [moves, lines, closes] (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/emptypath.cpp
diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp
index 36edf4e50f384b7fedeb3639c19d1cff423f4d74..d1b276157a759b9fa73c208cf5f1ea9672253b1e 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; )
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698