Flutter Engine
The Flutter Engine
collapsepaths.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 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"
11
12namespace {
13
14void test_collapse1(SkCanvas* canvas, const SkPaint& paint) {
16 canvas->translate(0, 0);
17 path.moveTo( 652.830078125, 673.9365234375);
18 path.lineTo( 479.50152587890625, 213.412628173828125);
19 path.lineTo( 511.840545654296875, 209.1551055908203125);
20 path.lineTo( 528.14959716796875, 208.6212158203125);
21 path.moveTo( 370.50653076171875, 73.684051513671875);
22 path.lineTo( 525.02093505859375, 208.6413726806640625);
23 path.lineTo( 478.403564453125, 213.5998992919921875);
24 path.setFillType(SkPathFillType::kEvenOdd);
25 canvas->drawPath(path.detach(), paint);
26}
27
28void test_collapse2(SkCanvas* canvas, const SkPaint& paint) {
30 path.moveTo( 492.781982421875, 508.7139892578125);
31 path.lineTo( 361.946746826171875, 161.0923004150390625);
32 path.lineTo( 386.357513427734375, 157.8785552978515625);
33 path.lineTo( 398.668212890625, 157.475555419921875);
34 path.moveTo( 279.673004150390625, 55.619640350341796875);
35 path.lineTo( 396.30657958984375, 157.4907684326171875);
36 path.lineTo( 361.117950439453125, 161.2336578369140625);
37 canvas->drawPath(path.detach(), paint);
38}
39
40void test_collapse3(SkCanvas* canvas, const SkPaint& paint) {
42 path.moveTo(31.9730987548828125, 69.4149169921875);
43 path.lineTo(36.630767822265625, 67.66190338134765625);
44 path.lineTo(51.1498870849609375, 64.2765045166015625);
45 path.moveTo(52.94580078125, 64.05560302734375);
46 path.lineTo(38.9994354248046875, 66.8980712890625);
47 path.lineTo(32.229583740234375, 69.31696319580078125);
48 path.lineTo(12.99810791015625, 22.4723663330078125);
49 canvas->drawPath(path.detach(), paint);
50}
51
52void test_collapse4(SkCanvas* canvas, const SkPaint& paint) {
54 path.moveTo( 122.66265869140625, 77.81488800048828125);
55 path.lineTo( 161.983642578125, 128.557952880859375);
56 path.lineTo(22.599969863891601562, 76.61859893798828125);
57 path.lineTo(18.03154754638671875, 76.055633544921875);
58 path.lineTo(15.40312957763671875, 75.7647247314453125);
59 path.lineTo(18.572841644287109375, 75.2251129150390625);
60 path.lineTo(20.895002365112304688, 73.7937774658203125);
61 canvas->drawPath(path.detach(), paint);
62}
63
64void test_collapse5(SkCanvas* canvas, const SkPaint& paint) {
66 path.moveTo(52.659847259521484375, 782.0546875);
67 path.lineTo(136.6915130615234375, 690.18011474609375);
68 path.lineTo( 392.147796630859375, 554.6090087890625);
69 path.lineTo( 516.51470947265625, 534.44134521484375);
70 path.moveTo(154.6182708740234375, 188.230926513671875);
71 path.lineTo( 430.242095947265625, 546.76605224609375);
72 path.lineTo( 373.1005859375, 559.0906982421875);
73 path.setFillType(SkPathFillType::kEvenOdd);
74 canvas->drawPath(path.detach(), paint);
75}
76
77void test_collapse6(SkCanvas* canvas, const SkPaint& paint) {
79 path.moveTo(13.314494132995605469, 197.7343902587890625);
80 path.lineTo(34.56102752685546875, 174.5048675537109375);
81 path.lineTo(99.15048980712890625, 140.22711181640625);
82 path.lineTo( 130.595367431640625, 135.1279296875);
83 path.moveTo(39.09362030029296875, 47.59223175048828125);
84 path.lineTo(108.7822418212890625, 138.244110107421875);
85 path.lineTo(94.33460235595703125, 141.360260009765625);
86 path.setFillType(SkPathFillType::kEvenOdd);
87 canvas->drawPath(path.detach(), paint);
88}
89
90void test_collapse7(SkCanvas* canvas, const SkPaint& paint) {
92 path.moveTo(13.737141609191894531, 204.0111541748046875);
93 path.lineTo( 35.658111572265625, 180.04425048828125);
94 path.lineTo(102.2978668212890625, 144.67840576171875);
95 path.lineTo( 134.74090576171875, 139.4173583984375);
96 path.moveTo(40.33458709716796875, 49.10297393798828125);
97 path.lineTo(112.2353668212890625, 142.6324462890625);
98 path.lineTo(97.32910919189453125, 145.8475189208984375);
99 path.setFillType(SkPathFillType::kEvenOdd);
100 canvas->drawPath(path.detach(), paint);
101}
102
103void test_collapse8(SkCanvas* canvas, const SkPaint& paint) {
105 path.moveTo( 11.75, 174.50);
106 path.lineTo( 30.50, 154.00);
107 path.lineTo( 87.50, 123.75);
108 path.lineTo(115.25, 119.25);
109 path.moveTo( 34.50, 42.00);
110 path.lineTo( 96.00, 122.00);
111 path.lineTo( 83.25, 124.75);
112 path.setFillType(SkPathFillType::kEvenOdd);
113 canvas->drawPath(path.detach(), paint);
114}
115
116void test_collapse9(SkCanvas* canvas, const SkPaint& paint) {
118 path.moveTo(SkDoubleToScalar( 13.25), SkDoubleToScalar(197.75));
119 path.lineTo(SkDoubleToScalar( 34.75), SkDoubleToScalar(174.75));
120 path.lineTo(SkDoubleToScalar( 99.0364), SkDoubleToScalar(140.364));
121 path.lineTo(SkDoubleToScalar( 99.25), SkDoubleToScalar(140.25));
122 path.lineTo(SkDoubleToScalar(100.167), SkDoubleToScalar(140.096));
123 path.lineTo(SkDoubleToScalar(130.50), SkDoubleToScalar(135.00));
124 path.moveTo(SkDoubleToScalar( 39.25), SkDoubleToScalar( 47.50));
125 path.lineTo(SkDoubleToScalar(100.167), SkDoubleToScalar(140.096));
126 path.lineTo(SkDoubleToScalar( 99.0364), SkDoubleToScalar(140.364));
127 path.lineTo(SkDoubleToScalar( 94.25), SkDoubleToScalar(141.50));
128 path.setFillType(SkPathFillType::kEvenOdd);
129 canvas->drawPath(path.detach(), paint);
130}
131
132// This one is a thin inverted 'v', but the edges should not disappear at any point.
133void test_collapse10(SkCanvas* canvas, const SkPaint& paint) {
135 path.moveTo( 5.5, 36.0);
136 path.lineTo(47.5, 5.0);
137 path.lineTo(90.0, 36.0);
138 path.lineTo(88.5, 36.0);
139 path.lineTo(47.5, 6.0);
140 path.lineTo( 7.0, 36.0);
141 canvas->drawPath(path.detach(), paint);
142}
143
144} // namespace
145
146DEF_SIMPLE_GM(collapsepaths, canvas, 500, 600) {
148
149 paint.setAntiAlias(true);
150 paint.setStyle(SkPaint::kFill_Style);
151 test_collapse1(canvas, paint);
152 test_collapse2(canvas, paint);
153 test_collapse3(canvas, paint);
154 test_collapse4(canvas, paint);
155 test_collapse5(canvas, paint);
156 test_collapse6(canvas, paint);
157 test_collapse7(canvas, paint);
158 test_collapse8(canvas, paint);
159 test_collapse9(canvas, paint);
160 test_collapse10(canvas, paint);
161}
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
DEF_SIMPLE_GM(collapsepaths, canvas, 500, 600)
const Paint & paint
Definition: color_source.cc:38
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57