Flutter Engine
The Flutter Engine
Functions
PathOpsBuilderTest.cpp File Reference
#include "include/core/SkPath.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkRect.h"
#include "include/pathops/SkPathOps.h"
#include "src/base/SkFloatBits.h"
#include "tests/PathOpsExtendedTest.h"
#include "tests/Test.h"

Go to the source code of this file.

Functions

 DEF_TEST (PathOpsBuilder, reporter)
 
 DEF_TEST (BuilderIssue3838, reporter)
 
 DEF_TEST (BuilderIssue3838_2, reporter)
 
 DEF_TEST (BuilderIssue3838_3, reporter)
 
 DEF_TEST (BuilderIssue502792_2, reporter)
 
 DEF_TEST (Fuzz846, reporter)
 
 DEF_TEST (Issue569540, reporter)
 
 DEF_TEST (SkOpBuilderFuzz665, reporter)
 
 DEF_TEST (SkOpBuilder618991, reporter)
 
 DEF_TEST (SkOpBuilderKFuzz1, reporter)
 

Function Documentation

◆ DEF_TEST() [1/10]

DEF_TEST ( BuilderIssue3838  ,
reporter   
)

Definition at line 85 of file PathOpsBuilderTest.cpp.

85 {
87 path.moveTo(200, 170);
88 path.lineTo(220, 170);
89 path.lineTo(220, 230);
90 path.lineTo(240, 230);
91 path.lineTo(240, 210);
92 path.lineTo(180, 210);
93 path.lineTo(180, 190);
94 path.lineTo(260, 190);
95 path.lineTo(260, 250);
96 path.lineTo(200, 250);
97 path.lineTo(200, 170);
98 path.close();
102 builder.resolve(&path2);
103 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, path2);
104 REPORTER_ASSERT(reporter, pixelDiff == 0);
105}
reporter
Definition: FontMgrTest.cpp:39
int comparePaths(skiatest::Reporter *reporter, const char *filename, const SkPath &one, const SkPath &two, SkBitmap &bitmap)
static SkPath path2()
@ kUnion_SkPathOp
union (inclusive-or) the two paths
Definition: SkPathOps.h:25
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
Definition: SkPath.h:59
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

◆ DEF_TEST() [2/10]

DEF_TEST ( BuilderIssue3838_2  ,
reporter   
)

Definition at line 107 of file PathOpsBuilderTest.cpp.

107 {
108 SkPath path;
109 path.addCircle(100, 100, 50);
110
114
116 builder.resolve(&result);
117 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result);
118 REPORTER_ASSERT(reporter, pixelDiff == 0);
119}
GAsyncResult * result

◆ DEF_TEST() [3/10]

DEF_TEST ( BuilderIssue3838_3  ,
reporter   
)

Definition at line 121 of file PathOpsBuilderTest.cpp.

121 {
122 SkPath path;
123 path.moveTo(40, 10);
124 path.lineTo(60, 10);
125 path.lineTo(60, 30);
126 path.lineTo(40, 30);
127 path.lineTo(40, 10);
128 path.moveTo(41, 11);
129 path.lineTo(41, 29);
130 path.lineTo(59, 29);
131 path.lineTo(59, 11);
132 path.lineTo(41, 11);
133
137 builder.resolve(&result);
138 int pixelDiff = comparePaths(reporter, __FUNCTION__, path, result);
139 REPORTER_ASSERT(reporter, pixelDiff == 0);
140}

◆ DEF_TEST() [4/10]

DEF_TEST ( BuilderIssue502792_2  ,
reporter   
)

Definition at line 142 of file PathOpsBuilderTest.cpp.

