• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
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/SkPathBuilder.h"
11 
12 DEF_SIMPLE_GM(crbug_1257515, canvas, 1139, 400) {
13     // <svg width="1139" height="400" viewBox="0 0 1139 400">
14     //    <g transform="translate(46,60) scale(1 1)">
15     //       <path fill="none" d="M 45.125 102.53701800000002
16     //                            L 135.375 162.666156 L 225.625 116.622276
17     //                            L 315.875 121.52087700000001 L 406.125 134.632899
18     //                            L 496.375 192.317736 L 586.625 138.82944899999998
19     //                            L 676.875 234.212031 L 767.125 207.082926 L 857.375 128.083857
20     //                            L 947.625 127.95689999999999 L 1037.875 113.956785"
21     //             stroke="red" stroke-width="2" stroke-linejoin="round" stroke-linecap="round">
22     //       </path>
23     //    </g>
24     // </svg>
25     SkPathBuilder b;
26     b.moveTo(45.125f, 102.53701800000002f)
27      .lineTo(135.375f, 162.666156f)
28      .lineTo(225.625f, 116.622276f)
29      .lineTo(315.875f, 121.52087700000001f)
30      .lineTo(406.125f, 134.632899f)
31      .lineTo(496.375f, 192.317736f)
32      .lineTo(586.625f, 138.82944899999998f)
33      .lineTo(676.875f, 234.212031f)
34      .lineTo(767.125f, 207.082926f)
35      .lineTo(857.375f, 128.083857f)
36      .lineTo(947.625f, 127.95689999999999f)
37      .lineTo(1037.875f, 113.956785f);
38 
39     SkPaint p;
40     p.setColor(SK_ColorRED);
41     p.setStrokeWidth(2.f);
42     p.setStyle(SkPaint::kStroke_Style);
43     p.setStrokeCap(SkPaint::kRound_Cap);
44     p.setStrokeJoin(SkPaint::kRound_Join);
45     p.setAntiAlias(true);
46 
47     canvas->save();
48     canvas->translate(-50.f, -200.f);
49     canvas->scale(2.f, 2.f);
50     canvas->drawPath(b.detach(), p);
51     canvas->restore();
52 
53     // <svg width="1148" height="700" viewBox="0 0 1148 700">
54     //    <path fill="none" d="M 129.5307 587.5728 L 232.4748 617.037 L 335.4189 624.8472
55     //                         L 438.3631 630.5933 L 541.3073 625.1138 L 644.2513 626.8717
56     //                         L 747.1955 629.9542 L 850.1396 629.6956 L 953.0838 616.4909
57     //                         L 1056.028 613.8181"
58     //          stroke="rgba(47,136,255,1)" stroke-width="3"
59     //          stroke-linecap="butt" stroke-linejoin="bevel" stroke-miterlimit="10">
60     //    </path>
61     // </svg>
62     b.moveTo(128.5307f, 587.5728f)
63      .lineTo(232.4748f, 617.037f)
64      .lineTo(335.4189f, 624.8472f)
65      .lineTo(438.3631f, 630.5933f)
66      .lineTo(541.3073f, 625.1138f)
67      .lineTo(644.2513f, 626.8717f)
68      .lineTo(747.1955f, 629.9542f)
69      .lineTo(850.1396f, 629.6956f)
70      .lineTo(953.0838f, 616.4909f)
71      .lineTo(1056.028f, 613.8181f);
72     p.setColor(SkColorSetARGB(255, 47, 136, 255));
73     p.setStrokeWidth(3.f);
74     p.setStrokeCap(SkPaint::kButt_Cap);
75     p.setStrokeJoin(SkPaint::kBevel_Join);
76     p.setStrokeMiter(10.f);
77 
78     canvas->save();
79     canvas->translate(-300.f, -900.f);
80     canvas->scale(2.f, 2.f);
81     canvas->drawPath(b.detach(), p);
82     canvas->restore();
83 }
84