Debian Codegraph @

gm/strokes.cpp

raw
1 /*
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
8 #include "gm/gm.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkColor.h"
11 #include "include/core/SkPaint.h"
12 #include "include/core/SkPath.h"
13 #include "include/core/SkPathBuilder.h"
14 #include "include/core/SkPathEffect.h"
15 #include "include/core/SkPathUtils.h"
16 #include "include/core/SkPoint.h"
17 #include "include/core/SkRect.h"
18 #include "include/core/SkScalar.h"
19 #include "include/core/SkSize.h"
20 #include "include/core/SkString.h"
21 #include "include/core/SkTypes.h"
22 #include "include/effects/SkDashPathEffect.h"
23 #include "include/utils/SkParsePath.h"
24 #include "src/base/SkFloatBits.h"
25 #include "src/base/SkRandom.h"
26 #include "tools/ToolUtils.h"
27
28 #include <string.h>
29
30 #if defined(SK_GRAPHITE)
31 #include "include/gpu/graphite/ContextOptions.h"
32 #endif
33
34 #define W 400
35 #define H 400
36 #define N 50
37
38 constexpr SkScalar SW = SkIntToScalar(W);
39 constexpr SkScalar SH = SkIntToScalar(H);
40
41 static void rnd_rect(SkRect* r, SkPaint* paint, SkRandom& rand) {
42 SkScalar x = rand.nextUScalar1() * W;
43 SkScalar y = rand.nextUScalar1() * H;
44 SkScalar w = rand.nextUScalar1() * (W >> 2);
45 SkScalar h = rand.nextUScalar1() * (H >> 2);
46 SkScalar hoffset = rand.nextSScalar1();
47 SkScalar woffset = rand.nextSScalar1();
48
49 r->setXYWH(x, y, w, h);
50 r->offset(-w/2 + woffset, -h/2 + hoffset);
51
52 paint->setColor(rand.nextU());
53 paint->setAlphaf(1.0f);
54 }
55
56
57 class StrokesGM : public skiagm::GM {
58 public:
59 StrokesGM() {}
60
61 protected:
62 SkString getName() const override { return SkString("strokes_round"); }
63
64 SkISize getISize() override { return SkISize::Make(W, H * 2); }
65
66 #if defined(SK_GRAPHITE)
67 void modifyGraphiteContextOptions(skgpu::graphite::ContextOptions* options) const override {
68 options->fMaxPathAtlasTextureSize = 0;
69 options->fAllowMultipleAtlasTextures = false;
70 }
71 #endif
72
73 void onDraw(SkCanvas* canvas) override {
74 SkPaint paint;
75 paint.setStyle(SkPaint::kStroke_Style);
76 paint.setStrokeWidth(SkIntToScalar(9)/2);
77
78 for (int y = 0; y < 2; y++) {
79 paint.setAntiAlias(!!y);
80 SkAutoCanvasRestore acr(canvas, true);
81 canvas->translate(0, SH * y);
82 canvas->clipRect(SkRect::MakeLTRB(
83 SkIntToScalar(2), SkIntToScalar(2)
84 , SW - SkIntToScalar(2), SH - SkIntToScalar(2)
85 ));
86
87 SkRandom rand;
88 for (int i = 0; i < N; i++) {
89 SkRect r;
90 rnd_rect(&r, &paint, rand);
91 canvas->drawOval(r, paint);
92 rnd_rect(&r, &paint, rand);
93 canvas->drawRoundRect(r, r.width()/4, r.height()/4, paint);
94 rnd_rect(&r, &paint, rand);
95 }
96 }
97 }
98
99 private:
100 using INHERITED = skiagm::GM;
101 };
102
103 /* See
104 https://code.google.com/p/chromium/issues/detail?id=422974 and
105 http://jsfiddle.net/1xnku3sg/2/
106 */
107 class ZeroLenStrokesGM : public skiagm::GM {
108 SkPath fMoveHfPath, fMoveZfPath, fDashedfPath, fRefPath[4];
109 SkPath fCubicPath, fQuadPath, fLinePath;
110 protected:
111 void onOnceBeforeDraw() override {
112 auto parse_assert_result = [](const char str[]) {
113 auto path = SkParsePath::FromSVGString(str);
114 SkAssertResult(path.has_value());
115 return *path;
116 };
117
118 fMoveHfPath = parse_assert_result("M0,0h0M10,0h0M20,0h0");
119 fMoveZfPath = parse_assert_result("M0,0zM10,0zM20,0z");
120 fDashedfPath = parse_assert_result("M0,0h25");
121 fCubicPath = parse_assert_result("M 0 0 C 0 0 0 0 0 0");
122 fQuadPath = parse_assert_result("M 0 0 Q 0 0 0 0");
123 fLinePath = parse_assert_result("M 0 0 L 0 0");
124
125 SkPathBuilder builders[4];
126 for (int i = 0; i < 3; ++i) {
127 builders[0].addCircle(i * 10.f, 0, 5);
128 builders[1].addCircle(i * 10.f, 0, 10);
129 builders[2].addRect({i * 10.f - 4, -2, i * 10.f + 4, 6});
130 builders[3].addRect({i * 10.f - 10, -10, i * 10.f + 10, 10});
131 }
132 for (int i = 0; i < 4; ++i) {
133 fRefPath[i] = builders[i].detach();
134 }
135 }
136
137 SkString getName() const override { return SkString("zeroPath"); }
138
139 SkISize getISize() override { return SkISize::Make(W, H * 2); }
140
141 void onDraw(SkCanvas* canvas) override {
142 SkPaint fillPaint, strokePaint, dashPaint;
143 fillPaint.setAntiAlias(true);
144 strokePaint = fillPaint;
145 strokePaint.setStyle(SkPaint::kStroke_Style);
146 for (int i = 0; i < 2; ++i) {
147 fillPaint.setAlphaf(1.0f);
148 strokePaint.setAlphaf(1.0f);
149 strokePaint.setStrokeWidth(i ? 8.f : 10.f);
150 strokePaint.setStrokeCap(i ? SkPaint::kSquare_Cap : SkPaint::kRound_Cap);
151 canvas->save();
152 canvas->translate(10 + i * 100.f, 10);
153 canvas->drawPath(fMoveHfPath, strokePaint);
154 canvas->translate(0, 20);
155 canvas->drawPath(fMoveZfPath, strokePaint);
156 dashPaint = strokePaint;
157 const SkScalar intervals[] = { 0, 10 };
158 dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 0));
159 (void)skpathutils::FillPathWithPaint(fDashedfPath, dashPaint);
160 canvas->translate(0, 20);
161 canvas->drawPath(fDashedfPath, dashPaint);
162 canvas->translate(0, 20);
163 canvas->drawPath(fRefPath[i * 2], fillPaint);
164 strokePaint.setStrokeWidth(20);
165 strokePaint.setAlphaf(0.5f);
166 canvas->translate(0, 50);
167 canvas->drawPath(fMoveHfPath, strokePaint);
168 canvas->translate(0, 30);
169 canvas->drawPath(fMoveZfPath, strokePaint);
170 canvas->translate(0, 30);
171 fillPaint.setAlphaf(0.5f);
172 canvas->drawPath(fRefPath[1 + i * 2], fillPaint);
173 canvas->translate(0, 30);
174 canvas->drawPath(fCubicPath, strokePaint);
175 canvas->translate(0, 30);
176 canvas->drawPath(fQuadPath, strokePaint);
177 canvas->translate(0, 30);
178 canvas->drawPath(fLinePath, strokePaint);
179 canvas->restore();
180 }
181 }
182
183 private:
184 using INHERITED = skiagm::GM;
185 };
186
187 class TeenyStrokesGM : public skiagm::GM {
188 SkString getName() const override { return SkString("teenyStrokes"); }
189
190 SkISize getISize() override { return SkISize::Make(W, H * 2); }
191
192 static void line(SkScalar scale, SkCanvas* canvas, SkColor color) {
193 SkPaint p;
194 p.setAntiAlias(true);
195 p.setStyle(SkPaint::kStroke_Style);
196 p.setColor(color);
197 canvas->translate(50, 0);
198 canvas->save();
199 p.setStrokeWidth(scale * 5);
200 canvas->scale(1 / scale, 1 / scale);
201 canvas->drawLine(20 * scale, 20 * scale, 20 * scale, 100 * scale, p);
202 canvas->drawLine(20 * scale, 20 * scale, 100 * scale, 100 * scale, p);
203 canvas->restore();
204 }
205
206 void onDraw(SkCanvas* canvas) override {
207 line(0.00005f, canvas, SK_ColorBLACK);
208 line(0.000045f, canvas, SK_ColorRED);
209 line(0.0000035f, canvas, SK_ColorGREEN);
210 line(0.000003f, canvas, SK_ColorBLUE);
211 line(0.000002f, canvas, SK_ColorBLACK);
212 }
213 private:
214 using INHERITED = skiagm::GM;
215 };
216
217 DEF_SIMPLE_GM(CubicStroke, canvas, 384, 384) {
218 SkPaint p;
219 p.setAntiAlias(true);
220 p.setStyle(SkPaint::kStroke_Style);
221 p.setStrokeWidth(1.0720f);
222 SkPath path = SkPathBuilder()
223 .moveTo(-6000,-6000)
224 .cubicTo(-3500,5500,-500,5500,2500,-6500)
225 .detach();
226 canvas->drawPath(path, p);
227 p.setStrokeWidth(1.0721f);
228 canvas->translate(10, 10);
229 canvas->drawPath(path, p);
230 p.setStrokeWidth(1.0722f);
231 canvas->translate(10, 10);
232 canvas->drawPath(path, p);
233 }
234
235 DEF_SIMPLE_GM(zerolinestroke, canvas, 90, 120) {
236 SkPaint paint;
237 paint.setStyle(SkPaint::kStroke_Style);
238 paint.setStrokeWidth(20);
239 paint.setAntiAlias(true);
240 paint.setStrokeCap(SkPaint::kRound_Cap);
241
242 SkPath path = SkPathBuilder()
243 .moveTo(30, 90)
244 .lineTo(30, 90)
245 .lineTo(60, 90)
246 .lineTo(60, 90)
247 .detach();
248 canvas->drawPath(path, paint);
249
250 path = SkPath::Line({30, 30}, {60, 30});
251 canvas->drawPath(path, paint);
252
253 path = SkPathBuilder()
254 .moveTo(30, 60)
255 .lineTo(30, 60)
256 .lineTo(60, 60)
257 .detach();
258 canvas->drawPath(path, paint);
259 }
260
261 DEF_SIMPLE_GM(quadcap, canvas, 200, 200) {
262 SkPaint p;
263 p.setAntiAlias(true);
264 p.setStyle(SkPaint::kStroke_Style);
265 p.setStrokeWidth(0);
266 SkPoint pts[] = {{105.738571f,13.126318f},
267 {105.738571f,13.126318f},
268 {123.753784f,1.f}};
269 SkVector tangent = pts[1] - pts[2];
270 tangent.normalize();
271 SkPoint pts2[3];
272 memcpy(pts2, pts, sizeof(pts));
273 const SkScalar capOutset = SK_ScalarPI / 8;
274 pts2[0].fX += tangent.fX * capOutset;
275 pts2[0].fY += tangent.fY * capOutset;
276 pts2[1].fX += tangent.fX * capOutset;
277 pts2[1].fY += tangent.fY * capOutset;
278 pts2[2].fX += -tangent.fX * capOutset;
279 pts2[2].fY += -tangent.fY * capOutset;
280
281 SkPath path = SkPathBuilder().moveTo(pts2[0]).quadTo(pts2[1], pts2[2]).detach();
282 canvas->drawPath(path, p);
283
284 path = SkPathBuilder().moveTo(pts[0]).quadTo(pts[1], pts[2]).detach();
285 p.setStrokeCap(SkPaint::kRound_Cap);
286 canvas->translate(30, 0);
287 canvas->drawPath(path, p);
288 }
289
290 class Strokes2GM : public skiagm::GM {
291 SkPath fPath;
292 protected:
293 void onOnceBeforeDraw() override {
294 SkRandom rand;
295 SkPathBuilder builder;
296 builder.moveTo(0, 0);
297 for (int i = 0; i < 13; i++) {
298 SkScalar x = rand.nextUScalar1() * (W >> 1);
299 SkScalar y = rand.nextUScalar1() * (H >> 1);
300 builder.lineTo(x, y);
301 }
302 fPath = builder.detach();
303 }
304
305 SkString getName() const override { return SkString("strokes_poly"); }
306
307 SkISize getISize() override { return SkISize::Make(W, H * 2); }
308
309 void onDraw(SkCanvas* canvas) override {
310 canvas->drawColor(SK_ColorWHITE);
311
312 SkPaint paint;
313 paint.setStyle(SkPaint::kStroke_Style);
314 paint.setStrokeWidth(SkIntToScalar(9)/2);
315
316 for (int y = 0; y < 2; y++) {
317 paint.setAntiAlias(!!y);
318 SkAutoCanvasRestore acr(canvas, true);
319 canvas->translate(0, SH * y);
320 canvas->clipRect(SkRect::MakeLTRB(SkIntToScalar(2),
321 SkIntToScalar(2),
322 SW - SkIntToScalar(2),
323 SH - SkIntToScalar(2)));
324
325 SkRandom rand;
326 for (int i = 0; i < N/2; i++) {
327 SkRect r;
328 rnd_rect(&r, &paint, rand);
329 canvas->rotate(SkIntToScalar(15), SW/2, SH/2);
330 canvas->drawPath(fPath, paint);
331 }
332 }
333 }
334
335 private:
336 using INHERITED = skiagm::GM;
337 };
338
339 //////////////////////////////////////////////////////////////////////////////
340
341 static SkRect inset(const SkRect& r) {
342 SkRect rr(r);
343 rr.inset(r.width()/10, r.height()/10);
344 return rr;
345 }
346
347 class Strokes3GM : public skiagm::GM {
348 static SkPath make0(const SkRect& bounds, SkString* title) {
349 title->set("CW CW");
350 return SkPathBuilder()
351 .addRect(bounds, SkPathDirection::kCW)
352 .addRect(inset(bounds), SkPathDirection::kCW)
353 .detach();
354 }
355
356 static SkPath make1(const SkRect& bounds, SkString* title) {
357 title->set("CW CCW");
358 return SkPathBuilder()
359 .addRect(bounds, SkPathDirection::kCW)
360 .addRect(inset(bounds), SkPathDirection::kCCW)
361 .detach();
362 }
363
364 static SkPath make2(const SkRect& bounds, SkString* title) {
365 title->set("CW CW");
366 return SkPathBuilder()
367 .addOval(bounds, SkPathDirection::kCW)
368 .addOval(inset(bounds), SkPathDirection::kCW)
369 .detach();
370 }
371
372 static SkPath make3(const SkRect& bounds, SkString* title) {
373 title->set("CW CCW");
374 return SkPathBuilder()
375 .addOval(bounds, SkPathDirection::kCW)
376 .addOval(inset(bounds), SkPathDirection::kCCW)
377 .detach();
378 }
379
380 static SkPath make4(const SkRect& bounds, SkString* title) {
381 title->set("CW CW");
382
383 SkRect r = bounds;
384 r.inset(bounds.width() / 10, -bounds.height() / 10);
385 return SkPathBuilder()
386 .addRect(bounds, SkPathDirection::kCW)
387 .addOval(r, SkPathDirection::kCW)
388 .detach();
389 }
390
391 static SkPath make5(const SkRect& bounds, SkString* title) {
392 title->set("CW CCW");
393
394 SkRect r = bounds;
395 r.inset(bounds.width() / 10, -bounds.height() / 10);
396 return SkPathBuilder()
397 .addRect(bounds, SkPathDirection::kCW)
398 .addOval(r, SkPathDirection::kCCW)
399 .detach();
400 }
401
402 public:
403 Strokes3GM() {}
404
405 protected:
406 SkString getName() const override { return SkString("strokes3"); }
407
408 SkISize getISize() override { return SkISize::Make(1500, 1500); }
409
410 void onDraw(SkCanvas* canvas) override {
411 SkPaint origPaint;
412 origPaint.setAntiAlias(true);
413 origPaint.setStyle(SkPaint::kStroke_Style);
414 SkPaint fillPaint(origPaint);
415 fillPaint.setColor(SK_ColorRED);
416 SkPaint strokePaint(origPaint);
417 strokePaint.setColor(ToolUtils::color_to_565(0xFF4444FF));
418
419 SkPath (*procs[])(const SkRect&, SkString*) = {
420 make0, make1, make2, make3, make4, make5
421 };
422
423 canvas->translate(SkIntToScalar(20), SkIntToScalar(80));
424
425 SkRect bounds = SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(50));
426 SkScalar dx = bounds.width() * 4/3;
427 SkScalar dy = bounds.height() * 5;
428
429 for (size_t i = 0; i < std::size(procs); ++i) {
430 SkString str;
431 SkPath orig = procs[i](bounds, &str);
432
433 canvas->save();
434 for (int j = 0; j < 13; ++j) {
435 strokePaint.setStrokeWidth(SK_Scalar1 * j * j);
436 canvas->drawPath(orig, strokePaint);
437 canvas->drawPath(orig, origPaint);
438 SkPath fill = skpathutils::FillPathWithPaint(orig, strokePaint);
439 canvas->drawPath(fill, fillPaint);
440 canvas->translate(dx + strokePaint.getStrokeWidth(), 0);
441 }
442 canvas->restore();
443 canvas->translate(0, dy);
444 }
445 }
446
447 private:
448 using INHERITED = skiagm::GM;
449 };
450
451 class Strokes4GM : public skiagm::GM {
452 public:
453 Strokes4GM() {}
454
455 protected:
456 SkString getName() const override { return SkString("strokes_zoomed"); }
457
458 SkISize getISize() override { return SkISize::Make(W, H * 2); }
459
460 void onDraw(SkCanvas* canvas) override {
461 SkPaint paint;
462 paint.setStyle(SkPaint::kStroke_Style);
463 paint.setStrokeWidth(0.055f);
464
465 canvas->scale(1000, 1000);
466 canvas->drawCircle(0, 2, 1.97f, paint);
467 }
468
469 private:
470 using INHERITED = skiagm::GM;
471 };
472
473 // Test stroking for curves that produce degenerate tangents when t is 0 or 1 (skbug.com/40035337)
474 class Strokes5GM : public skiagm::GM {
475 public:
476 Strokes5GM() {}
477
478 protected:
479 SkString getName() const override { return SkString("zero_control_stroke"); }
480
481 SkISize getISize() override { return SkISize::Make(W, H * 2); }
482
483 void onDraw(SkCanvas* canvas) override {
484 SkPaint p;
485 p.setColor(SK_ColorRED);
486 p.setAntiAlias(true);
487 p.setStyle(SkPaint::kStroke_Style);
488 p.setStrokeWidth(40);
489 p.setStrokeCap(SkPaint::kButt_Cap);
490
491 SkPath path = SkPathBuilder()
492 .moveTo(157.474f,111.753f)
493 .cubicTo(128.5f,111.5f,35.5f,29.5f,35.5f,29.5f)
494 .detach();
495 canvas->drawPath(path, p);
496 path = SkPathBuilder()
497 .moveTo(250, 50)
498 .quadTo(280, 80, 280, 80)
499 .detach();
500 canvas->drawPath(path, p);
501 path = SkPathBuilder()
502 .moveTo(150, 50)
503 .conicTo(180, 80, 180, 80, 0.707f)
504 .detach();
505 canvas->drawPath(path, p);
506
507 path = SkPathBuilder()
508 .moveTo(157.474f,311.753f)
509 .cubicTo(157.474f,311.753f,85.5f,229.5f,35.5f,229.5f)
510 .detach();
511 canvas->drawPath(path, p);
512 path = SkPathBuilder()
513 .moveTo(280, 250)
514 .quadTo(280, 250, 310, 280)
515 .detach();
516 canvas->drawPath(path, p);
517 path = SkPathBuilder()
518 .moveTo(180, 250)
519 .conicTo(180, 250, 210, 280, 0.707f)
520 .detach();
521 canvas->drawPath(path, p);
522 }
523
524 private:
525 using INHERITED = skiagm::GM;
526 };
527
528
529 //////////////////////////////////////////////////////////////////////////////
530
531 DEF_GM( return new StrokesGM; )
532 DEF_GM( return new Strokes2GM; )
533 DEF_GM( return new Strokes3GM; )
534 DEF_GM( return new Strokes4GM; )
535 DEF_GM( return new Strokes5GM; )
536
537 DEF_GM( return new ZeroLenStrokesGM; )
538 DEF_GM( return new TeenyStrokesGM; )
539
540 DEF_SIMPLE_GM(zerolinedash, canvas, 256, 256) {
541 canvas->clear(SK_ColorWHITE);
542
543 SkPaint paint;
544 paint.setColor(SkColorSetARGB(255, 0, 0, 0));
545 paint.setStrokeWidth(11);
546 paint.setStrokeCap(SkPaint::kRound_Cap);
547 paint.setStrokeJoin(SkPaint::kBevel_Join);
548
549 SkScalar dash_pattern[] = {1, 5};
550 paint.setPathEffect(SkDashPathEffect::Make(dash_pattern, 0));
551
552 canvas->drawLine(100, 100, 100, 100, paint);
553 }
554
555 #ifdef PDF_IS_FIXED_SO_THIS_DOESNT_BREAK_IT
556 DEF_SIMPLE_GM(longrect_dash, canvas, 250, 250) {
557 canvas->clear(SK_ColorWHITE);
558
559 SkPaint paint;
560 paint.setColor(SkColorSetARGB(255, 0, 0, 0));
561 paint.setStrokeWidth(5);
562 paint.setStrokeCap(SkPaint::kRound_Cap);
563 paint.setStrokeJoin(SkPaint::kBevel_Join);
564 paint.setStyle(SkPaint::kStroke_Style);
565 SkScalar dash_pattern[] = {1, 5};
566 paint.setPathEffect(SkDashPathEffect::Make(dash_pattern, 2, 0));
567 // try all combinations of stretching bounds
568 for (auto left : { 20.f, -100001.f } ) {
569 for (auto top : { 20.f, -100001.f } ) {
570 for (auto right : { 40.f, 100001.f } ) {
571 for (auto bottom : { 40.f, 100001.f } ) {
572 canvas->save();
573 canvas->clipRect({10, 10, 50, 50});
574 canvas->drawRect({left, top, right, bottom}, paint);
575 canvas->restore();
576 canvas->translate(60, 0);
577 }
578 }
579 canvas->translate(-60 * 4, 60);
580 }
581 }
582 }
583 #endif
584
585 DEF_SIMPLE_GM(inner_join_geometry, canvas, 1000, 700) {
586 // These paths trigger cases where we must add inner join geometry.
587 // skbug.com/40043052
588 const SkPoint pathPoints[] = {
589 /*moveTo*/ /*lineTo*/ /*lineTo*/
590 {119, 71}, {129, 151}, {230, 24},
591 {200, 144}, {129, 151}, {230, 24},
592 {192, 176}, {224, 175}, {281, 103},
593 {233, 205}, {224, 175}, {281, 103},
594 {121, 216}, {234, 189}, {195, 147},
595 {141, 216}, {254, 189}, {238, 250},
596 {159, 202}, {269, 197}, {289, 165},
597 {159, 202}, {269, 197}, {287, 227},
598 };
599
600 SkPaint pathPaint;
601 pathPaint.setStroke(true);
602 pathPaint.setAntiAlias(true);
603 pathPaint.setStrokeWidth(100);
604
605 SkPaint skeletonPaint;
606 skeletonPaint.setStroke(true);
607 skeletonPaint.setAntiAlias(true);
608 skeletonPaint.setStrokeWidth(0);
609 skeletonPaint.setColor(SK_ColorRED);
610
611 canvas->translate(0, 50);
612 for (size_t i = 0; i < std::size(pathPoints) / 3; i++) {
613 auto path = SkPath::Polygon({pathPoints + i * 3, 3}, false);
614 canvas->drawPath(path, pathPaint);
615
616 SkPath fillPath = skpathutils::FillPathWithPaint(path, pathPaint);
617 canvas->drawPath(fillPath, skeletonPaint);
618
619 canvas->translate(200, 0);
620 if ((i + 1) % 4 == 0) {
621 canvas->translate(-800, 200);
622 }
623 }
624 }
625
626 DEF_SIMPLE_GM(skbug12244, canvas, 150, 150) {
627 // Should look like a stroked triangle; these vertices are the results of the SkStroker
628 // but we draw as a filled path in order to highlight that it's the GPU triangulating path
629 // renderer that's the source of the problem, and not the stroking operation. The original
630 // path was a simple:
631 // m(0,0), l(100, 40), l(0, 80), l(0,0) with a stroke width of 15px
632 SkPath path = SkPathBuilder()
633 .moveTo(2.7854299545288085938, -6.9635753631591796875)
634 .lineTo( 120.194366455078125, 40)
635 .lineTo(-7.5000004768371582031, 91.07775115966796875)
636 .lineTo(-7.5000004768371582031, -11.077748298645019531)
637 .lineTo(2.7854299545288085938, -6.9635753631591796875)
638 .moveTo(-2.7854299545288085938, 6.9635753631591796875)
639 .lineTo( 0, 0)
640 .lineTo( 7.5, 0)
641 .lineTo(7.5000004768371582031, 68.92224884033203125)
642 .lineTo( 79.805633544921875, 40)
643 .lineTo(-2.7854299545288085938, 6.9635753631591796875)
644 .detach();
645
646 SkPaint p;
647 p.setColor(SK_ColorGREEN);
648
649 canvas->translate(20.f, 20.f);
650 canvas->drawPath(path, p);
651 }
652
653 DEF_SIMPLE_GM(b_340982297, canvas, 80, 50) {
654 SkPaint paint;
655 paint.setAntiAlias(true);
656
657 SkPath path = SkPathBuilder()
658 .moveTo(30.23983f, 48.5674667f)
659 .lineTo(1.30884242f, 45.5222702f)
660 .lineTo(2.97688866f, 29.6749554f)
661 .lineTo(17.4423828f, 31.1975555f)
662 .lineTo(2.94269657f, 30.0452003f)
663 .lineTo(4.38597536f, 11.8849154f)
664 .lineTo(33.3853493f, 14.1896257f)
665 .close()
666 .detach();
667
668 canvas->drawPath(path, paint);
669
670 path = SkPathBuilder()
671 .moveTo(73.3853455f, 4.18963623f)
672 .lineTo(69.995636f, 39.1360626f)
673 .lineTo(42.83145142f, 21.056778f)
674 .lineTo(42.97689819f, 19.6749573f)
675 .lineTo(57.4423828f, 21.1975555f)
676 .lineTo(42.94268799f, 20.0451965f)
677 .lineTo(44.38595581f, 1.88491821f)
678 .close()
679 .detach();
680
681 canvas->drawPath(path, paint);
682 }