blob: 6f2d8963dcf16661d07088c37589089a3fd0cf78 [file] [log] [blame]
senorblancod6ed19c2015-02-26 06:58:17 -08001/*
2 * Copyright 2015 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
Robert Phillips77505da2017-01-20 09:11:37 -05008#include "Test.h"
9
senorblanco0e95b112015-04-20 15:00:06 -070010#include "SkPath.h"
11
Brian Salomonc65aec92017-03-09 09:03:58 -050012#include "GrClip.h"
kkinnunen15302832015-12-01 04:35:26 -080013#include "GrContext.h"
Stephen White73e7f802017-08-23 13:56:07 -040014#include "GrContextPriv.h"
Stephen Whitecc700832017-02-15 11:45:16 -050015#include "SkGradientShader.h"
Florin Malita4aed1382017-05-25 10:38:07 -040016#include "SkShaderBase.h"
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040017#include "effects/GrPorterDuffXferProcessor.h"
Brian Salomonc65aec92017-03-09 09:03:58 -050018#include "ops/GrTessellatingPathRenderer.h"
senorblancod6ed19c2015-02-26 06:58:17 -080019
20/*
21 * These tests pass by not crashing, hanging or asserting in Debug.
22 */
23
24// Tests active edges made inactive by splitting.
25// Also tests active edge list forced into an invalid ordering by
26// splitting (mopped up in cleanup_active_edges()).
27static SkPath create_path_0() {
28 SkPath path;
29 path.moveTo(229.127044677734375f, 67.34100341796875f);
30 path.lineTo(187.8097381591796875f, -6.7729740142822265625f);
31 path.lineTo(171.411407470703125f, 50.94266510009765625f);
32 path.lineTo(245.5253753662109375f, 9.6253643035888671875f);
33 path.moveTo(208.4683990478515625f, 30.284009933471679688f);
34 path.lineTo(171.411407470703125f, 50.94266510009765625f);
35 path.lineTo(187.8097381591796875f, -6.7729740142822265625f);
36 return path;
37}
38
39// Intersections which fall exactly on the current vertex, and require
40// a restart of the intersection checking.
41static SkPath create_path_1() {
42 SkPath path;
43 path.moveTo(314.483551025390625f, 486.246002197265625f);
44 path.lineTo(385.41949462890625f, 532.8087158203125f);
45 path.lineTo(373.232879638671875f, 474.05938720703125f);
46 path.lineTo(326.670166015625f, 544.995361328125f);
47 path.moveTo(349.951507568359375f, 509.52734375f);
48 path.lineTo(373.232879638671875f, 474.05938720703125f);
49 path.lineTo(385.41949462890625f, 532.8087158203125f);
50 return path;
51}
52
53// Tests active edges which are removed by splitting.
54static SkPath create_path_2() {
55 SkPath path;
56 path.moveTo(343.107391357421875f, 613.62176513671875f);
57 path.lineTo(426.632415771484375f, 628.5740966796875f);
58 path.lineTo(392.3460693359375f, 579.33544921875f);
59 path.lineTo(377.39373779296875f, 662.86041259765625f);
60 path.moveTo(384.869873046875f, 621.097900390625f);
61 path.lineTo(392.3460693359375f, 579.33544921875f);
62 path.lineTo(426.632415771484375f, 628.5740966796875f);
63 return path;
64}
65
66// Collinear edges merged in set_top().
67// Also, an intersection between left and right enclosing edges which
68// falls above the current vertex.
69static SkPath create_path_3() {
70 SkPath path;
71 path.moveTo(545.95751953125f, 791.69854736328125f);
72 path.lineTo(612.05816650390625f, 738.494140625f);
73 path.lineTo(552.4056396484375f, 732.0460205078125f);
74 path.lineTo(605.61004638671875f, 798.14666748046875f);
75 path.moveTo(579.00787353515625f, 765.0963134765625f);
76 path.lineTo(552.4056396484375f, 732.0460205078125f);
77 path.lineTo(612.05816650390625f, 738.494140625f);
78 return path;
79}
80
81// Tests active edges which are made inactive by set_top().
82static SkPath create_path_4() {
83 SkPath path;
84 path.moveTo(819.2725830078125f, 751.77447509765625f);
85 path.lineTo(820.70904541015625f, 666.933837890625f);
86 path.lineTo(777.57049560546875f, 708.63592529296875f);
87 path.lineTo(862.4111328125f, 710.0723876953125f);
88 path.moveTo(819.99078369140625f, 709.3541259765625f);
89 path.lineTo(777.57049560546875f, 708.63592529296875f);
90 path.lineTo(820.70904541015625f, 666.933837890625f);
91 return path;
92}
93
94static SkPath create_path_5() {
95 SkPath path;
96 path.moveTo(823.33209228515625f, 749.052734375f);
97 path.lineTo(823.494873046875f, 664.20013427734375f);
98 path.lineTo(780.9871826171875f, 706.5450439453125f);
99 path.lineTo(865.8397216796875f, 706.70782470703125f);
100 path.moveTo(823.4134521484375f, 706.6263427734375f);
101 path.lineTo(780.9871826171875f, 706.5450439453125f);
102 path.lineTo(823.494873046875f, 664.20013427734375f);
103 return path;
104}
105
106static SkPath create_path_6() {
107 SkPath path;
108 path.moveTo(954.862548828125f, 562.8349609375f);
109 path.lineTo(899.32818603515625f, 498.679443359375f);
110 path.lineTo(895.017578125f, 558.52435302734375f);
111 path.lineTo(959.17315673828125f, 502.990081787109375f);
112 path.moveTo(927.0953369140625f, 530.7572021484375f);
113 path.lineTo(895.017578125f, 558.52435302734375f);
114 path.lineTo(899.32818603515625f, 498.679443359375f);
115 return path;
116}
117
118static SkPath create_path_7() {
119 SkPath path;
120 path.moveTo(958.5330810546875f, 547.35516357421875f);
121 path.lineTo(899.93109130859375f, 485.989013671875f);
122 path.lineTo(898.54901123046875f, 545.97308349609375f);
123 path.lineTo(959.9151611328125f, 487.37109375f);
124 path.moveTo(929.2320556640625f, 516.67205810546875f);
125 path.lineTo(898.54901123046875f, 545.97308349609375f);
126 path.lineTo(899.93109130859375f, 485.989013671875f);
127 return path;
128}
129
130static SkPath create_path_8() {
131 SkPath path;
132 path.moveTo(389.8609619140625f, 369.326873779296875f);
133 path.lineTo(470.6290283203125f, 395.33697509765625f);
134 path.lineTo(443.250030517578125f, 341.9478759765625f);
135 path.lineTo(417.239959716796875f, 422.7159423828125f);
136 path.moveTo(430.244964599609375f, 382.3319091796875f);
137 path.lineTo(443.250030517578125f, 341.9478759765625f);
138 path.lineTo(470.6290283203125f, 395.33697509765625f);
139 return path;
140}
141
142static SkPath create_path_9() {
143 SkPath path;
144 path.moveTo(20, 20);
145 path.lineTo(50, 80);
146 path.lineTo(20, 80);
147 path.moveTo(80, 50);
148 path.lineTo(50, 50);
149 path.lineTo(20, 50);
150 return path;
151}
152
153static SkPath create_path_10() {
154 SkPath path;
155 path.moveTo(257.19439697265625f, 320.876617431640625f);
156 path.lineTo(190.113037109375f, 320.58978271484375f);
157 path.lineTo(203.64404296875f, 293.8145751953125f);
158 path.moveTo(203.357177734375f, 360.896026611328125f);
159 path.lineTo(216.88824462890625f, 334.120819091796875f);
160 path.lineTo(230.41925048828125f, 307.345611572265625f);
161 return path;
162}
163
164// A degenerate segments case, where both upper and lower segments of
165// a split edge must remain active.
166static SkPath create_path_11() {
167 SkPath path;
168 path.moveTo(231.9331207275390625f, 306.2012939453125f);
169 path.lineTo(191.4859161376953125f, 306.04547119140625f);
170 path.lineTo(231.0659332275390625f, 300.2642822265625f);
171 path.moveTo(189.946807861328125f, 302.072265625f);
172 path.lineTo(179.79705810546875f, 294.859771728515625f);
173 path.lineTo(191.0016021728515625f, 296.165679931640625f);
174 path.moveTo(150.8942108154296875f, 304.900146484375f);
175 path.lineTo(179.708892822265625f, 297.849029541015625f);
176 path.lineTo(190.4742279052734375f, 299.11895751953125f);
177 return path;
178}
179
180// Handle the case where edge.dist(edge.fTop) != 0.0.
181static SkPath create_path_12() {
182 SkPath path;
183 path.moveTo( 0.0f, 400.0f);
184 path.lineTo( 138.0f, 202.0f);
185 path.lineTo( 0.0f, 202.0f);
186 path.moveTo( 12.62693023681640625f, 250.57464599609375f);
187 path.lineTo( 8.13896942138671875f, 254.556884765625f);
188 path.lineTo(-18.15641021728515625f, 220.40203857421875f);
189 path.lineTo(-15.986493110656738281f, 219.6513519287109375f);
190 path.moveTo( 36.931194305419921875f, 282.485504150390625f);
191 path.lineTo( 15.617521286010742188f, 261.2901611328125f);
192 path.lineTo( 10.3829498291015625f, 252.565765380859375f);
193 path.lineTo(-16.165292739868164062f, 222.646026611328125f);
194 return path;
195}
196
197// A degenerate segments case which exercises inactive edges being
198// made active by splitting.
199static SkPath create_path_13() {
200 SkPath path;
201 path.moveTo(690.62127685546875f, 509.25555419921875f);
202 path.lineTo(99.336181640625f, 511.71405029296875f);
203 path.lineTo(708.362548828125f, 512.4349365234375f);
204 path.lineTo(729.9940185546875f, 516.3114013671875f);
205 path.lineTo(738.708984375f, 518.76995849609375f);
206 path.lineTo(678.3463134765625f, 510.0819091796875f);
207 path.lineTo(681.21795654296875f, 504.81378173828125f);
208 path.moveTo(758.52764892578125f, 521.55963134765625f);
209 path.lineTo(719.1549072265625f, 514.50372314453125f);
210 path.lineTo(689.59063720703125f, 512.0628662109375f);
211 path.lineTo(679.78216552734375f, 507.447845458984375f);
212 return path;
213}
214
215// Tests vertices which become "orphaned" (ie., no connected edges)
216// after simplification.
217static SkPath create_path_14() {
218 SkPath path;
219 path.moveTo(217.326019287109375f, 166.4752960205078125f);
220 path.lineTo(226.279266357421875f, 170.929473876953125f);
221 path.lineTo(234.3973388671875f, 177.0623626708984375f);
222 path.lineTo(262.0921630859375f, 188.746124267578125f);
223 path.moveTo(196.23638916015625f, 174.0722198486328125f);
224 path.lineTo(416.15277099609375f, 180.138214111328125f);
225 path.lineTo(192.651947021484375f, 304.0228271484375f);
226 return path;
227}
228
senorblancoa2b6d282015-03-02 09:34:13 -0800229static SkPath create_path_15() {
230 SkPath path;
231 path.moveTo( 0.0f, 0.0f);
232 path.lineTo(10000.0f, 0.0f);
233 path.lineTo( 0.0f, -1.0f);
234 path.lineTo(10000.0f, 0.000001f);
235 path.lineTo( 0.0f, -30.0f);
236 return path;
237}
238
senorblanco70f52512016-08-17 14:56:22 -0700239// Reduction of Nebraska-StateSeal.svg. Floating point error causes the
240// same edge to be added to more than one poly on the same side.
241static SkPath create_path_16() {
242 SkPath path;
243 path.moveTo(170.8199920654296875, 491.86700439453125);
244 path.lineTo(173.7649993896484375, 489.7340087890625);
245 path.lineTo(174.1450958251953125, 498.545989990234375);
246 path.lineTo( 171.998992919921875, 500.88201904296875);
247 path.moveTo(168.2922515869140625, 498.66265869140625);
248 path.lineTo(169.8589935302734375, 497.94500732421875);
249 path.lineTo( 172, 500.88299560546875);
250 path.moveTo( 169.555267333984375, 490.70111083984375);
251 path.lineTo(173.7649993896484375, 489.7340087890625);
252 path.lineTo( 170.82000732421875, 491.86700439453125);
253 return path;
254}
255
Stephen Whitecc700832017-02-15 11:45:16 -0500256// A simple concave path. Test this with a non-invertible matrix.
257static SkPath create_path_17() {
258 SkPath path;
259 path.moveTo(20, 20);
260 path.lineTo(80, 20);
261 path.lineTo(30, 30);
262 path.lineTo(20, 80);
263 return path;
264}
265
Stephen White64dbb892017-05-03 16:00:38 -0400266// A shape with a vertex collinear to the right hand edge.
267// This messes up find_enclosing_edges.
268static SkPath create_path_18() {
269 SkPath path;
270 path.moveTo(80, 20);
271 path.lineTo(80, 60);
272 path.lineTo(20, 60);
273 path.moveTo(80, 50);
274 path.lineTo(80, 80);
275 path.lineTo(20, 80);
276 return path;
277}
278
Stephen White6eca90f2017-05-25 14:47:11 -0400279// Exercises the case where an edge becomes collinear with *two* of its
280// adjacent neighbour edges after splitting.
281// This is a reduction from
282// http://mooooo.ooo/chebyshev-sine-approximation/horner_ulp.svg
283static SkPath create_path_19() {
284 SkPath path;
285 path.moveTo( 351.99298095703125, 348.23046875);
286 path.lineTo( 351.91876220703125, 347.33984375);
287 path.lineTo( 351.91876220703125, 346.1953125);
288 path.lineTo( 351.90313720703125, 347.734375);
289 path.lineTo( 351.90313720703125, 346.1328125);
290 path.lineTo( 351.87579345703125, 347.93359375);
291 path.lineTo( 351.87579345703125, 345.484375);
292 path.lineTo( 351.86407470703125, 347.7890625);
293 path.lineTo( 351.86407470703125, 346.2109375);
294 path.lineTo( 351.84844970703125, 347.63763427734375);
295 path.lineTo( 351.84454345703125, 344.19232177734375);
296 path.lineTo( 351.78204345703125, 346.9483642578125);
297 path.lineTo( 351.758636474609375, 347.18310546875);
298 path.lineTo( 351.75469970703125, 346.75);
299 path.lineTo( 351.75469970703125, 345.46875);
300 path.lineTo( 352.5546875, 345.46875);
301 path.lineTo( 352.55078125, 347.01953125);
302 path.lineTo( 351.75079345703125, 347.02313232421875);
303 path.lineTo( 351.74688720703125, 346.15203857421875);
304 path.lineTo( 351.74688720703125, 347.646148681640625);
305 path.lineTo( 352.5390625, 346.94140625);
306 path.lineTo( 351.73907470703125, 346.94268798828125);
307 path.lineTo( 351.73516845703125, 344.48565673828125);
308 path.lineTo( 352.484375, 346.73828125);
309 path.lineTo( 351.68438720703125, 346.7401123046875);
310 path.lineTo( 352.4765625, 346.546875);
311 path.lineTo( 351.67657470703125, 346.54937744140625);
312 path.lineTo( 352.47265625, 346.75390625);
313 path.lineTo( 351.67266845703125, 346.756622314453125);
314 path.lineTo( 351.66876220703125, 345.612091064453125);
315 return path;
316}
317
Stephen White019f6c02017-06-09 10:06:26 -0400318// An intersection above the first vertex in the mesh.
319// Reduction from http://crbug.com/730687
Stephen White0cb31672017-06-08 14:41:01 -0400320static SkPath create_path_20() {
321 SkPath path;
322 path.moveTo( 2822128.5, 235.026336669921875);
323 path.lineTo( 2819349.25, 235.3623504638671875);
324 path.lineTo( -340558688, 23.83478546142578125);
325 path.lineTo( -340558752, 25.510419845581054688);
326 path.lineTo( -340558720, 27.18605804443359375);
327 return path;
328}
329
Stephen Whitee3a0be72017-06-12 11:43:18 -0400330// An intersection whose result is NaN (due to rounded-to-inf endpoint).
331static SkPath create_path_21() {
332 SkPath path;
333 path.moveTo(1.7889142061167663539e+38, 39338463358011572224.0);
334 path.lineTo( 1647.4193115234375, -522.603515625);
335 path.lineTo( 1677.74560546875, -529.0028076171875);
336 path.lineTo( 1678.29541015625, -528.7847900390625);
337 path.lineTo( 1637.5167236328125, -519.79266357421875);
338 path.lineTo( 1647.4193115234375, -522.603515625);
339 return path;
340}
341
342// A quad which becomes NaN when interpolated.
343static SkPath create_path_22() {
344 SkPath path;
345 path.moveTo(-5.71889e+13f, 1.36759e+09f);
346 path.quadTo(2.45472e+19f, -3.12406e+15f, -2.19589e+18f, 2.79462e+14f);
347 return path;
348}
349
Stephen White3f5301b2017-08-15 17:01:15 -0400350// A path which contains out-of-range colinear intersections.
351static SkPath create_path_23() {
352 SkPath path;
353 path.moveTo( 0, 63.39080047607421875);
354 path.lineTo(-0.70804601907730102539, 63.14350128173828125);
355 path.lineTo(-7.8608899287380243391e-17, 64.14080047607421875);
356 path.moveTo( 0, 64.14080047607421875);
357 path.lineTo(44.285900115966796875, 64.14080047607421875);
358 path.lineTo( 0, 62.64080047607421875);
359 path.moveTo(21.434900283813476562, -0.24732701480388641357);
360 path.lineTo(-0.70804601907730102539, 63.14350128173828125);
361 path.lineTo(0.70804601907730102539, 63.6381988525390625);
362 return path;
363}
364
Stephen White73e7f802017-08-23 13:56:07 -0400365// A path which results in infs and nans when conics are converted to quads.
366static SkPath create_path_24() {
367 SkPath path;
368 path.moveTo(-2.20883e+37f, -1.02892e+37f);
369 path.conicTo(-2.00958e+38f, -9.36107e+37f, -1.7887e+38f, -8.33215e+37f, 0.707107f);
370 path.conicTo(-1.56782e+38f, -7.30323e+37f, 2.20883e+37f, 1.02892e+37f, 0.707107f);
371 path.conicTo(2.00958e+38f, 9.36107e+37f, 1.7887e+38f, 8.33215e+37f, 0.707107f);
372 path.conicTo(1.56782e+38f, 7.30323e+37f, -2.20883e+37f, -1.02892e+37f, 0.707107f);
373 return path;
374}
375
Stephen Whitee260c462017-12-19 18:09:54 -0500376// An edge collapse event which also collapses a neighbour, requiring
377// its event to be removed.
378static SkPath create_path_25() {
379 SkPath path;
380 path.moveTo( 43.44110107421875, 148.15106201171875);
381 path.lineTo( 44.64471435546875, 148.16748046875);
382 path.lineTo( 46.35009765625, 147.403076171875);
383 path.lineTo( 46.45404052734375, 148.34906005859375);
384 path.lineTo( 45.0400390625, 148.54205322265625);
385 path.lineTo( 44.624053955078125, 148.9810791015625);
386 path.lineTo( 44.59405517578125, 149.16107177734375);
387 path.lineTo( 44.877044677734375, 149.62005615234375);
388 path.lineTo(144.373016357421875, 68.8070068359375);
389 return path;
390}
391
392// An edge collapse event causes an edge to become collinear, requiring
393// its event to be removed.
394static SkPath create_path_26() {
395 SkPath path;
396 path.moveTo( 43.44110107421875, 148.15106201171875);
397 path.lineTo( 44.64471435546875, 148.16748046875);
398 path.lineTo( 46.35009765625, 147.403076171875);
399 path.lineTo( 46.45404052734375, 148.34906005859375);
400 path.lineTo( 45.0400390625, 148.54205322265625);
401 path.lineTo( 44.624053955078125, 148.9810791015625);
402 path.lineTo( 44.59405517578125, 149.16107177734375);
403 path.lineTo( 44.877044677734375, 149.62005615234375);
404 path.lineTo(144.373016357421875, 68.8070068359375);
405 return path;
406}
407
Stephen White94b7e542018-01-04 14:01:10 -0500408// A path which results in non-finite points when stroked and bevelled for AA.
409static SkPath create_path_27() {
410 SkPath path;
411 path.moveTo(8.5027233009104409507e+37, 1.7503381025241130639e+37);
412 path.lineTo(7.0923661737711584874e+37, 1.4600074517285415699e+37);
413 path.lineTo(7.0848733446033294691e+37, 1.4584649744781838604e+37);
414 path.lineTo(-2.0473916115129349496e+37, -4.2146796450364162012e+36);
415 path.lineTo(2.0473912312177548811e+37, 4.2146815465123165435e+36);
416 return path;
417}
Stephen Whitef470b7e2018-01-04 16:45:51 -0500418
419// AA stroking this path produces intersection failures on bevelling.
420// This should skip the point, but not assert.
421static SkPath create_path_28() {
422 SkPath path;
423 path.moveTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24);
424 path.lineTo( 1260.3787841796875, 1727.7947998046875);
425 path.lineTo( 1260.5567626953125, 1728.0386962890625);
426 path.lineTo(1.1482511310557754163e+21, 4.054538502765980051e+23);
427 path.lineTo(-7.5952312625177475154e+21, -2.6819185100266674911e+24);
428 return path;
429}
Stephen Whitee40c3612018-01-09 11:49:08 -0500430
431// A quad which generates a huge number of points (>2B) when uniformly
432// linearized. This should not hang or OOM.
433static SkPath create_path_29() {
434 SkPath path;
435 path.moveTo(10, 0);
436 path.lineTo(0, 0);
437 path.quadTo(10, 0, 0, 8315084722602508288);
438 return path;
439}
440
Stephen White20010e82018-03-28 14:41:22 -0400441// A path which hangs during simplification. It produces an edge which is
442// to the left of its own endpoints, which causes an infinte loop in the
443// right-enclosing-edge splitting.
444static SkPath create_path_30() {
445 SkPath path;
446 path.moveTo(0.75001740455627441406, 23.051967620849609375);
447 path.lineTo(5.8471612930297851562, 22.731662750244140625);
448 path.lineTo(10.749670028686523438, 22.253145217895507812);
449 path.lineTo(13.115868568420410156, 22.180681228637695312);
450 path.lineTo(15.418928146362304688, 22.340015411376953125);
451 path.lineTo( 17.654022216796875, 22.82159423828125);
452 path.lineTo(19.81632232666015625, 23.715869903564453125);
453 path.lineTo(40, 0);
454 path.lineTo(5.5635203441547955577e-15, 0);
455 path.lineTo(5.5635203441547955577e-15, 47);
456 path.lineTo(-1.4210854715202003717e-14, 21.713298797607421875);
457 path.lineTo(0.75001740455627441406, 21.694292068481445312);
458 path.lineTo(0.75001740455627441406, 23.051967620849609375);
459 return path;
460}
461
Stephen Whiteea495232018-04-03 11:28:15 -0400462// A path with vertices which become infinite on AA stroking. Should not crash or assert.
463static SkPath create_path_31() {
464 SkPath path;
465 path.moveTo(2.0257809259190991347e+36, -1244080640);
466 path.conicTo(2.0257809259190991347e+36, -1244080640,
467 2.0257809259190991347e+36, 0.10976474732160568237, 0.70710676908493041992);
468 path.lineTo(-10036566016, -1954718402215936);
469 path.conicTo(-1.1375507718551896064e+20, -1954721086570496,
470 10036566016, -1954721086570496, 0.70710676908493041992);
471 return path;
472}
473
Stephen Whiteec79c392018-05-18 11:49:21 -0400474// Reduction from skbug.com/7911 that causes a crash due to splitting a
475// zombie edge.
476static SkPath create_path_32() {
477 SkPath path;
478 path.moveTo( 0, 1.0927740941146660348e+24);
479 path.lineTo(2.9333931225865729333e+32, 16476101);
480 path.lineTo(1.0927731573659435417e+24, 1.0927740941146660348e+24);
481 path.lineTo(1.0927740941146660348e+24, 3.7616281094287041715e-37);
482 path.lineTo(1.0927740941146660348e+24, 1.0927740941146660348e+24);
483 path.lineTo(1.3061803026169399536e-33, 1.0927740941146660348e+24);
484 path.lineTo(4.7195362919941370727e-16, -8.4247545146051822591e+32);
485 return path;
486}
487
Stephen White7b376942018-05-22 11:51:32 -0400488// From crbug.com/844873. Crashes trying to merge a zombie edge.
489static SkPath create_path_33() {
490 SkPath path;
491 path.moveTo( 316.000579833984375, -4338355948977389568);
492 path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0);
493 path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0);
494 path.lineTo( 771.21014404296875, -4338355948977389568.0);
495 path.lineTo( 316.000579833984375, -4338355948977389568.0);
496 path.moveTo( 354.208984375, -4338355948977389568.0);
497 path.lineTo( 773.00177001953125, -4338355948977389568.0);
498 path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0);
499 path.lineTo(1.5069369808623501312e+20, 75180972320904708096.0);
500 path.lineTo( 354.208984375, -4338355948977389568.0);
501 return path;
502}
503
Stephen White53a02982018-05-30 22:47:46 -0400504// From crbug.com/844873. Hangs repeatedly splitting alternate vertices.
505static SkPath create_path_34() {
506 SkPath path;
507 path.moveTo(10, -1e+20f);
508 path.lineTo(11, 25000);
509 path.lineTo(10, 25000);
510 path.lineTo(11, 25010);
511 return path;
512}
513
514// Reduction from circular_arcs_stroke_and_fill_round GM which
515// repeatedly splits on the opposite edge from case 34 above.
516static SkPath create_path_35() {
517 SkPath path;
518 path.moveTo( 16.25, 26.495191574096679688);
519 path.lineTo(32.420825958251953125, 37.377376556396484375);
520 path.lineTo(25.176382064819335938, 39.31851959228515625);
521 path.moveTo( 20, 20);
522 path.lineTo(28.847436904907226562, 37.940830230712890625);
523 path.lineTo(25.17638397216796875, 39.31851959228515625);
524 return path;
525}
526
Stephen Whitee62999f2018-06-05 18:45:07 -0400527// Reduction from crbug.com/843135 where an intersection is found
528// below the bottom of both intersected edges.
529static SkPath create_path_36() {
530 SkPath path;
531 path.moveTo(-2791476679359332352, 2608107002026524672);
532 path.lineTo( 0, 11.95427703857421875);
533 path.lineTo(-2781824066779086848, 2599088532777598976);
534 path.lineTo( -7772.6875, 7274);
535 return path;
536}
537
Stephen White89042d52018-06-08 12:18:22 -0400538// Reduction from crbug.com/843135. Exercises a case where an intersection is missed.
539// This causes bad ordering in the active edge list.
540static SkPath create_path_37() {
541 SkPath path;
542 path.moveTo(-1.0662557646016024569e+23, 9.9621425197286319718e+22);
543 path.lineTo( -121806400, 113805032);
544 path.lineTo( -120098872, 112209680);
545 path.lineTo( 6.2832999862817380468e-36, 2.9885697364807128906);
546 return path;
547}
548
Brian Salomonaff329b2017-08-11 09:40:37 -0400549static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) {
Stephen Whitee260c462017-12-19 18:09:54 -0500550
Stephen Whitecc700832017-02-15 11:45:16 -0500551 SkPoint pts[2] = { {0, 0}, {1, 1} };
552 SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
553 sk_sp<SkShader> shader = SkGradientShader::MakeLinear(
554 pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
Brian Salomon4cbb6e62017-10-25 15:12:19 -0400555 GrColorSpaceInfo colorSpaceInfo(nullptr, kRGBA_8888_GrPixelConfig);
Florin Malitac6c5ead2018-04-11 15:33:40 -0400556 GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo);
Florin Malita4aed1382017-05-25 10:38:07 -0400557 return as_SB(shader)->asFragmentProcessor(args);
Stephen Whitecc700832017-02-15 11:45:16 -0500558}
559
Robert Phillips256c37b2017-03-01 14:32:46 -0500560static void test_path(GrContext* ctx,
Stephen Whitecc700832017-02-15 11:45:16 -0500561 GrRenderTargetContext* renderTargetContext,
562 const SkPath& path,
563 const SkMatrix& matrix = SkMatrix::I(),
564 GrAAType aaType = GrAAType::kNone,
Brian Salomonaff329b2017-08-11 09:40:37 -0400565 std::unique_ptr<GrFragmentProcessor> fp = nullptr) {
senorblancod6ed19c2015-02-26 06:58:17 -0800566 GrTessellatingPathRenderer tess;
robertphillips976f5f02016-06-03 10:59:20 -0700567
568 GrPaint paint;
Brian Salomona1633922017-01-09 11:46:10 -0500569 paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
Stephen Whitecc700832017-02-15 11:45:16 -0500570 if (fp) {
Brian Salomonaff329b2017-08-11 09:40:37 -0400571 paint.addColorFragmentProcessor(std::move(fp));
Stephen Whitecc700832017-02-15 11:45:16 -0500572 }
robertphillips976f5f02016-06-03 10:59:20 -0700573
cdalton846c0512016-05-13 10:25:00 -0700574 GrNoClip noClip;
Chris Daltondb91c6e2017-09-08 16:25:08 -0600575 SkIRect clipConservativeBounds = SkIRect::MakeWH(renderTargetContext->width(),
576 renderTargetContext->height());
bsalomon6663acf2016-05-10 09:14:17 -0700577 GrStyle style(SkStrokeRec::kFill_InitStyle);
bsalomon8acedde2016-06-24 10:42:16 -0700578 GrShape shape(path, style);
Robert Phillips256c37b2017-03-01 14:32:46 -0500579 GrPathRenderer::DrawPathArgs args{ctx,
Brian Salomon82f44312017-01-11 13:42:54 -0500580 std::move(paint),
581 &GrUserStencilSettings::kUnused,
582 renderTargetContext,
583 &noClip,
Chris Daltondb91c6e2017-09-08 16:25:08 -0600584 &clipConservativeBounds,
Stephen Whitecc700832017-02-15 11:45:16 -0500585 &matrix,
Brian Salomon82f44312017-01-11 13:42:54 -0500586 &shape,
Stephen Whitecc700832017-02-15 11:45:16 -0500587 aaType,
Brian Salomon82f44312017-01-11 13:42:54 -0500588 false};
bsalomon0aff2fa2015-07-31 06:48:27 -0700589 tess.drawPath(args);
senorblancod6ed19c2015-02-26 06:58:17 -0800590}
591
bsalomonfda88072016-04-11 14:40:50 -0700592DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
Robert Phillips77505da2017-01-20 09:11:37 -0500593 GrContext* ctx = ctxInfo.grContext();
Robert Phillips0c4b7b12018-03-06 08:20:37 -0500594 sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
Brian Salomonbdecacf2018-02-02 20:32:49 -0500595 SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
596 kTopLeft_GrSurfaceOrigin));
Brian Osman11052242016-10-27 14:47:55 -0400597 if (!rtc) {
robertphillips87f15c82016-05-20 11:14:33 -0700598 return;
599 }
600
Robert Phillips77505da2017-01-20 09:11:37 -0500601 ctx->flush();
Greg Danielf44cb482018-02-27 14:26:32 -0500602 // Adding discard to appease vulkan validation warning about loading uninitialized data on draw
603 rtc->discard();
604
Robert Phillips256c37b2017-03-01 14:32:46 -0500605 test_path(ctx, rtc.get(), create_path_0());
606 test_path(ctx, rtc.get(), create_path_1());
607 test_path(ctx, rtc.get(), create_path_2());
608 test_path(ctx, rtc.get(), create_path_3());
609 test_path(ctx, rtc.get(), create_path_4());
610 test_path(ctx, rtc.get(), create_path_5());
611 test_path(ctx, rtc.get(), create_path_6());
612 test_path(ctx, rtc.get(), create_path_7());
613 test_path(ctx, rtc.get(), create_path_8());
614 test_path(ctx, rtc.get(), create_path_9());
615 test_path(ctx, rtc.get(), create_path_10());
616 test_path(ctx, rtc.get(), create_path_11());
617 test_path(ctx, rtc.get(), create_path_12());
618 test_path(ctx, rtc.get(), create_path_13());
619 test_path(ctx, rtc.get(), create_path_14());
620 test_path(ctx, rtc.get(), create_path_15());
621 test_path(ctx, rtc.get(), create_path_16());
Stephen Whitecc700832017-02-15 11:45:16 -0500622 SkMatrix nonInvertibleMatrix = SkMatrix::MakeScale(0, 0);
Brian Salomonaff329b2017-08-11 09:40:37 -0400623 std::unique_ptr<GrFragmentProcessor> fp(create_linear_gradient_processor(ctx));
624 test_path(ctx, rtc.get(), create_path_17(), nonInvertibleMatrix, GrAAType::kCoverage,
625 std::move(fp));
Stephen White64dbb892017-05-03 16:00:38 -0400626 test_path(ctx, rtc.get(), create_path_18());
Stephen White6eca90f2017-05-25 14:47:11 -0400627 test_path(ctx, rtc.get(), create_path_19());
Stephen White0cb31672017-06-08 14:41:01 -0400628 test_path(ctx, rtc.get(), create_path_20(), SkMatrix(), GrAAType::kCoverage);
Stephen Whitee3a0be72017-06-12 11:43:18 -0400629 test_path(ctx, rtc.get(), create_path_21(), SkMatrix(), GrAAType::kCoverage);
630 test_path(ctx, rtc.get(), create_path_22());
Stephen White3f5301b2017-08-15 17:01:15 -0400631 test_path(ctx, rtc.get(), create_path_23());
Greg Daniel6888c0d2017-08-25 11:55:50 -0400632 test_path(ctx, rtc.get(), create_path_24());
Stephen Whitee260c462017-12-19 18:09:54 -0500633 test_path(ctx, rtc.get(), create_path_25(), SkMatrix(), GrAAType::kCoverage);
634 test_path(ctx, rtc.get(), create_path_26(), SkMatrix(), GrAAType::kCoverage);
Stephen White94b7e542018-01-04 14:01:10 -0500635 test_path(ctx, rtc.get(), create_path_27(), SkMatrix(), GrAAType::kCoverage);
Stephen Whitef470b7e2018-01-04 16:45:51 -0500636 test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), GrAAType::kCoverage);
Stephen Whitee40c3612018-01-09 11:49:08 -0500637 test_path(ctx, rtc.get(), create_path_29());
Stephen White20010e82018-03-28 14:41:22 -0400638 test_path(ctx, rtc.get(), create_path_30());
Stephen Whiteea495232018-04-03 11:28:15 -0400639 test_path(ctx, rtc.get(), create_path_31(), SkMatrix(), GrAAType::kCoverage);
Stephen Whiteec79c392018-05-18 11:49:21 -0400640 test_path(ctx, rtc.get(), create_path_32());
Stephen White7b376942018-05-22 11:51:32 -0400641 test_path(ctx, rtc.get(), create_path_33());
Stephen White53a02982018-05-30 22:47:46 -0400642 test_path(ctx, rtc.get(), create_path_34());
643 test_path(ctx, rtc.get(), create_path_35());
Stephen Whitee62999f2018-06-05 18:45:07 -0400644 test_path(ctx, rtc.get(), create_path_36());
Stephen White89042d52018-06-08 12:18:22 -0400645 test_path(ctx, rtc.get(), create_path_37());
senorblancod6ed19c2015-02-26 06:58:17 -0800646}