142 {
143 SkPath path, pathB;
144 path.setFillType(SkPathFillType::kWinding);
145 path.addRect(0, 0, 1, 1, SkPathDirection::kCW);
146 path.addRect(2, 2, 3, 3, SkPathDirection::kCW);
148 pathB.addRect(3, 3, 4, 4, SkPathDirection::kCW);
149 pathB.addRect(3, 3, 4, 4, SkPathDirection::kCW);
152 builder.add(pathB, kDifference_SkPathOp);
154 builder.resolve(&result);
155}
@ kDifference_SkPathOp
subtract the op path from the first path
Definition: SkPathOps.h:23
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864

◆ DEF_TEST() [5/10]

DEF_TEST ( Fuzz846  ,
reporter   
)

Definition at line 157 of file PathOpsBuilderTest.cpp.

157 {
158/*
159<clipPath id="clip-circle">
160 <circle id="circle" cx="60" cy="60" r="50" />
161</clipPath>
162<clipPath id="clip-rect">
163 <clipPath id="clip-rect">
164 <clipPath id="clip-rect">
165 <clipPath id="clip-rect">
166 <rect x="10" y="30" width="0" height="60" />
167 <rect x="10" y="30" width="0" height="60" />
168 <rect x="10" y="30" width="100" height="60" />
169 <rect x="10" y="30" width="32668" />
170 <rect x="10" y="30" width="100" height="18446744073709551615" />
171 <rect x="10" y="255" width="100" height="60" />
172 <rect width="100" height="60" />
173 <rect x="10" y="30" width="100" height="60" />
174 <rect x="10" y="30" width="100" height="4294967236" />
175 <rect x="10" y="30" width="100" height="60" />
176 </clipPath>
177 <rect x="10" y="30" width="0" height="60" />
178 <rect x="10" y="30" width="0" height="0.18093252719929986369568203" />
179 <rect x="10" y="30" width="100" height="60" />
180 <rect x="10" y="30" width="32668" height="60" />
181 <rect x="10" y="30" width="100" height="18446744073709551615" />
182 <rect x="10" y="255" width="100" height="60" />
183 <rect x="2147483649" y="30" width="100" height="60" />
184 <rect x="10" y="30" width="100" height="60" />
185 <rect x="10" y="30" width="100" height="60" />
186 <rect x="10" y="30" width="100" height="60" />
187 </clipPath>
188 <rect x="10" y="30" width="0" height="60" />
189 <rect x="10" y="30" width="0" height="60" />
190 <rect x="10" y="30" width="100" height="60" />
191 <rect x="10" y="30" width="32668" height="60" />
192 <rect x="10" y="30" width="100" height="18446744073709551615" />
193 <rect x="10" y="255" width="100" height="60" />
194 <rect x="2147483649" y="30" width="100" height="60" />
195 <rect x="10" y="30" width="100" height="60" />
196 <rect x="10" y="2879753595" width="100" height="60" />
197 <rect x="10" y="30" width="100" height="60" />
198 </clipPath>
199 <rect x="10" y="30" width="100" height="60" />
200 <rect x="10" y="30" width="0" height="60" />
201 <rect x="10" y="30" width="100" height="60" />
202 <rect x="10" y="30" width="32668" height="60" />
203 <rect x="10" y="30" width="100" height="18446744073709551615" />
204 <rect x="10" y="255" width="100" height="60" />
205 <rect x="2147483649" y="30" width="100" height="60" />
206 <rect x="10" y="30" width="100" height="60" />
207 <rect x="10" y="30" width="100" height="4294967236" />
208 <rect x="10" y="30" width="100" height="4294967236" />
209 <rect x="10" y="30" width="100" height="4294967236" />
210 <rect x="10" y="30" width="100" height="4294967236" />
211 <rect x="10" y="30" width="100" height="60" />
212 <rect x="757798030" y="30" width="100" height="60" />
213*/
214 SkPath clipCircle, clipRect;
215 SkPath inner;
216 clipCircle.addCircle(60, 60, 50); // <circle id="circle" cx="60" cy="60" r="50" />
217
218 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
219 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
220 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
221 inner.addRect(10, 30, 10+32668, 30+0); // <rect x="10" y="30" width="32668" />
222 inner.addRect(10, 30, 10+100, 30+18446744073709551615.f); // <rect x="10" y="30" width="100" height="18446744073709551615" />
223 inner.addRect(10, 255, 10+100, 255+60); // <rect x="10" y="255" width="100" height="60" />
224 inner.addRect(0, 0, 0+100, 0+60); // <rect width="100" height="60" />
225 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
226 inner.addRect(10, 30, 10+100, 30+4294967236.f); // <rect x="10" y="30" width="100" height="4294967236" />
227 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
228 clipRect.addPath(inner);
229 inner.reset();
230 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
231 inner.addRect(10, 30, 10+0, 30+0.18093252719929986369568203f); // <rect x="10" y="30" width="0" height="0.18093252719929986369568203" />
232 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
233 inner.addRect(10, 30, 10+32668, 30+60); // <rect x="10" y="30" width="32668" height="60" />
234 inner.addRect(10, 30, 10+100, 30+18446744073709551615.f); // <rect x="10" y="30" width="100" height="18446744073709551615" />
235 inner.addRect(10, 255, 10+100, 255+60); // <rect x="10" y="255" width="100" height="60" />
236 inner.addRect(2147483649.f, 30, 2147483649.f+100, 30+60); // <rect x="2147483649" y="30" width="100" height="60" />
237 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
238 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
239 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
240 clipRect.addPath(inner);
241 inner.reset();
242 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
243 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
244 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
245 inner.addRect(10, 30, 10+32668, 30+60); // <rect x="10" y="30" width="32668" height="60" />
246 inner.addRect(10, 30, 10+100, 30+18446744073709551615.f); // <rect x="10" y="30" width="100" height="18446744073709551615" />
247 inner.addRect(10, 255, 10+100, 255+60); // <rect x="10" y="255" width="100" height="60" />
248 inner.addRect(2147483649.f, 30, 2147483649.f+100, 30+60); // <rect x="2147483649" y="30" width="100" height="60" />
249 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
250 inner.addRect(10, 2879753595.f, 10+100, 30+2879753595.f); // <rect x="10" y="2879753595" width="100" height="60" />
251 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
252 clipRect.addPath(inner);
253 inner.reset();
254 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
255 inner.addRect(10, 30, 10+0, 30+60); // <rect x="10" y="30" width="0" height="60" />
256 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
257 inner.addRect(10, 30, 10+32668, 30+60); // <rect x="10" y="30" width="32668" height="60" />
258 inner.addRect(10, 30, 10+100, 30+18446744073709551615.f); // <rect x="10" y="30" width="100" height="18446744073709551615" />
259 inner.addRect(10, 255, 10+100, 255+60); // <rect x="10" y="255" width="100" height="60" />
260 inner.addRect(2147483649.f, 30, 2147483649.f+100, 30+60); // <rect x="2147483649" y="30" width="100" height="60" />
261 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
262 inner.addRect(10, 30, 10+100, 30+4294967236.f); // <rect x="10" y="30" width="100" height="4294967236" />
263 inner.addRect(10, 30, 10+100, 30+4294967236.f); // <rect x="10" y="30" width="100" height="4294967236" />
264 inner.addRect(10, 30, 10+100, 30+4294967236.f); // <rect x="10" y="30" width="100" height="4294967236" />
265 inner.addRect(10, 30, 10+100, 30+4294967236.f); // <rect x="10" y="30" width="100" height="4294967236" />
266 inner.addRect(10, 30, 10+100, 30+60); // <rect x="10" y="30" width="100" height="60" />
267 inner.addRect(757798030.f, 30, 757798030.f+100, 30+60); // <rect x="757798030" y="30" width="100" height="60" />
268 clipRect.addPath(inner);
269
271 builder.add(clipCircle, kUnion_SkPathOp);
274 builder.resolve(&result);
275}
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1213
SkPath & reset()
Definition: SkPath.cpp:370
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw

