Commit Graph

72760 Commits

Author SHA1 Message Date
Matthias Clasen
e9a010eb67 curve: Add gsk_curve_get_curvature
This will be used in the stroker.
2022-04-08 16:44:28 -04:00
Matthias Clasen
282be569f6 curve: Add gsk_curve_get_normal
Its easy but thats no reason not to have this api.
2022-04-08 16:44:28 -04:00
Matthias Clasen
f2069508cf Add a test for gsk_curve_offset
The stroker relies on offsetting.
This only tests a few very simple cases.
2022-04-08 16:44:28 -04:00
Matthias Clasen
56f587a5a3 Add a test for gsk_curve_reverse
The stroker relies on this working.
2022-04-08 16:44:28 -04:00
Matthias Clasen
64807abc59 Add a test for tangents of degenerate curves
The stroker relies on these to work.
2022-04-08 16:44:28 -04:00
Matthias Clasen
2cace6bada 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.
2022-04-08 16:44:28 -04:00
Matthias Clasen
b1363aadeb curve: Add gsk_curve_reverse
This will be used in stroking.
2022-04-08 16:44:28 -04:00
Matthias Clasen
e44be94835 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.
2022-04-08 16:44:28 -04:00
Matthias Clasen
ffc663b5c5 Add conic decomposition tests
We don't have good error bounds here, unfortunately.
2022-04-08 16:44:28 -04:00
Matthias Clasen
fcf43c4012 path: support conic->curve in foreach 2022-04-08 16:44:28 -04:00
Matthias Clasen
a9c36f8ba9 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.
2022-04-08 16:44:28 -04:00
Matthias Clasen
72835f321f Add a performance test for curve eval
All curve types are equally fast here.
2022-04-08 16:44:28 -04:00
Matthias Clasen
8069495f76 Add a performance test for curve intersection
This shows how much more expensive curve
intersections are.
2022-04-08 16:44:28 -04:00
Matthias Clasen
6a51dfc929 Add curve split tests 2022-04-08 16:44:28 -04:00
Matthias Clasen
1fba399296 testsuite: Add special-case curve tests 2022-04-08 16:44:28 -04:00
Matthias Clasen
4d6c2108ac Add curve intersection tests
These tests check that gsk_curve_intersect finds
the intersections we want.
2022-04-08 16:44:28 -04:00
Matthias Clasen
ac5c742df6 curve: Add gsk_curve_intersect
Add a way to find the intersections of two curves.
This will be used in stroking.
2022-04-08 16:44:28 -04:00
Matthias Clasen
ee799830ef curve: Add gsk_curve_get_bounds
Add getters for bounding boxes of curves.
2022-04-08 16:44:28 -04:00
Matthias Clasen
7e9c94e599 Add a bounding box type
graphene_rect_t does not quite work for this purpose.
2022-04-08 16:44:28 -04:00
Matthias Clasen
9e2c689745 Only test conic weights between 1/20 and 20
The rest just give us no end of numeric trouble.
2022-04-08 16:44:28 -04:00
Benjamin Otte
94f93dbd2d path: Add gsk_path_builder_add_ellipse() 2022-04-08 16:44:28 -04:00
Benjamin Otte
846ae95818 path: Change semantics of gtk_path_builder_add_segment()
Allow start >= end to mean that the path continues at the beginning
after reaching the end until it reaches the point at @end.
2022-04-08 16:44:28 -04:00
Benjamin Otte
c28fd1dbe6 pathmeasure: Add gsk_path_measure_is_closed () 2022-04-08 16:44:28 -04:00
Benjamin Otte
6021b76a6b pathmeasure: Add gsk_path_measure_restrict_to_contour() 2022-04-08 16:44:28 -04:00
Matthias Clasen
15541842e4 pathmeasure: Add gsk_path_measure_get_{path,tolerance}
These are just nice apis to have and avoid having to carry
these around as extra arguments in many places.

