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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkPath.h"
9 #include "SkStream.h"
10 #include "gm.h"
11
12 // Test how short paths are stroked with various caps
13 DEF_SIMPLE_GM(path_stroke_with_zero_length, canvas, 240, 120) {
14 SkPath paths[5];
15 paths[0].moveTo(30.0f, 0); // single line segment
16 paths[0].rLineTo(30.0f, 0);
17
18 paths[1].moveTo(90.0f, 0); // single line segment with close
19 paths[1].rLineTo(30.0f, 0);
20 paths[1].close();
21
22 paths[2].moveTo(150.0f, 0); // zero-length line
23 paths[2].rLineTo(0, 0);
24
25 paths[3].moveTo(180.0f, 0); // zero-length line with close
26 paths[3].rLineTo(0, 0);
27 paths[3].close();
28
29 paths[4].moveTo(210.0f, 0); // close only, no line
30 paths[4].close();
31
32 auto drawPaths = [&](const SkPaint& paint) {
33 canvas->translate(0, 30.0f);
34 for (const SkPath& path : paths) {
35 canvas->drawPath(path, paint);
36 }
37 };
38
39 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
40
41 SkPaint butt;
42 butt.setStyle(SkPaint::kStroke_Style);
43 butt.setStrokeWidth(20.0f);
44 butt.setStrokeCap(SkPaint::kButt_Cap);
45 drawPaths(butt);
46
47 SkPaint round(butt);
48 round.setStrokeCap(SkPaint::kRound_Cap);
49 drawPaths(round);
50
51 SkPaint square(butt);
52 square.setStrokeCap(SkPaint::kSquare_Cap);
53 drawPaths(square);
54 }
OLDNEW
« 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