◆ DEF_TEST() [6/10]

DEF_TEST ( Issue569540  ,
reporter   
)

Definition at line 277 of file PathOpsBuilderTest.cpp.

277 {
279 path1.moveTo(5, -225);
280 path1.lineTo(-225, 7425);
281 path1.lineTo(7425, 7425);
282 path1.lineTo(7425, -225);
283 path1.lineTo(-225, -225);
284 path1.lineTo(5, -225);
285 path1.close();
286
288 path2.moveTo(5940, 2790);
289 path2.lineTo(5940, 2160);
290 path2.lineTo(5970, 1980);
291 path2.lineTo(5688, 773669888);
292 path2.lineTo(5688, 2160);
293 path2.lineTo(5688, 2430);
294 path2.lineTo(5400, 4590);
295 path2.lineTo(5220, 4590);
296 path2.lineTo(5220, 4920);
297 path2.cubicTo(5182.22900390625f, 4948.328125f, 5160, 4992.78662109375f, 5160, 5040.00048828125f);
298 path2.lineTo(5940, 2790);
299 path2.close();
300
305 builder.resolve(&result);
306}
static SkPath path1()
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
SkPath & cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
Definition: SkPath.cpp:799
SkPath & close()
Definition: SkPath.cpp:823

◆ DEF_TEST() [7/10]

