Debian Codegraph @

gm/pathfill.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/SkPathUtils.h"
15 #include "include/core/SkRRect.h"
16 #include "include/core/SkRect.h"
17 #include "include/core/SkScalar.h"
18 #include "include/core/SkSize.h"
19 #include "include/core/SkString.h"
20 #include "include/core/SkTypes.h"
21
22 namespace {
23 struct PathDY {
24 SkPath path;
25 SkScalar dy;
26 };
27 }
28
29 typedef PathDY (*MakePathProc)();
30
31 static PathDY make_frame() {
32 SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
33 SkIntToScalar(630), SkIntToScalar(470) };
34 SkPath path = SkPath::RRect(SkRRect::MakeRectXY(r, 15, 15));
35 SkPaint paint;
36 paint.setStyle(SkPaint::kStroke_Style);
37 paint.setStrokeWidth(SkIntToScalar(5));
38 return {skpathutils::FillPathWithPaint(path, paint), 15};
39 }
40
41 static PathDY make_triangle() {
42 constexpr int gCoord[] = {
43 10, 20, 15, 5, 30, 30
44 };
45 return {
46 SkPathBuilder().moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1]))
47 .lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3]))
48 .lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5]))
49 .close()
50 .offset(10, 0)
51 .detach(),
52 30
53 };
54 }
55
56 static PathDY make_rect() {
57 SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
58 SkIntToScalar(30), SkIntToScalar(30) };
59 return {
60 SkPathBuilder().addRect(r).offset(10, 0).detach(),
61 30
62 };
63 }
64
65 static PathDY make_oval() {
66 SkRect r = { SkIntToScalar(10), SkIntToScalar(10),
67 SkIntToScalar(30), SkIntToScalar(30) };
68 return {
69 SkPathBuilder().addOval(r).offset(10, 0).detach(),
70 30
71 };
72 }
73
74 static PathDY make_sawtooth(int teeth) {
75 SkScalar x = SkIntToScalar(20);
76 SkScalar y = SkIntToScalar(20);
77 const SkScalar x0 = x;
78 const SkScalar dx = SkIntToScalar(5);
79 const SkScalar dy = SkIntToScalar(10);
80
81 SkPathBuilder builder;
82 builder.moveTo(x, y);
83 for (int i = 0; i < teeth; i++) {
84 x += dx;
85 builder.lineTo(x, y - dy);
86 x += dx;
87 builder.lineTo(x, y + dy);
88 }
89 builder.lineTo(x, y + (2 * dy));
90 builder.lineTo(x0, y + (2 * dy));
91 builder.close();
92
93 return {builder.detach(), 30};
94 }
95
96 static PathDY make_sawtooth_3() { return make_sawtooth(3); }
97 static PathDY make_sawtooth_32() { return make_sawtooth(32); }
98
99 static PathDY make_house() {
100 SkPathBuilder builder;
101 builder.addPolygon({{
102 {21, 23},
103 {21, 11.534f},
104 {22.327f, 12.741f},
105 {23.673f, 11.261f},
106 {12, 0.648f},
107 {8, 4.285f},
108 {8, 2},
109 {4, 2},
110 {4, 7.921f},
111 {0.327f, 11.26f},
112 {1.673f, 12.74f},
113 {3, 11.534f},
114 {3, 23},
115 {11, 23},
116 {11, 18},
117 {13, 18},
118 {13, 23},
119 {21, 23}}}, true)
120 .polylineTo({{
121 {9, 16},
122 {9, 21},
123 {5, 21},
124 {5, 9.715f},
125 {12, 3.351f},
126 {19, 9.715f},
127 {19, 21},
128 {15, 21},
129 {15, 16},
130 {9, 16}}})
131 .close()
132 .offset(20, 0);
133 return {builder.detach(), 30};
134 }
135
136 static PathDY make_star(int n) {
137 const SkScalar c = SkIntToScalar(45);
138 const SkScalar r = SkIntToScalar(20);
139
140 SkScalar rad = -SK_ScalarPI / 2;
141 const SkScalar drad = (n >> 1) * SK_ScalarPI * 2 / n;
142
143 SkPathBuilder builder;
144 builder.moveTo(c, c - r);
145 for (int i = 1; i < n; i++) {
146 rad += drad;
147 builder.lineTo(c + SkScalarCos(rad) * r, c + SkScalarSin(rad) * r);
148 }
149 builder.close();
150
151 return {builder.detach(), r * 2 * 6 / 5};
152 }
153
154 static PathDY make_star_5() { return make_star(5); }
155 static PathDY make_star_13() { return make_star(13); }
156
157 // We don't expect any output from this path.
158 static PathDY make_line() {
159 return {
160 SkPathBuilder().moveTo(30, 30)
161 .lineTo(120, 40)
162 .close()
163 .moveTo(150, 30)
164 .lineTo(150, 30)
165 .lineTo(300, 40)
166 .close()
167 .detach(),
168 40
169 };
170 }
171
172 static SkPath make_info() {
173 SkPathBuilder path;
174 path.moveTo(24, 4);
175 path.cubicTo(12.94999980926514f, 4,
176 4, 12.94999980926514f,
177 4, 24);
178 path.cubicTo(4, 35.04999923706055f,
179 12.94999980926514f, 44,
180 24, 44);
181 path.cubicTo(35.04999923706055f, 44,
182 44, 35.04999923706055f,
183 44, 24);
184 path.cubicTo(44, 12.95000076293945f,
185 35.04999923706055f, 4,
186 24, 4);
187 path.close();
188 path.moveTo(26, 34);
189 path.lineTo(22, 34);
190 path.lineTo(22, 22);
191 path.lineTo(26, 22);
192 path.lineTo(26, 34);
193 path.close();
194 path.moveTo(26, 18);
195 path.lineTo(22, 18);
196 path.lineTo(22, 14);
197 path.lineTo(26, 14);
198 path.lineTo(26, 18);
199 path.close();
200 return path.detach();
201 }
202
203 static SkPath make_accessibility() {
204 SkPathBuilder path;
205 path.moveTo(12, 2);
206 path.cubicTo(13.10000038146973f, 2,
207 14, 2.900000095367432f,
208 14, 4);
209 path.cubicTo(14, 5.099999904632568f,
210 13.10000038146973f, 6,
211 12, 6);
212 path.cubicTo(10.89999961853027f, 6,
213 10, 5.099999904632568f,
214 10, 4);
215 path.cubicTo(10, 2.900000095367432f,
216 10.89999961853027f, 2,
217 12, 2);
218 path.close();
219 path.moveTo(21, 9);
220 path.lineTo(15, 9);
221 path.lineTo(15, 22);
222 path.lineTo(13, 22);
223 path.lineTo(13, 16);
224 path.lineTo(11, 16);
225 path.lineTo(11, 22);
226 path.lineTo(9, 22);
227 path.lineTo(9, 9);
228 path.lineTo(3, 9);
229 path.lineTo(3, 7);
230 path.lineTo(21, 7);
231 path.lineTo(21, 9);
232 path.close();
233 return path.detach();
234 }
235
236 // test case for http://crbug.com/695196
237 static SkPath make_visualizer() {
238 SkPathBuilder path;
239 path.moveTo(1.9520f, 2.0000f);
240 path.conicTo(1.5573f, 1.9992f, 1.2782f, 2.2782f, 0.9235f);
241 path.conicTo(0.9992f, 2.5573f, 1.0000f, 2.9520f, 0.9235f);
242 path.lineTo(1.0000f, 5.4300f);
243 path.lineTo(17.0000f, 5.4300f);
244 path.lineTo(17.0000f, 2.9520f);
245 path.conicTo(17.0008f, 2.5573f, 16.7218f, 2.2782f, 0.9235f);
246 path.conicTo(16.4427f, 1.9992f, 16.0480f, 2.0000f, 0.9235f);
247 path.lineTo(1.9520f, 2.0000f);
248 path.close();
249 path.moveTo(2.7140f, 3.1430f);
250 path.conicTo(3.0547f, 3.1287f, 3.2292f, 3.4216f, 0.8590f);
251 path.conicTo(3.4038f, 3.7145f, 3.2292f, 4.0074f, 0.8590f);
252 path.conicTo(3.0547f, 4.3003f, 2.7140f, 4.2860f, 0.8590f);
253 path.conicTo(2.1659f, 4.2631f, 2.1659f, 3.7145f, 0.7217f);
254 path.conicTo(2.1659f, 3.1659f, 2.7140f, 3.1430f, 0.7217f);
255 path.lineTo(2.7140f, 3.1430f);
256 path.close();
257 path.moveTo(5.0000f, 3.1430f);
258 path.conicTo(5.3407f, 3.1287f, 5.5152f, 3.4216f, 0.8590f);
259 path.conicTo(5.6898f, 3.7145f, 5.5152f, 4.0074f, 0.8590f);
260 path.conicTo(5.3407f, 4.3003f, 5.0000f, 4.2860f, 0.8590f);
261 path.conicTo(4.4519f, 4.2631f, 4.4519f, 3.7145f, 0.7217f);
262 path.conicTo(4.4519f, 3.1659f, 5.0000f, 3.1430f, 0.7217f);
263 path.lineTo(5.0000f, 3.1430f);
264 path.close();
265 path.moveTo(7.2860f, 3.1430f);
266 path.conicTo(7.6267f, 3.1287f, 7.8012f, 3.4216f, 0.8590f);
267 path.conicTo(7.9758f, 3.7145f, 7.8012f, 4.0074f, 0.8590f);
268 path.conicTo(7.6267f, 4.3003f, 7.2860f, 4.2860f, 0.8590f);
269 path.conicTo(6.7379f, 4.2631f, 6.7379f, 3.7145f, 0.7217f);
270 path.conicTo(6.7379f, 3.1659f, 7.2860f, 3.1430f, 0.7217f);
271 path.close();
272 path.moveTo(1.0000f, 6.1900f);
273 path.lineTo(1.0000f, 14.3810f);
274 path.conicTo(0.9992f, 14.7757f, 1.2782f, 15.0548f, 0.9235f);
275 path.conicTo(1.5573f, 15.3338f, 1.9520f, 15.3330f, 0.9235f);
276 path.lineTo(16.0480f, 15.3330f);
277 path.conicTo(16.4427f, 15.3338f, 16.7218f, 15.0548f, 0.9235f);
278 path.conicTo(17.0008f, 14.7757f, 17.0000f, 14.3810f, 0.9235f);
279 path.lineTo(17.0000f, 6.1910f);
280 path.lineTo(1.0000f, 6.1910f);
281 path.lineTo(1.0000f, 6.1900f);
282 path.close();
283 return path.detach();
284 }
285
286 constexpr MakePathProc gProcs[] = {
287 make_frame,
288 make_triangle,
289 make_rect,
290 make_oval,
291 make_sawtooth_32,
292 make_star_5,
293 make_star_13,
294 make_line,
295 make_house,
296 make_sawtooth_3,
297 };
298
299 #define N std::size(gProcs)
300
301 class PathFillGM : public skiagm::GM {
302 SkPath fPath[N];
303 SkScalar fDY[N];
304 SkPath fInfoPath;
305 SkPath fAccessibilityPath;
306 SkPath fVisualizerPath;
307 protected:
308 void onOnceBeforeDraw() override {
309 for (size_t i = 0; i < N; i++) {
310 auto [path, dy] = gProcs[i]();
311 fPath[i] = path;
312 fDY[i] = dy;
313 }
314
315 fInfoPath = make_info();
316 fAccessibilityPath = make_accessibility();
317 fVisualizerPath = make_visualizer();
318 }
319
320 SkString getName() const override { return SkString("pathfill"); }
321
322 SkISize getISize() override { return SkISize::Make(640, 480); }
323
324 void onDraw(SkCanvas* canvas) override {
325 SkPaint paint;
326 paint.setAntiAlias(true);
327
328 for (size_t i = 0; i < N; i++) {
329 canvas->drawPath(fPath[i], paint);
330 canvas->translate(SkIntToScalar(0), fDY[i]);
331 }
332
333 canvas->save();
334 canvas->scale(0.300000011920929f, 0.300000011920929f);
335 canvas->translate(50, 50);
336 canvas->drawPath(fInfoPath, paint);
337 canvas->restore();
338
339 canvas->scale(2, 2);
340 canvas->translate(5, 15);
341 canvas->drawPath(fAccessibilityPath, paint);
342
343 canvas->scale(0.5f, 0.5f);
344 canvas->translate(5, 50);
345 canvas->drawPath(fVisualizerPath, paint);
346 }
347
348 private:
349 using INHERITED = skiagm::GM;
350 };
351
352 // test inverse-fill w/ a clip that completely excludes the geometry
353 class PathInverseFillGM : public skiagm::GM {
354 SkPath fPath[N];
355 SkScalar fDY[N];
356 protected:
357 void onOnceBeforeDraw() override {
358 for (size_t i = 0; i < N; i++) {
359 auto [path, dy] = gProcs[i]();
360 fPath[i] = path;
361 fDY[i] = dy;
362 }
363 }
364
365 SkString getName() const override { return SkString("pathinvfill"); }
366
367 SkISize getISize() override { return SkISize::Make(450, 220); }
368
369 static void show(SkCanvas* canvas, const SkPath& path, const SkPaint& paint,
370 const SkRect* clip, SkScalar top, const SkScalar bottom) {
371 canvas->save();
372 if (clip) {
373 SkRect r = *clip;
374 r.fTop = top;
375 r.fBottom = bottom;
376 canvas->clipRect(r);
377 }
378 canvas->drawPath(path, paint);
379 canvas->restore();
380 }
381
382 void onDraw(SkCanvas* canvas) override {
383 SkPath path = SkPathBuilder().addCircle(50, 50, 40)
384 .toggleInverseFillType()
385 .detach();
386
387 SkRect clipR = {0, 0, 100, 200};
388
389 canvas->translate(10, 10);
390
391 for (int doclip = 0; doclip <= 1; ++doclip) {
392 for (int aa = 0; aa <= 1; ++aa) {
393 SkPaint paint;
394 paint.setAntiAlias(SkToBool(aa));
395
396 canvas->save();
397 canvas->clipRect(clipR);
398
399 const SkRect* clipPtr = doclip ? &clipR : nullptr;
400
401 show(canvas, path, paint, clipPtr, clipR.fTop, clipR.centerY());
402 show(canvas, path, paint, clipPtr, clipR.centerY(), clipR.fBottom);
403
404 canvas->restore();
405 canvas->translate(SkIntToScalar(110), 0);
406 }
407 }
408 }
409
410 private:
411 using INHERITED = skiagm::GM;
412 };
413
414 DEF_SIMPLE_GM(rotatedcubicpath, canvas, 200, 200) {
415 SkPaint p;
416 p.setAntiAlias(true);
417 p.setStyle(SkPaint::kFill_Style);
418
419 canvas->translate(50, 50);
420 SkPath path = SkPathBuilder()
421 .moveTo(48,-23)
422 .cubicTo(48,-29.5, 6,-30, 6,-30)
423 .cubicTo(6,-30, 2,0, 2,0)
424 .cubicTo(2,0, 44,-21.5, 48,-23)
425 .close()
426 .detach();
427
428 p.setColor(SK_ColorBLUE);
429 canvas->drawPath(path, p);
430
431 // Rotated path, which is not antialiased on GPU
432 p.setColor(SK_ColorRED);
433 canvas->rotate(90);
434 canvas->drawPath(path, p);
435 }
436
437 ///////////////////////////////////////////////////////////////////////////////
438
439 DEF_GM( return new PathFillGM; )
440 DEF_GM( return new PathInverseFillGM; )
441
442 DEF_SIMPLE_GM(bug7792, canvas, 800, 800) {
443 // from skbug.com/40039046 bug description
444 SkPaint p;
445 SkPath path = SkPathBuilder()
446 .moveTo(10, 10)
447 .moveTo(75, 75)
448 .lineTo(150, 75)
449 .lineTo(150, 150)
450 .lineTo(75, 150)
451 .detach();
452 canvas->drawPath(path, p);
453 // from skbug.com/40039046#c3
454 canvas->translate(200, 0);
455 path = SkPathBuilder()
456 .moveTo(75, 50)
457 .moveTo(100, 75)
458 .lineTo(150, 75)
459 .lineTo(150, 150)
460 .lineTo(75, 150)
461 .lineTo(75, 50)
462 .close()
463 .detach();
464 canvas->drawPath(path, p);
465 // from skbug.com/40039046#c9
466 canvas->translate(200, 0);
467 path = SkPathBuilder()
468 .moveTo(10, 10)
469 .moveTo(75, 75)
470 .lineTo(150, 75)
471 .lineTo(150, 150)
472 .lineTo(75, 150)
473 .close()
474 .detach();
475 canvas->drawPath(path, p);
476 // from skbug.com/40039046#c11
477 canvas->translate(-200 * 2, 200);
478 path = SkPathBuilder()
479 .moveTo(75, 150)
480 .lineTo(75, 75)
481 .lineTo(150, 75)
482 .lineTo(150, 150)
483 .lineTo(75, 150)
484 .moveTo(75, 150)
485 .detach();
486 canvas->drawPath(path, p);
487 // from skbug.com/40039046#c14
488 canvas->translate(200, 0);
489 path = SkPathBuilder()
490 .moveTo(250, 75)
491 .moveTo(250, 75)
492 .moveTo(250, 75)
493 .moveTo(100, 75)
494 .lineTo(150, 75)
495 .lineTo(150, 150)
496 .lineTo(75, 150)
497 .lineTo(75, 75)
498 .close()
499 .lineTo(0, 0)
500 .close()
501 .detach();
502 canvas->drawPath(path, p);
503 // from skbug.com/40039046#c15
504 canvas->translate(200, 0);
505 path = SkPathBuilder()
506 .moveTo(75, 75)
507 .lineTo(150, 75)
508 .lineTo(150, 150)
509 .lineTo(75, 150)
510 .moveTo(250, 75)
511 .detach();
512 canvas->drawPath(path, p);
513 // from skbug.com/40039046#c17
514 canvas->translate(-200 * 2, 200);
515 path = SkPathBuilder()
516 .moveTo(75, 10)
517 .moveTo(75, 75)
518 .lineTo(150, 75)
519 .lineTo(150, 150)
520 .lineTo(75, 150)
521 .lineTo(75, 10)
522 .close()
523 .detach();
524 canvas->drawPath(path, p);
525 // from skbug.com/40039046#c19
526 canvas->translate(200, 0);
527 path = SkPathBuilder()
528 .moveTo(75, 75)
529 .lineTo(75, 75)
530 .lineTo(75, 75)
531 .lineTo(75, 75)
532 .lineTo(150, 75)
533 .lineTo(150, 150)
534 .lineTo(75, 150)
535 .close()
536 .moveTo(10, 10)
537 .lineTo(30, 10)
538 .lineTo(10, 30)
539 .detach();
540 canvas->drawPath(path, p);
541 // from skbug.com/40039046#c23
542 canvas->translate(200, 0);
543 path = SkPathBuilder()
544 .moveTo(75, 75)
545 .lineTo(75, 75)
546 .moveTo(75, 75)
547 .lineTo(75, 75)
548 .lineTo(150, 75)
549 .lineTo(150, 150)
550 .lineTo(75, 150)
551 .close()
552 .detach();
553 canvas->drawPath(path, p);
554 // from skbug.com/40039046#c29
555 canvas->translate(-200 * 2, 200);
556 path = SkPathBuilder()
557 .moveTo(75, 75)
558 .lineTo(150, 75)
559 .lineTo(150, 150)
560 .lineTo(75, 150)
561 .lineTo(75, 250)
562 .moveTo(75, 75)
563 .close()
564 .detach();
565 canvas->drawPath(path, p);
566 // from skbug.com/40039046#c31
567 canvas->translate(200, 0);
568 path = SkPathBuilder()
569 .moveTo(75, 75)
570 .lineTo(150, 75)
571 .lineTo(150, 150)
572 .lineTo(75, 150)
573 .lineTo(75, 10)
574 .moveTo(75, 75)
575 .close()
576 .detach();
577 canvas->drawPath(path, p);
578 // from skbug.com/40039046#c36
579 canvas->translate(200, 0);
580 path = SkPathBuilder()
581 .moveTo(75, 75)
582 .lineTo(150, 75)
583 .lineTo(150, 150)
584 .lineTo(10, 150)
585 .moveTo(75, 75)
586 .lineTo(75, 75)
587 .detach();
588 canvas->drawPath(path, p);
589 // from skbug.com/40039046#c39
590 canvas->translate(200, -200 * 3);
591 path = SkPathBuilder()
592 .moveTo(150, 75)
593 .lineTo(150, 150)
594 .lineTo(75, 150)
595 .lineTo(75, 100)
596 .detach();
597 canvas->drawPath(path, p);
598 // from zero_length_paths_aa
599 canvas->translate(0, 200);
600 path = SkPathBuilder()
601 .moveTo(150, 100)
602 .lineTo(150, 100)
603 .lineTo(150, 150)
604 .lineTo(75, 150)
605 .lineTo(75, 100)
606 .lineTo(75, 75)
607 .lineTo(150, 75)
608 .close()
609 .detach();
610 canvas->drawPath(path, p);
611 // from skbug.com/40039046#c41
612 canvas->translate(0, 200);
613 path = SkPathBuilder()
614 .moveTo(75, 75)
615 .lineTo(150, 75)
616 .lineTo(150, 150)
617 .lineTo(140, 150)
618 .lineTo(140, 75)
619 .moveTo(75, 75)
620 .close()
621 .detach();
622 canvas->drawPath(path, p);
623 // from skbug.com/40039046#c53
624 canvas->translate(0, 200);
625 path = SkPathBuilder()
626 .moveTo(75, 75)
627 .lineTo(150, 75)
628 .lineTo(150, 150)
629 .lineTo(140, 150)
630 .lineTo(140, 75)
631 .moveTo(75, 75)
632 .close()
633 .detach();
634 canvas->drawPath(path, p);
635 }
636
637 #include "include/core/SkSurface.h"
638
639 DEF_SIMPLE_GM(path_stroke_clip_crbug1070835, canvas, 25, 50) {
640 SkCanvas* orig = canvas;
641 auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(25, 25));
642 canvas = surf->getCanvas();
643
644 SkPaint p;
645 p.setColor(SK_ColorRED);
646 p.setAntiAlias(true);
647 p.setStyle(SkPaint::kStroke_Style);
648 p.setStrokeWidth(2);
649
650 canvas->scale(4.16666651f/2, 4.16666651f/2);
651
652 SkPoint pts[] = {
653 {11, 12},
654 {11, 18.0751324f},
655 {6.07513189f, 23},
656 {-4.80825292E-7f, 23},
657 {-6.07513332f, 23},
658 {-11, 18.0751324f},
659 {-11, 11.999999f},
660 {-10.999999f, 5.92486763f},
661 {-6.07513189f, 1},
662 {1.31173692E-7f, 1},
663 {6.07513141f, 1},
664 {10.9999981f, 5.92486572f},
665 {11, 11.9999971f},
666 };
667 SkPath path = SkPathBuilder()
668 .moveTo(pts[0])
669 .cubicTo(pts[1], pts[2], pts[3])
670 .cubicTo(pts[4], pts[5], pts[6])
671 .cubicTo(pts[7], pts[8], pts[9])
672 .cubicTo(pts[10],pts[11],pts[12])
673 .detach();
674
675 canvas->drawPath(path, p);
676
677 surf->draw(orig, 0, 0);
678 }
679
680 DEF_SIMPLE_GM(path_arcto_skbug_9077, canvas, 200, 200) {
681 SkPaint p;
682 p.setColor(SK_ColorRED);
683 p.setAntiAlias(true);
684 p.setStyle(SkPaint::kStroke_Style);
685 p.setStrokeWidth(2);
686
687 SkPathBuilder path;
688 SkPoint pts[] = { {20, 20}, {100, 20}, {100, 60}, {130, 150}, {180, 160} };
689 SkScalar radius = 60;
690 path.moveTo(pts[0]);
691 path.lineTo(pts[1]);
692 path.lineTo(pts[2]);
693 path.close();
694 path.arcTo(pts[3], pts[4], radius);
695 canvas->drawPath(path.detach(), p);
696 }
697
698 DEF_SIMPLE_GM(path_skbug_11859, canvas, 512, 512) {
699 SkPaint paint;
700 paint.setColor(SK_ColorRED);
701 paint.setAntiAlias(true);
702
703 SkPath path = SkPathBuilder()
704 .moveTo(258, -2)
705 .lineTo(258, 258)
706 .lineTo(237, 258)
707 .lineTo(240, -2)
708 .lineTo(258, -2)
709 .moveTo(-2, -2)
710 .lineTo(240, -2)
711 .lineTo(238, 131)
712 .lineTo(-2, 131)
713 .lineTo(-2, -2)
714 .detach();
715
716 canvas->scale(2, 2);
717 canvas->drawPath(path, paint);
718 }
719
720 DEF_SIMPLE_GM(path_skbug_11886, canvas, 256, 256) {
721 SkPoint m = {0.f, 770.f};
722 SkPath path = SkPathBuilder()
723 .moveTo(m)
724 .cubicTo(m + SkPoint{0.f, 1.f},
725 m + SkPoint{20.f, -750.f},
726 m + SkPoint{83.f, -746.f})
727 .detach();
728 SkPaint paint;
729 paint.setAntiAlias(true);
730 canvas->drawPath(path, paint);
731 }