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

Unified Diff: gm/path_stroke_with_zero_length.cpp

Issue 1374383004: SkPDF: when drawing stroked path, draw using SVG rules for zero-length segments (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-10-06 (Tuesday) 12:31:14 EDT Created 5 years, 2 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 | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/path_stroke_with_zero_length.cpp
diff --git a/gm/path_stroke_with_zero_length.cpp b/gm/path_stroke_with_zero_length.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dc52947da3b2f79bc07ab6c133b4a5461d4015ed
--- /dev/null
+++ b/gm/path_stroke_with_zero_length.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPath.h"
+#include "SkStream.h"
+#include "gm.h"
+
+// Test how short paths are stroked with various caps
+DEF_SIMPLE_GM(path_stroke_with_zero_length, canvas, 240, 120) {
+ SkPath paths[5];
+ paths[0].moveTo(30.0f, 0); // single line segment
+ paths[0].rLineTo(30.0f, 0);
+
+ paths[1].moveTo(90.0f, 0); // single line segment with close
+ paths[1].rLineTo(30.0f, 0);
+ paths[1].close();
+
+ paths[2].moveTo(150.0f, 0); // zero-length line
+ paths[2].rLineTo(0, 0);
+
+ paths[3].moveTo(180.0f, 0); // zero-length line with close
+ paths[3].rLineTo(0, 0);
+ paths[3].close();
+
+ paths[4].moveTo(210.0f, 0); // close only, no line
+ paths[4].close();
+
+ auto drawPaths = [&](const SkPaint& paint) {
+ canvas->translate(0, 30.0f);
+ for (const SkPath& path : paths) {
+ canvas->drawPath(path, paint);
+ }
+ };
+
+ SkAutoCanvasRestore autoCanvasRestore(canvas, true);
+
+ SkPaint butt;
+ butt.setStyle(SkPaint::kStroke_Style);
+ butt.setStrokeWidth(20.0f);
+ butt.setStrokeCap(SkPaint::kButt_Cap);
+ drawPaths(butt);
+
+ SkPaint round(butt);
+ round.setStrokeCap(SkPaint::kRound_Cap);
+ drawPaths(round);
+
+ SkPaint square(butt);
+ square.setStrokeCap(SkPaint::kSquare_Cap);
+ drawPaths(square);
+}
« no previous file with comments | « no previous file | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698