DEF_TEST ( PathOpsBuilder  ,
reporter   
)

Definition at line 16 of file PathOpsBuilderTest.cpp.

16 {
21
25
29
30 SkPath rectPath;
32 rectPath.addRect(0, 1, 2, 3, SkPathDirection::kCW);
33 builder.add(rectPath, kUnion_SkPathOp);
35 bool closed;
37 REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
40 int pixelDiff = comparePaths(reporter, __FUNCTION__, rectPath, result);
41 REPORTER_ASSERT(reporter, pixelDiff == 0);
42
43 rectPath.reset();
45 rectPath.addRect(0, 1, 2, 3, SkPathDirection::kCCW);
46 builder.add(rectPath, kUnion_SkPathOp);
48 REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
51 REPORTER_ASSERT(reporter, rectPath == result);
52
53 builder.add(rectPath, kDifference_SkPathOp);
56
57 SkPath rect2, rect3;
58 rect2.addRect(2, 1, 4, 3, SkPathDirection::kCW);
59 rect3.addRect(4, 1, 5, 3, SkPathDirection::kCCW);
60 builder.add(rectPath, kUnion_SkPathOp);
61 builder.add(rect2, kUnion_SkPathOp);
62 builder.add(rect3, kUnion_SkPathOp);
64 REPORTER_ASSERT(reporter, result.isRect(nullptr, &closed, &dir));
66 SkRect expected;
67 expected.setLTRB(0, 1, 5, 3);
68 REPORTER_ASSERT(reporter, result.getBounds() == expected);
69
70 SkPath circle1, circle2, circle3;
71 circle1.addCircle(5, 6, 4, SkPathDirection::kCW);
72 circle2.addCircle(7, 4, 8, SkPathDirection::kCCW);
73 circle3.addCircle(6, 5, 6, SkPathDirection::kCW);
74 SkPath opCompare;
75 Op(circle1, circle2, kUnion_SkPathOp, &opCompare);
76 Op(opCompare, circle3, kDifference_SkPathOp, &opCompare);
77 builder.add(circle1, kUnion_SkPathOp);
78 builder.add(circle2, kUnion_SkPathOp);
79 builder.add(circle3, kDifference_SkPathOp);
81 pixelDiff = comparePaths(reporter, __FUNCTION__, opCompare, result);
82 REPORTER_ASSERT(reporter, pixelDiff == 0);
83}
SkPathDirection
Definition: SkPathTypes.h:34
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

◆ DEF_TEST() [8/10]