This was showing up as inconvenience in writing tests
for the measure apis.
2022-04-08 16:44:28 -04:00
Benjamin Otte
1dbfff9f2b gtk-demo: Use dashes in path-fill demo 2022-04-08 16:44:28 -04:00
Matthias Clasen
2418d67e23 gsk: Use stroke bounds in the stroke node
We can use gsk_path_get_stroke_bounds to get a
better estimate for the bounds of the stroke node.
2022-04-08 16:44:28 -04:00
Matthias Clasen
91193e807f path: Add gsk_path_get_stroke_bounds
A relatively cheap way to get bounds for the area
that would be affected by stroking a path.
2022-04-08 16:44:28 -04:00
Benjamin Otte
d537df1f62 testsuite: Add tests for the dasher 2022-04-08 16:44:28 -04:00
Benjamin Otte
4a596fe5bf path: Add a foreach function that dashes a path 2022-04-08 16:44:28 -04:00
Benjamin Otte
27e7b97d28 path: Deal with non-uniformness of progress parameter
The progress is non-uniform, so simple translation of progress doesn't work.
So check if larger and smaller values inch closer towards minimal distance.
2022-04-08 16:44:28 -04:00
Benjamin Otte
95a34803cb path: Always decompose conics into at least 2 segments
Conics are evil in that their parameter skews towards the center, and if
it's a very flat conic (weight almost equal to 0), then we'd approximate
it with a single segment and not subdivide, which would cause the
parameter to be wildly off around 0.25 or 0.75.

And that would cause offset calculations to fail.
2022-04-08 16:44:28 -04:00
Matthias Clasen
c3571c104d testsuite Add curve tangent tests 2022-04-08 16:44:28 -04:00
Benjamin Otte
451a629de1 testsuite: Add a test for the conic that got us segment() 2022-04-08 16:44:28 -04:00
Benjamin Otte
c0e332f677 path: Add gsk_curve_segment()
Using split() twice with scaled t values does not work with conics.
2022-04-08 16:44:28 -04:00
Benjamin Otte
66edb0b5cd testsuite: Add a test for gsk_curve_decompose() 2022-04-08 16:44:28 -04:00
Benjamin Otte
a430099e35 testuite: Add tests for gsk_curve_get_tangent() 2022-04-08 16:44:28 -04:00
Matthias Clasen
26aef58709 testuite: Add tests for gsk_curve_get_point()
Add a few tests for gsk_curve_get_point().

Since GskCurve is not public api, we add gskcurve.c
as source to the test binary.
2022-04-08 16:44:28 -04:00
Benjamin Otte
d15f558769 curve: Split eval() into get_point() and get_tangent()
That's more in line with the get_start/end_point/tangent() functions.

Plus, those calls are independent and we usually want one or the other.
2022-04-08 16:44:28 -04:00
Matthias Clasen
0c2f43d1bd curve: Add gsk_curve_get_{start,end}_tangent
Add a way to get the tangents at the start and end of the curve.
This will be used in stroking.
2022-04-08 16:44:28 -04:00
Benjamin Otte
77d6bc9158 testsuite: Add conics to the random paths 2022-04-08 16:44:28 -04:00
Benjamin Otte
ef120ef1a0 path: Add GskCurve
GskCurve is an abstraction for path operations. It's essentially a
collection of vfuncs per GskPathOperation.

GskStandardContour has been ported to use it where appropriate.
2022-04-08 16:44:28 -04:00
Benjamin Otte
dcf0ba6920 path: Introduce gskpathop
A gskpathop is a pointer to a graphene_point_t* with the low bits used
to encode the GskPathOperation. It's an easy way to introduce API for
operations.

So far it's just used to replace GskStandardOperation.
2022-04-08 08:06:02 -04:00
Benjamin Otte
159fb16494 css: Replace border rendering code with GskPath 2022-04-08 08:06:02 -04:00
Benjamin Otte
7965c420bc pathbuilder: Add gsk_path_builder_add_rounded_rect()
It works, but does not use a custom contour yet.
2022-04-08 08:06:02 -04:00
Benjamin Otte
7b83101ed7 path: Add conic curves
So far this just adds the API, if you use it, you'll get lots of
g_warnings().

This will be fixed in future commits.
2022-04-08 08:06:02 -04:00
Benjamin Otte
dd2036ea01 path: Rename to gtk_path_builder_add_segment()
It's about bulding paths, not about measuring them.
2022-04-08 08:06:02 -04:00
Matthias Clasen
c66d61a55c path: Split contours into their own file
I'm not sure I want to keep all contours in one file,
but for now that's how it is.
2022-04-08 08:06:02 -04:00
Benjamin Otte
e2b5e83812 path: Make all private contour APIs take a GskContour
... instead of a path, index tuple.
2022-04-08 08:06:02 -04:00
Matthias Clasen
d773a36623 Add a nodeparser tests for fill and stroke nodes 2022-04-08 08:06:02 -04:00