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

Side by Side Diff: gm/arcto.cpp

Issue 1627423002: fix arcto exception handling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/core/SkPath.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BD-style license that can be 4 * Use of this source code is governed by a BD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkParsePath.h" 9 #include "SkParsePath.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 17 matching lines...) Expand all
28 fill="none" stroke="red" stroke-width="5" /> 28 fill="none" stroke="red" stroke-width="5" />
29 29
30 <path d="M250,400 A120,80 0 1,1 250,500" 30 <path d="M250,400 A120,80 0 1,1 250,500"
31 fill="none" stroke="green" stroke-width="5"/> 31 fill="none" stroke="green" stroke-width="5"/>
32 32
33 <path d="M250,400 A120,80 0 1,0 250,500" 33 <path d="M250,400 A120,80 0 1,0 250,500"
34 fill="none" stroke="purple" stroke-width="5"/> 34 fill="none" stroke="purple" stroke-width="5"/>
35 35
36 <path d="M250,400 A120,80 0 0,1 250,500" 36 <path d="M250,400 A120,80 0 0,1 250,500"
37 fill="none" stroke="blue" stroke-width="5"/> 37 fill="none" stroke="blue" stroke-width="5"/>
38
39 <path d="M100,100 A 0, 0 0 0,1 200,200"
40 fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/>
41
42 <path d="M200,100 A 80,80 0 0,1 200,100"
43 fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/>
38 </svg> 44 </svg>
39 */ 45 */
40 46
41 DEF_SIMPLE_GM(arcto, canvas, 500, 600) { 47 DEF_SIMPLE_GM(arcto, canvas, 500, 600) {
42 SkPaint paint; 48 SkPaint paint;
43 paint.setAntiAlias(true); 49 paint.setAntiAlias(true);
44 paint.setStyle(SkPaint::kStroke_Style); 50 paint.setStyle(SkPaint::kStroke_Style);
45 paint.setStrokeWidth(2); 51 paint.setStrokeWidth(2);
46 paint.setColor(0xFF660000); 52 paint.setColor(0xFF660000);
47 canvas->scale(2, 2); 53 // canvas->scale(2, 2); // for testing on retina
48 SkRect oval = SkRect::MakeXYWH(100, 100, 100, 100); 54 SkRect oval = SkRect::MakeXYWH(100, 100, 100, 100);
49 SkPath svgArc; 55 SkPath svgArc;
50 56
51 for (int angle = 0; angle <= 45; angle += 45) { 57 for (int angle = 0; angle <= 45; angle += 45) {
52 for (int oHeight = 2; oHeight >= 1; --oHeight) { 58 for (int oHeight = 2; oHeight >= 1; --oHeight) {
53 SkScalar ovalHeight = oval.height() / oHeight; 59 SkScalar ovalHeight = oval.height() / oHeight;
54 svgArc.moveTo(oval.fLeft, oval.fTop); 60 svgArc.moveTo(oval.fLeft, oval.fTop);
55 svgArc.arcTo(oval.width() / 2, ovalHeight, SkIntToScalar(angle), SkP ath::kSmall_ArcSize, 61 svgArc.arcTo(oval.width() / 2, ovalHeight, SkIntToScalar(angle), SkP ath::kSmall_ArcSize,
56 SkPath::kCW_Direction, oval.right(), oval.bottom()); 62 SkPath::kCW_Direction, oval.right(), oval.bottom());
57 canvas->drawPath(svgArc, paint); 63 canvas->drawPath(svgArc, paint);
(...skipping 18 matching lines...) Expand all
76 "M250,400 A120,80 0 1,1 250,500", 82 "M250,400 A120,80 0 1,1 250,500",
77 "M250,400 A120,80 0 1,0 250,500", 83 "M250,400 A120,80 0 1,0 250,500",
78 "M250,400 A120,80 0 0,1 250,500" 84 "M250,400 A120,80 0 0,1 250,500"
79 }; 85 };
80 int cIndex = 0; 86 int cIndex = 0;
81 for (const char* arcstr : arcstrs) { 87 for (const char* arcstr : arcstrs) {
82 SkParsePath::FromSVGString(arcstr, &svgArc); 88 SkParsePath::FromSVGString(arcstr, &svgArc);
83 paint.setColor(colors[cIndex++]); 89 paint.setColor(colors[cIndex++]);
84 canvas->drawPath(svgArc, paint); 90 canvas->drawPath(svgArc, paint);
85 } 91 }
92
93 // test that zero length arcs still draw round cap
94 paint.setStrokeCap(SkPaint::kRound_Cap);
95 SkPath path;
96 path.moveTo(100, 100);
97 path.arcTo(0, 0, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 200) ;
98 canvas->drawPath(path, paint);
99
100 path.reset();
101 path.moveTo(200, 100);
102 path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 10 0);
103 canvas->drawPath(path, paint);
86 } 104 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698