DEF_TEST ( SkOpBuilder618991  ,
reporter   
)

Definition at line 330 of file PathOpsBuilderTest.cpp.

330 {
331 SkPath path0;
332 path0.moveTo(140, 40);
333 path0.lineTo(200, 210);
334 path0.lineTo(40, 100);
335 path0.lineTo(2.22223e+07f, 2.22222e+14f);
336 path0.lineTo(2.22223e+07f, 2.22222e+14f);
337
339 path1.moveTo(160, 60);
340 path1.lineTo(220, 230);
341 path1.lineTo(60, 120);
342 path1.lineTo(2.22223e+07f, 2.22222e+14f);
343 path1.lineTo(2.22223e+07f, 2.22222e+14f);
344
348 builder.resolve(&path0);
349}

◆ DEF_TEST() [9/10]

DEF_TEST ( SkOpBuilderFuzz665  ,
reporter   
)

Definition at line 308 of file PathOpsBuilderTest.cpp.

308 {
309 SkPath path;
310 path.setFillType(SkPathFillType::kEvenOdd);
311path.moveTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50)); // -5.0959e+07f, 2.32235e+07f
312path.lineTo(SkBits2Float(0xcc4264b0), SkBits2Float(0x4bb12e48)); // -5.0959e+07f, 2.32234e+07f
313path.lineTo(SkBits2Float(0xcc4264a7), SkBits2Float(0x4bb12e50)); // -5.0959e+07f, 2.32235e+07f
314path.close();
316 path.reset();
317 path.setFillType(SkPathFillType::kWinding);
318path.moveTo(SkBits2Float(0x43213333), SkBits2Float(0x43080000)); // 161.2f, 136
319path.lineTo(SkBits2Float(0x43038000), SkBits2Float(0x43080000)); // 131.5f, 136
320path.cubicTo(SkBits2Float(0x43038000), SkBits2Float(0x42f00000), SkBits2Float(0x42f16666), SkBits2Float(0x42d53333), SkBits2Float(0x42d3cccd), SkBits2Float(0x42cd6666)); // 131.5f, 120, 120.7f, 106.6f, 105.9f, 102.7f
321path.lineTo(SkBits2Float(0x42e33333), SkBits2Float(0x42940000)); // 113.6f, 74
327 builder.resolve(&result);
328}
static float SkBits2Float(uint32_t bits)
Definition: SkFloatBits.h:48

◆ DEF_TEST() [10/10]

DEF_TEST ( SkOpBuilderKFuzz1  ,
reporter   
)

Definition at line 351 of file PathOpsBuilderTest.cpp.

351 {
352 SkPath path;
353path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000)); // 0, 0
354path.lineTo(SkBits2Float(0x39008001), SkBits2Float(0xd31fbc1d)); // 0.000122547f, -6.86056e+11f
355path.conicTo(SkBits2Float(0x246a205a), SkBits2Float(0x0080d3fb), SkBits2Float(0xce000001), SkBits2Float(0x04d31fbc), SkBits2Float(0x57a82c00)); // 5.07681e-17f, 1.1831e-38f, -5.36871e+08f, 4.9635e-36f, 3.69814e+14f
356 SkPath path0(path);
357 path.reset();
358path.moveTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000)); // 0, 0
359path.cubicTo(SkBits2Float(0x80d3f924), SkBits2Float(0xcecece4f), SkBits2Float(0xcececece), SkBits2Float(0xcececece), SkBits2Float(0x9a9a9ace), SkBits2Float(0x9a9a9a9a)); // -1.94667e-38f, -1.73481e+09f, -1.73483e+09f, -1.73483e+09f, -6.3943e-23f, -6.39427e-23f
360path.moveTo(SkBits2Float(0x9a9a019a), SkBits2Float(0xa59a9a9a)); // -6.36955e-23f, -2.68195e-16f
365 builder.resolve(&path);
366}