blob: 095da77edfc56fb1e55e9d51b1775fa6ac50c026 [file] [log] [blame]
reed@google.com63d73742012-01-10 15:33:12 +00001/*
2 * Copyright 2011 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040010#include "include/core/SkColor.h"
11#include "include/core/SkFont.h"
12#include "include/core/SkFontStyle.h"
13#include "include/core/SkPaint.h"
14#include "include/core/SkPath.h"
15#include "include/core/SkRect.h"
16#include "include/core/SkScalar.h"
17#include "include/core/SkString.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050018#include "include/core/SkTypeface.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040019#include "include/core/SkTypes.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050020#include "src/core/SkPathPriv.h"
21#include "src/core/SkTextFormatParams.h"
22#include "tools/ToolUtils.h"
reed@google.com63d73742012-01-10 15:33:12 +000023
caryclarke148ac52015-07-15 14:03:12 -070024/* Generated on a Mac with:
25 * paint.setTypeface(SkTypeface::CreateByName("Papyrus"));
26 * paint.getTextPath("H", 1, 100, 80, &textPath);
27 */
28static SkPath papyrus_hello() {
29 SkPath path;
30 path.moveTo(169.824f, 83.4102f);
31 path.lineTo(167.285f, 85.6074f);
32 path.lineTo(166.504f, 87.2188f);
33 path.lineTo(165.82f, 86.7793f);
34 path.lineTo(165.186f, 87.1211f);
35 path.lineTo(164.6f, 88.1953f);
36 path.lineTo(161.914f, 89.416f);
37 path.lineTo(161.719f, 89.2207f);
38 path.lineTo(160.596f, 88.8789f);
39 path.lineTo(160.498f, 87.6094f);
40 path.lineTo(160.693f, 86.3887f);
41 path.lineTo(161.621f, 84.6797f);
42 path.lineTo(161.279f, 83.2148f);
43 path.lineTo(161.523f, 81.9941f);
44 path.lineTo(162.012f, 79.1133f);
45 path.lineTo(162.695f, 76.623f);
46 path.lineTo(162.305f, 73.4004f);
47 path.lineTo(162.207f, 72.4238f);
48 path.lineTo(163.477f, 71.4961f);
49 path.quadTo(163.525f, 71.0078f, 163.525f, 70.2754f);
50 path.quadTo(163.525f, 68.8594f, 162.793f, 67.1992f);
51 path.lineTo(163.623f, 64.6113f);
52 path.lineTo(162.598f, 63.6836f);
53 path.lineTo(163.184f, 61.0957f);
54 path.lineTo(162.695f, 60.8027f);
55 path.lineTo(162.988f, 52.5996f);
56 path.lineTo(162.402f, 52.1113f);
57 path.lineTo(161.914f, 50.1094f);
58 path.lineTo(161.523f, 50.5f);
59 path.quadTo(160.645f, 50.5f, 160.327f, 50.6465f);
60 path.quadTo(160.01f, 50.793f, 159.424f, 51.4766f);
61 path.lineTo(158.203f, 52.7949f);
62 path.lineTo(156.299f, 52.0137f);
63 path.quadTo(154.346f, 52.5996f, 154.004f, 52.5996f);
64 path.quadTo(154.053f, 52.5996f, 152.783f, 52.4043f);
65 path.quadTo(151.465f, 51.3789f, 150.488f, 51.3789f);
66 path.quadTo(150.342f, 51.3789f, 150.269f, 51.4033f);
67 path.quadTo(150.195f, 51.4277f, 150.098f, 51.4766f);
68 path.lineTo(145.02f, 51.916f);
69 path.lineTo(139.893f, 51.2812f);
70 path.lineTo(135.693f, 51.623f);
71 path.lineTo(133.594f, 51.0859f);
72 path.lineTo(130.42f, 52.0137f);
73 path.lineTo(125.488f, 51.4766f);
74 path.lineTo(124.219f, 51.623f);
75 path.lineTo(122.705f, 50.5f);
76 path.lineTo(122.217f, 51.7207f);
77 path.lineTo(116.211f, 51.623f);
78 path.quadTo(114.99f, 52.7949f, 114.99f, 53.8203f);
79 path.lineTo(115.576f, 57.6777f);
80 path.quadTo(115.723f, 58.2148f, 115.723f, 59.2891f);
81 path.quadTo(115.723f, 60.2656f, 115.186f, 61.1934f);
82 path.lineTo(115.479f, 64.2207f);
83 path.quadTo(114.795f, 64.6602f, 114.648f, 65.0752f);
84 path.quadTo(114.502f, 65.4902f, 114.502f, 66.3203f);
85 path.quadTo(114.893f, 66.9551f, 115.918f, 67.1992f);
86 path.lineTo(116.016f, 69.2988f);
87 path.lineTo(116.016f, 75.6953f);
88 path.lineTo(116.016f, 75.9883f);
89 path.lineTo(116.113f, 77.209f);
90 path.quadTo(116.113f, 77.6484f, 115.479f, 78.0879f);
91 path.lineTo(115.576f, 79.1133f);
92 path.lineTo(116.309f, 82.0918f);
93 path.lineTo(116.406f, 83.1172f);
94 path.quadTo(116.406f, 85.2656f, 114.404f, 86.291f);
95 path.lineTo(111.914f, 87.5117f);
96 path.lineTo(109.717f, 88.7812f);
97 path.lineTo(108.398f, 89.416f);
98 path.lineTo(108.105f, 88.9766f);
99 path.lineTo(107.617f, 88.9766f);
100 path.quadTo(107.08f, 87.9023f, 107.08f, 87.0234f);
101 path.quadTo(107.08f, 85.998f, 107.324f, 85.6074f);
102 path.lineTo(108.398f, 83.1172f);
103 path.lineTo(108.887f, 81.4082f);
104 path.lineTo(109.619f, 81.1152f);
105 path.lineTo(109.717f, 79.5039f);
106 path.lineTo(108.887f, 78.7227f);
107 path.quadTo(109.619f, 77.3555f, 109.619f, 77.1113f);
108 path.quadTo(109.619f, 76.8672f, 108.887f, 75.5977f);
109 path.lineTo(108.789f, 74.7188f);
110 path.lineTo(109.18f, 66.6133f);
111 path.lineTo(108.691f, 64.416f);
112 path.quadTo(108.691f, 63.293f, 109.521f, 62.707f);
113 path.lineTo(110.205f, 62.1211f);
114 path.quadTo(110.449f, 61.877f, 110.596f, 60.998f);
115 path.quadTo(109.082f, 60.4609f, 109.082f, 59.1914f);
116 path.lineTo(109.082f, 58.9961f);
117 path.lineTo(109.424f, 55.2852f);
118 path.lineTo(108.789f, 53.7227f);
119 path.lineTo(108.789f, 48.1074f);
120 path.lineTo(108.594f, 45.3242f);
121 path.lineTo(108.691f, 43.8105f);
122 path.lineTo(107.91f, 43.9082f);
123 path.lineTo(107.715f, 44.1035f);
124 path.lineTo(107.324f, 42.7852f);
125 path.lineTo(107.715f, 43.1758f);
126 path.lineTo(107.91f, 41.3203f);
127 path.quadTo(109.717f, 40.2949f, 109.717f, 39.2207f);
128 path.quadTo(109.717f, 37.707f, 107.715f, 37.4141f);
129 path.lineTo(106.982f, 33.9961f);
130 path.lineTo(106.982f, 33.2148f);
131 path.lineTo(106.689f, 29.3086f);
132 path.lineTo(106.689f, 26.1836f);
133 path.lineTo(107.91f, 25.6953f);
134 path.lineTo(109.521f, 24.5234f);
135 path.lineTo(112.109f, 23.3027f);
136 path.lineTo(114.014f, 22.5215f);
137 path.lineTo(115.479f, 23.1074f);
138 path.quadTo(115.479f, 24.0352f, 116.113f, 25.1094f);
139 path.quadTo(115.381f, 25.8906f, 115.259f, 26.3789f);
140 path.quadTo(115.137f, 26.8672f, 114.99f, 28.8203f);
141 path.lineTo(114.893f, 29.9922f);
142 path.lineTo(115.82f, 33.4102f);
143 path.lineTo(116.016f, 35.4121f);
144 path.lineTo(115.576f, 35.4121f);
145 path.lineTo(114.697f, 37.707f);
146 path.lineTo(115.381f, 38.4883f);
147 path.lineTo(115.186f, 39.5137f);
148 path.lineTo(114.697f, 40.3926f);
149 path.lineTo(114.209f, 41.418f);
150 path.lineTo(114.404f, 42.4922f);
151 path.lineTo(114.795f, 43.3223f);
152 path.quadTo(115.186f, 44.1035f, 115.186f, 46.4961f);
153 path.lineTo(116.309f, 46.7891f);
154 path.lineTo(125, 47.2773f);
155 path.lineTo(126.318f, 48.2051f);
156 path.lineTo(129.59f, 48.5957f);
157 path.lineTo(130.615f, 48.498f);
158 path.lineTo(130.908f, 48.0098f);
159 path.lineTo(134.277f, 48.2051f);
160 path.lineTo(134.717f, 48.3027f);
161 path.quadTo(135.4f, 47.7168f, 136.084f, 47.7168f);
162 path.lineTo(137.109f, 47.8145f);
163 path.lineTo(137.109f, 48.2051f);
164 path.lineTo(137.695f, 48.5957f);
165 path.lineTo(138.818f, 48.498f);
166 path.lineTo(144.189f, 48.4004f);
167 path.lineTo(146.191f, 48.2051f);
168 path.lineTo(147.998f, 48.791f);
169 path.quadTo(148.877f, 47.5215f, 150.098f, 47.5215f);
170 path.lineTo(150.293f, 47.5215f);
171 path.lineTo(152.783f, 47.7168f);
172 path.lineTo(157.52f, 47.2773f);
173 path.lineTo(160.303f, 47.4238f);
174 path.lineTo(161.279f, 47.1797f);
175 path.lineTo(161.621f, 46.1055f);
176 path.lineTo(162.5f, 43.9082f);
177 path.lineTo(162.305f, 38.293f);
178 path.lineTo(162.5f, 37.1211f);
179 path.lineTo(161.816f, 35.998f);
180 path.lineTo(160.596f, 34.7773f);
181 path.lineTo(160.596f, 32.6777f);
182 path.lineTo(160.303f, 30.4805f);
183 path.lineTo(160.889f, 29.4062f);
184 path.quadTo(160.303f, 27.4043f, 160.303f, 26.2812f);
185 path.quadTo(160.303f, 25.3535f, 160.889f, 25.207f);
186 path.lineTo(162.207f, 25.0117f);
187 path.lineTo(163.721f, 23.8887f);
188 path.lineTo(164.893f, 23.8887f);
189 path.quadTo(165.625f, 23.6934f, 166.797f, 22.5215f);
190 path.lineTo(168.213f, 23.2051f);
191 path.lineTo(168.701f, 25.5f);
192 path.lineTo(169.092f, 26.8184f);
193 path.lineTo(167.676f, 31.9941f);
194 path.lineTo(168.018f, 34.6797f);
195 path.lineTo(167.822f, 35.8027f);
196 path.lineTo(167.285f, 35.8027f);
197 path.quadTo(166.602f, 35.8027f, 166.602f, 36.7793f);
198 path.quadTo(166.846f, 37.3652f, 167.578f, 37.707f);
199 path.lineTo(168.506f, 38.1953f);
200 path.lineTo(168.799f, 39.5137f);
201 path.lineTo(169.092f, 41.5156f);
202 path.lineTo(168.994f, 42.1016f);
203 path.lineTo(168.213f, 43.6152f);
204 path.lineTo(168.408f, 52.502f);
205 path.lineTo(168.213f, 60.1191f);
206 path.lineTo(168.994f, 61.291f);
207 path.quadTo(168.604f, 63.0488f, 168.604f, 63.9766f);
208 path.lineTo(168.604f, 64.123f);
209 path.lineTo(168.604f, 64.3184f);
210 path.lineTo(168.604f, 64.9043f);
211 path.lineTo(168.604f, 66.0762f);
212 path.quadTo(167.578f, 67.1504f, 167.578f, 67.5898f);
213 path.quadTo(167.578f, 67.7852f, 167.676f, 67.7852f);
214 path.lineTo(168.994f, 70.0801f);
215 path.lineTo(168.701f, 76.7207f);
216 path.lineTo(169.824f, 83.4102f);
217 path.close();
218 return path;
219}
220
221/* Generated on a Mac with:
222 * paint.setTypeface(SkTypeface::CreateByName("Hiragino Maru Gothic Pro"));
223 * const unsigned char hyphen[] = { 0xE3, 0x83, 0xBC };
224 * paint.getTextPath(hyphen, SK_ARRAY_COUNT(hyphen), 400, 80, &textPath);
225 */
226static SkPath hiragino_maru_gothic_pro_dash() {
227 SkPath path;
228 path.moveTo(488, 55.1f);
229 path.cubicTo(490.5f, 55.1f, 491.9f, 53.5f, 491.9f, 50.8f);
230 path.cubicTo(491.9f, 48.2f, 490.5f, 46.3f, 487.9f, 46.3f);
231 path.lineTo(412, 46.3f);
232 path.cubicTo(409.4f, 46.3f, 408, 48.2f, 408, 50.8f);
233 path.cubicTo(408, 53.5f, 409.4f, 55.1f, 411.9f, 55.1f);
234 path.lineTo(488, 55.1f);
235 path.close();
236 return path;
237}
238
Hal Canarydf2d27e2019-01-08 09:38:02 -0500239static void show_bold(SkCanvas* canvas, const char* text,
240 SkScalar x, SkScalar y, const SkPaint& paint, const SkFont& font) {
241 canvas->drawString(text, x, y, font, paint);
242 SkFont f(font);
243 f.setEmbolden(true);
244 canvas->drawString(text, x, y + 120, f, paint);
halcanary2a243382015-09-09 08:16:41 -0700245}
246
Hal Canarydf2d27e2019-01-08 09:38:02 -0500247static void path_bold(SkCanvas* canvas, const SkPath& path,
248 const SkPaint& paint, float textSize) {
caryclarke148ac52015-07-15 14:03:12 -0700249 SkPaint p(paint);
250 canvas->drawPath(path, p);
251 p.setStyle(SkPaint::kStrokeAndFill_Style);
Hal Canarydf2d27e2019-01-08 09:38:02 -0500252 SkScalar fakeBoldScale = SkScalarInterpFunc(textSize,
caryclarke148ac52015-07-15 14:03:12 -0700253 kStdFakeBoldInterpKeys, kStdFakeBoldInterpValues,
254 kStdFakeBoldInterpLength);
Hal Canarydf2d27e2019-01-08 09:38:02 -0500255 SkScalar extra = textSize * fakeBoldScale;
caryclarke148ac52015-07-15 14:03:12 -0700256 p.setStrokeWidth(extra);
257 canvas->save();
258 canvas->translate(0, 120);
259 canvas->drawPath(path, p);
260 canvas->restore();
halcanary2a243382015-09-09 08:16:41 -0700261}
262
263DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
264 SkString("stroke-fill")) {
reed@google.com188bfcf2012-01-17 18:26:38 +0000265 SkScalar x = SkIntToScalar(100);
266 SkScalar y = SkIntToScalar(88);
267
Hal Canarydf2d27e2019-01-08 09:38:02 -0500268 // use the portable typeface to generically test the fake bold code everywhere
269 // (as long as the freetype option to do the bolding itself isn't enabled)
Mike Kleinea3f0142019-03-20 11:12:10 -0500270 SkFont font(ToolUtils::create_portable_typeface("serif", SkFontStyle()), 100);
reed@google.comd1ab9322012-01-10 18:40:03 +0000271 SkPaint paint;
reed@google.comd1ab9322012-01-10 18:40:03 +0000272 paint.setAntiAlias(true);
reed@google.comb435bd72012-01-10 19:28:01 +0000273 paint.setStrokeWidth(SkIntToScalar(5));
halcanary9d524f22016-03-29 09:03:52 -0700274
caryclarke148ac52015-07-15 14:03:12 -0700275 // use paths instead of text to test the path data on all platforms, since the
276 // Mac-specific font may change or is not available everywhere
Hal Canarydf2d27e2019-01-08 09:38:02 -0500277 path_bold(canvas, papyrus_hello(), paint, font.getSize());
278 path_bold(canvas, hiragino_maru_gothic_pro_dash(), paint, font.getSize());
halcanary9d524f22016-03-29 09:03:52 -0700279
Hal Canarydf2d27e2019-01-08 09:38:02 -0500280 show_bold(canvas, "Hi There", x + SkIntToScalar(430), y, paint, font);
reed@google.com188bfcf2012-01-17 18:26:38 +0000281
282 paint.setStyle(SkPaint::kStrokeAndFill_Style);
283
reed@google.comd1ab9322012-01-10 18:40:03 +0000284 SkPath path;
Mike Reed7d34dc72019-11-26 12:17:17 -0500285 path.setFillType(SkPathFillType::kWinding);
Mike Reed30bc5272019-11-22 18:34:02 +0000286 path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW);
287 path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(40), SkPathDirection::kCCW);
reed@google.comd1ab9322012-01-10 18:40:03 +0000288 canvas->drawPath(path, paint);
rmistry@google.comae933ce2012-08-23 18:19:56 +0000289
reed@google.comd1ab9322012-01-10 18:40:03 +0000290 SkPath path2;
Mike Reed7d34dc72019-11-26 12:17:17 -0500291 path2.setFillType(SkPathFillType::kWinding);
Mike Reed30bc5272019-11-22 18:34:02 +0000292 path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW);
293 path2.addCircle(x + SkIntToScalar(120), y + SkIntToScalar(200), SkIntToScalar(40), SkPathDirection::kCW);
reed@google.comd1ab9322012-01-10 18:40:03 +0000294 canvas->drawPath(path2, paint);
rmistry@google.comae933ce2012-08-23 18:19:56 +0000295
reed@google.comd1ab9322012-01-10 18:40:03 +0000296 path2.reset();
Mike Reed30bc5272019-11-22 18:34:02 +0000297 path2.addCircle(x + SkIntToScalar(240), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCCW);
reed@google.comd1ab9322012-01-10 18:40:03 +0000298 canvas->drawPath(path2, paint);
reed026beb52015-06-10 14:23:15 -0700299 SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCCW_FirstDirection));
rmistry@google.comae933ce2012-08-23 18:19:56 +0000300
reed@google.comd1ab9322012-01-10 18:40:03 +0000301 path2.reset();
halcanary96fcdcc2015-08-27 07:41:13 -0700302 SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path2, nullptr));
Mike Reed30bc5272019-11-22 18:34:02 +0000303 path2.addCircle(x + SkIntToScalar(360), y + SkIntToScalar(200), SkIntToScalar(50), SkPathDirection::kCW);
reed026beb52015-06-10 14:23:15 -0700304 SkASSERT(SkPathPriv::CheapIsFirstDirection(path2, SkPathPriv::kCW_FirstDirection));
reed@google.comd1ab9322012-01-10 18:40:03 +0000305 canvas->drawPath(path2, paint);
robertphillips4f662e62014-12-29 14:06:51 -0800306
307 SkRect r = SkRect::MakeXYWH(x - SkIntToScalar(50), y + SkIntToScalar(280),
308 SkIntToScalar(100), SkIntToScalar(100));
309 SkPath path3;
Mike Reed7d34dc72019-11-26 12:17:17 -0500310 path3.setFillType(SkPathFillType::kWinding);
Mike Reed30bc5272019-11-22 18:34:02 +0000311 path3.addRect(r, SkPathDirection::kCW);
robertphillips4f662e62014-12-29 14:06:51 -0800312 r.inset(SkIntToScalar(10), SkIntToScalar(10));
Mike Reed30bc5272019-11-22 18:34:02 +0000313 path3.addRect(r, SkPathDirection::kCCW);
robertphillips4f662e62014-12-29 14:06:51 -0800314 canvas->drawPath(path3, paint);
315
halcanary9d524f22016-03-29 09:03:52 -0700316 r = SkRect::MakeXYWH(x + SkIntToScalar(70), y + SkIntToScalar(280),
robertphillips4f662e62014-12-29 14:06:51 -0800317 SkIntToScalar(100), SkIntToScalar(100));
318 SkPath path4;
Mike Reed7d34dc72019-11-26 12:17:17 -0500319 path4.setFillType(SkPathFillType::kWinding);
Mike Reed30bc5272019-11-22 18:34:02 +0000320 path4.addRect(r, SkPathDirection::kCCW);
robertphillips4f662e62014-12-29 14:06:51 -0800321 r.inset(SkIntToScalar(10), SkIntToScalar(10));
Mike Reed30bc5272019-11-22 18:34:02 +0000322 path4.addRect(r, SkPathDirection::kCW);
robertphillips4f662e62014-12-29 14:06:51 -0800323 canvas->drawPath(path4, paint);
324
halcanary9d524f22016-03-29 09:03:52 -0700325 r = SkRect::MakeXYWH(x + SkIntToScalar(190), y + SkIntToScalar(280),
robertphillips4f662e62014-12-29 14:06:51 -0800326 SkIntToScalar(100), SkIntToScalar(100));
327 path4.reset();
halcanary96fcdcc2015-08-27 07:41:13 -0700328 SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
Mike Reed30bc5272019-11-22 18:34:02 +0000329 path4.addRect(r, SkPathDirection::kCCW);
reed026beb52015-06-10 14:23:15 -0700330 SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCCW_FirstDirection));
robertphillips4f662e62014-12-29 14:06:51 -0800331 path4.moveTo(0, 0); // test for crbug.com/247770
332 canvas->drawPath(path4, paint);
333
halcanary9d524f22016-03-29 09:03:52 -0700334 r = SkRect::MakeXYWH(x + SkIntToScalar(310), y + SkIntToScalar(280),
robertphillips4f662e62014-12-29 14:06:51 -0800335 SkIntToScalar(100), SkIntToScalar(100));
336 path4.reset();
halcanary96fcdcc2015-08-27 07:41:13 -0700337 SkASSERT(!SkPathPriv::CheapComputeFirstDirection(path4, nullptr));
Mike Reed30bc5272019-11-22 18:34:02 +0000338 path4.addRect(r, SkPathDirection::kCW);
reed026beb52015-06-10 14:23:15 -0700339 SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCW_FirstDirection));
robertphillips4f662e62014-12-29 14:06:51 -0800340 path4.moveTo(0, 0); // test for crbug.com/247770
341 canvas->drawPath(path4, paint);
reed@google.com63d73742012-01-10 15:33:12 +0000342}
caryclark52b64612016-02-05 13:59:31 -0800343
344DEF_SIMPLE_GM(bug339297, canvas, 640, 480) {
345 SkPath path;
346 path.moveTo(-469515, -10354890);
347 path.cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664);
348 path.lineTo(3195550, -9860655);
349 path.lineTo(3195539, -9860652);
350 path.lineTo(3195539, -9860652);
351 path.lineTo(3195539, -9860652);
352 path.cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877);
353 path.lineTo(-469515, -10354890);
354 path.close();
355
356 canvas->translate(258, 10365663);
357
358 SkPaint paint;
359 paint.setAntiAlias(true);
360 paint.setColor(SK_ColorBLACK);
361 paint.setStyle(SkPaint::kFill_Style);
362 canvas->drawPath(path, paint);
363
364 paint.setColor(SK_ColorRED);
365 paint.setStyle(SkPaint::kStroke_Style);
366 paint.setStrokeWidth(1);
367 canvas->drawPath(path, paint);
368}
Stephen White2cee2832017-08-23 09:37:16 -0400369
Chris Daltona32a3c32017-12-05 10:05:21 -0700370DEF_SIMPLE_GM(bug339297_as_clip, canvas, 640, 480) {
371 SkPath path;
372 path.moveTo(-469515, -10354890);
373 path.cubicTo(771919.62f, -10411179, 2013360.1f, -10243774, 3195542.8f, -9860664);
374 path.lineTo(3195550, -9860655);
375 path.lineTo(3195539, -9860652);
376 path.lineTo(3195539, -9860652);
377 path.lineTo(3195539, -9860652);
378 path.cubicTo(2013358.1f, -10243761, 771919.25f, -10411166, -469513.84f, -10354877);
379 path.lineTo(-469515, -10354890);
380 path.close();
381
382 canvas->translate(258, 10365663);
383
384 canvas->save();
385 canvas->clipPath(path, true);
386 canvas->clear(SK_ColorBLACK);
387 canvas->restore();
388
389 SkPaint paint;
390 paint.setAntiAlias(true);
391 paint.setStyle(SkPaint::kFill_Style);
392 paint.setColor(SK_ColorRED);
393 paint.setStyle(SkPaint::kStroke_Style);
394 paint.setStrokeWidth(1);
395 canvas->drawPath(path, paint);
396}
397
Stephen White2cee2832017-08-23 09:37:16 -0400398DEF_SIMPLE_GM(bug6987, canvas, 200, 200) {
399 SkPaint paint;
400 paint.setStyle(SkPaint::kStroke_Style);
401 paint.setStrokeWidth(0.0001f);
402 paint.setAntiAlias(true);
403 SkPath path;
404 canvas->save();
405 canvas->scale(50000.0f, 50000.0f);
406 path.moveTo(0.0005f, 0.0004f);
407 path.lineTo(0.0008f, 0.0010f);
408 path.lineTo(0.0002f, 0.0010f);
409 path.close();
410 canvas->drawPath(path, paint);
411 canvas->restore();
412}