Commit Graph

76962 Commits

Author SHA1 Message Date
Matthias Clasen
39b06fbb88 API: Add gsk_path_measure_get_curvature 2023-07-01 16:04:29 -04:00
Matthias Clasen
e4466c2125 Add a test for gsk_curve_offset
The stroker relies on offsetting.
This only tests a few very simple cases.
2023-07-01 16:04:29 -04:00
Matthias Clasen
8110ee78ec Add a test for gsk_curve_reverse
The stroker relies on this working.
2023-07-01 16:04:29 -04:00
Matthias Clasen
e3064c5137 Add a test for tangents of degenerate curves
The stroker relies on these to work.
2023-07-01 16:04:29 -04:00
Matthias Clasen
cf0afb785c curve: Handle degenerate cases
Nothing prevents control points from being identical,
and if that happens, some of our constructions involving
tangents and normals break down. Handle these cases in
get_{start,end}_tangent and offset, for the case of
cubics.
2023-07-01 16:04:29 -04:00
Matthias Clasen
c1ae2f5c4b curve: Add gsk_curve_reverse
This will be used in stroking.
2023-07-01 16:04:29 -04:00
Matthias Clasen
75b73365d9 curve: Add gsk_curve_offset
This method creates an offset curve from an existing
curve by just moving the control points laterally.

This will be used in stroking.
2023-07-01 16:04:29 -04:00
Matthias Clasen
547a034489 Add decomposition tests
We don't have good error bounds for conics,
unfortunately. But we can test that we decompose
into the right curves.
2023-07-01 16:04:29 -04:00
Matthias Clasen
0a2ec0e050 path: Allow limiting curve types in foreach
This is useful if your rendering system can't
handle certain kinds of curves, such as conics.
2023-07-01 16:04:29 -04:00
Matthias Clasen
3d06f5c1f2 curve: Add gsk_curve_decompose_curve
This is mainly useful for decomposing a conic into
cubics. The criterion here for terminating the
subdivision is very improvised.

But it also allows for other use cases, such as
raising the degree of quadratics to cubics.
2023-07-01 16:04:29 -04:00
Matthias Clasen
f863802904 Add a performance test for curve eval
All curve types are equally fast here.
2023-07-01 16:04:29 -04:00
Matthias Clasen
f737e41598 Add a performance test for curve intersection
This shows how much more expensive curve
intersections are.
2023-07-01 16:04:29 -04:00
Matthias Clasen
37377504d9 Add curve split tests 2023-07-01 16:04:29 -04:00
Matthias Clasen
5808463468 Add special-case curve tests 2023-07-01 16:04:29 -04:00
Matthias Clasen
e00e7753c4 Add curve match tests
Add tests that check that the curve api agrees on
values for a quadratic and its equivalent cubic
and conic.
2023-07-01 16:04:29 -04:00
Matthias Clasen
2a6b12c3be Add curve intersection and bounds tests
These tests check that gsk_curve_intersect finds
the intersections we want and get_bounds returns
propert bounding boxes.
2023-07-01 16:04:29 -04:00
Matthias Clasen
de2d2e5ffd curve: Add gsk_curve_intersect
Add a way to find the intersections of two curves.
This will be used in stroking.
2023-07-01 16:04:29 -04:00
Matthias Clasen
4a5fafa2c2 curve: Add gsk_curve_print
Useful for debugging.
2023-07-01 16:04:29 -04:00
Matthias Clasen
cede374079 curve: Add gsk_curve_get_curvature
This will be used in the stroker.
2023-07-01 16:04:29 -04:00
Matthias Clasen
6ff8649d22 curve: Add gsk_curve_get_normal
Its easy but thats no reason not to have this api.
2023-07-01 16:04:29 -04:00
Matthias Clasen
4ba1e5bb8f curve: Add gsk_curve_get_bounds
Add getters for bounding boxes of curves.
2023-07-01 16:04:29 -04:00
Matthias Clasen
554c31b421 curve: Add some curve utilities
These apis will be used in the stroker.
2023-07-01 16:04:29 -04:00
Matthias Clasen
1981d98ed9 Add a bounding box type
graphene_rect_t does not quite work for this purpose.
2023-07-01 16:04:29 -04:00
Matthias Clasen
d705f267c1 Add quadratic curves 2023-07-01 16:04:29 -04:00
Matthias Clasen
321f6a2ab4 Replace GskCurveCurve with GskCubicCurve 2023-07-01 16:04:29 -04:00
Matthias Clasen
96d7506f75 Replace GSK_PATH_FOREACH_ALLOW_CURVE with _CUBIC 2023-07-01 16:04:29 -04:00
Matthias Clasen
a79fafb170 Rename gsk_path_builder_curve_to to _cubic_to 2023-07-01 16:04:29 -04:00
Matthias Clasen
7ccfae2943 Replace GSK_PATH_CURVE by _CUBIC 2023-07-01 16:04:29 -04:00
Matthias Clasen
001ac59a6b pathmeasure: Drop some unused apis
We are not convinced that it is a good idea
to expose the concept of contours, and these
apis are entirely unused, so drop them.
2023-07-01 16:04:29 -04:00
Matthias Clasen
1a85ba7451 curve: Explicitly initialize memory
Unitialized memory warnings aren't fun.
2023-06-30 07:48:31 -04:00
Matthias Clasen
750088f01c Be less demanding in the get_point test
When looking for discontinuities, there
is no need to check for epsilons. As we
move close to the end of one contour / the
beginning of the next, the path length distance
between the two points will get arbitrarily
small, so we can just check that the distance
between the points is more than twice that.

This makes spurious failures of the /path/get_point
test go away.
2023-06-30 07:47:58 -04:00
Matthias Clasen
db2a167ea2 Plug a memory leak in the path tests 2023-06-30 07:47:52 -04:00
Matthias Clasen
cdca291962 Only test conic weights between 1/20 and 20
The rest just give us no end of numeric trouble.
2023-06-30 07:47:44 -04:00
Matthias Clasen
ba5f7d77f8 pathbuilder: Avoid trouble with sincos
The Windows builds seem to have problem with
this handling of sincos(), so do it the same
way we do it elsewere, by defining _sincos().
2023-06-30 07:47:44 -04:00
Matthias Clasen
17726a4330 Make gsk_stroke_to_cairo public
It comes in handy, and does no harm.
2023-06-30 07:47:44 -04:00
Matthias Clasen
b47cbd74c0 Add comment for conic curves 2023-06-30 07:47:04 -04:00
Matthias Clasen
84e8f3db83 Docs: Fix a typo 2023-06-30 07:47:04 -04:00
Matthias Clasen
ae22094fb7 Documentation fixes
gi-docgen can't handle an indent > 2 in continuation lines.
2023-06-30 07:45:12 -04:00
Matthias Clasen
c3061916bc curve: Match skia more precisely
Close reading of sources revealed that we
were not actually using the same conditions
as skia here, causing our measurements to
come out slightly different.

With this change, we are in almost perfect
agreement with skia.
2023-06-30 07:44:21 -04:00
Matthias Clasen
87346d3151 curve: Cosmetic 2023-06-30 07:44:13 -04:00
Matthias Clasen
0f38573008 tests: Less degenerate, please
We were inadvertendly using 95% degenerate paths,
instead of 5%. Oops.
2023-06-30 07:42:52 -04:00
Matthias Clasen
555aa8e409 contour: Reimplement get_winding
Follow the usual implementation more closely,
and drop reporting a separate 'on_edge' bit.

This was wrong in some cases, and we don't
need it. See the testcase in this commit
for a case where 'on_edge' was wrongly
deciding that a point is inside.
2023-06-30 07:42:52 -04:00
Matthias Clasen
efd2f41c54 Add a test for a bad case
This is narrowing down what goes wrong in the
segment test: We have an unevenly parameterized
cubic. This case gave me a lot of trouble.
2023-06-30 07:42:52 -04:00
Matthias Clasen
670058eec7 tests: Handle internal tests better
We have a better way of testing private API now,
by linking statically.
2023-06-30 07:42:52 -04:00
Matthias Clasen
6452f92ee6 Fix a stack overflow in a test
The test_in_fill_rotated test was mistakenly
assuming that conics come with 4 points, when
the only have 3. Oops.
2023-06-30 07:42:52 -04:00
Matthias Clasen
087c81f957 Fix memory overruns in the path parser
It turns out that using strchr() to identify
chars in your string isn't safe since strchr
happily matches the '\0' at the end of the input.

If we are not careful, that makes use walk
off the end of the string.

This issue was found by asan.
2023-06-30 07:42:50 -04:00
Matthias Clasen
4e2e8b2d7b Fix curve tests in release builds
g_test_init sabotages tests in release builds,
we have to use (g_test_init) to avoid the sabotage.

At the same time, we have to avoid using g_assert,
since that's a no-op in release builds.
2023-06-30 07:42:10 -04:00
Matthias Clasen
596ed7244e Fix fp16 with asan
The IFUNC resolvers that we are using here get
run early, before asan had a chance to set up its
plumbing, and therefore things go badly if they
are compiled with asan. Turning it off makes things
work again.

The gcc bug tracking this problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110442
2023-06-30 07:42:10 -04:00
Benjamin Otte
826efc4dff testsuite: Increase tolerances to make the path test work
I dislike the corner cases being so low (lower than 1% and off by a
whole point).
2023-06-19 18:18:44 +02:00
Benjamin Otte
d4705216ed path: Handle segments of degenerate curves via lines
When curves have long straight parts that decompose into a single line,
don't try to split them. Instead, split at a well-known position and a
the part of that long straight line as a line.

This gives way more accurate numbers and is more accurate than 1% for
everything but contours with very small weight and
start_point == end_point, where the error is closer to 1.5%.
2023-06-19 18:18:44 +02:00