Commit Graph

77289 Commits

Author SHA1 Message Date
Benjamin Otte
673d85ff16 testsuite: Add a test for gsk_curve_decompose() 2023-07-31 16:51:04 +02:00
Benjamin Otte
5a85046c09 testuite: Add tests for gsk_curve_get_tangent() 2023-07-31 16:51:04 +02:00
Matthias Clasen
887c1ff416 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
5877155c40 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.
2023-07-31 16:51:04 +02:00
Matthias Clasen
041b9170cc 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
968f5aea61 testsuite: Add conics to the random paths 2023-07-31 16:51:04 +02:00
Benjamin Otte
2badf27114 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
0a05d864d1 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
46fe43c5df WIP: css: Replace border rendering code with GskPath
The weight is wrong still, I need to compute the correct one to get real
45deg circle corners and not just roughly correct ones.
2023-07-31 16:51:04 +02:00
Benjamin Otte
74164440f6 WIP: pathbuilder: Add gsk_path_builder_add_rounded_rect()
It works, but does not use a custom contour yet.
2023-07-31 16:51:04 +02:00
Benjamin Otte
0cea93777a 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
70077d9a2a path: Rename to gtk_path_builder_add_segment()
It's about bulding paths, not about measuring them.
2023-07-31 16:51:04 +02:00
Benjamin Otte
df34aceee1 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.
2023-07-31 16:51:04 +02:00
Benjamin Otte
70c6756639 path: Make all private contour APIs take a GskContour
... instead of a path, index tuple.
2023-07-31 16:51:04 +02:00
Benjamin Otte
63398ea869 stroke: Add support for dashes
... and hook it up in the node parser and for Cairo rendering.
2023-07-31 16:51:04 +02:00
Matthias Clasen
d315e0687e gsk: Implement parsing fill and stroke nodes
Make serialization and deserialization work for stroke and
fill nodes.
2023-07-31 16:51:04 +02:00
Benjamin Otte
89c63d1517 path: Add flags to gsk_path_foreach()
This way we can default to the siplest possible foreach() output - like
cairo_copy_path_flat() decomposing everything into lines - and add flags
to get more and more fancy.

This will be useful to have conics automatically decomposed for Cairo
drawing or if we want to add more line types in the future.
2023-07-31 16:51:04 +02:00
Benjamin Otte
3c5369a9ff testsuite: Add an in_fill() test 2023-07-31 16:51:04 +02:00
Matthias Clasen
e81e80e069 Implement gsk_path_measure_in_fill
Implement this in the obvious way, using the decomposed form
of standard contours. Since the decomposed form is part of the
measure object, this api moves from gsk_path_in_fill to
gsk_path_measure_in_fill.
2023-07-31 16:51:04 +02:00
Benjamin Otte
6dba706a9a testsuite: Add a parsing test
This test includes an implementation of a gsk_path_equal() func with
a tolerance that is necessary because parsing does not always work
100% exactly due to floating point rounding, so we can't just
compare the to_string() output.
2023-07-31 16:51:04 +02:00
Matthias Clasen
673e92645a path: Special-case rects and circles
Write out the commands for rects and circles in a special
way, and add code in the parser to recognize this, so we
can successfully round-trip these through the SVG path format.

The special way - for people who want to use it for debugging -
for now is that we use uppercase "Z" to close standard paths, but
lowercase "z" to close our special paths.

A test is included, but the random path serializations should take care
of it, too.
2023-07-31 16:51:04 +02:00
Matthias Clasen
8ef4b40e97 path: Fix serialization for circles
The svg A can not do a full circle, since it is a two point
parametrization - if the start and end point are the same,
it draws nothing. So, use two arcs.
2023-07-31 16:51:04 +02:00
Benjamin Otte
0ab25f0580 testsuite: Add librsvg path tests 2023-07-31 16:51:04 +02:00
Matthias Clasen
192bf4bbbe path: Implement gsk_path_parse
Implement the SVG path syntax to read back the strings
that we generate when serializing paths. The tests for
this code are taken from librsvg.

This includes an elliptical arc implementation according
to the SVG spec. The code is mostly taken from librsvg,
but pretty directly follows the SVG spec implementation
notes. We don't export this, since the parametrization
is inconvenient. We do want an arc_to API, but
these are not the arcs we are looking for.
2023-07-31 16:51:04 +02:00
Matthias Clasen
bddffb08cc path: Implement SVG arcs
This is elliptical arc implementation according to the SVG spec.
The code is mostly taken from librsvg, but pretty directly
follows the SVG spec implementation notes.

We don't export this, since the parametrization is inconvenient.
We do want an arc_to API, but these are not the arcs we are
looking for.

It will be used in parsing SVG path syntax.
2023-07-31 16:51:04 +02:00
Matthias Clasen
84dbd7c46f stroke: Add miter limit
Add a miter limit to GskStroke. This will be needed to
fully implement line joins.

Also introduce the GSK_LINE_JOIN_MITER_CLIP value,
following SVG 2.0. cairo does not have it, so translate
it to plain miter when using cairo.
2023-07-31 16:51:04 +02:00
Matthias Clasen
4487cafd40 Documentation typo fixes 2023-07-31 16:51:04 +02:00
Benjamin Otte
2f930f93cc testsuite: Add relative path functions
They're making the paths slightly weirder, but they test public API, so
woohoo!
2023-07-31 16:51:04 +02:00
Benjamin Otte
0a947d9a6a pathbuilder: Add relative path commands
And gsk_path_builder_get_current_point().

They will be needed by the string parser.
2023-07-31 16:51:04 +02:00
Benjamin Otte
46f405ac7d path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
This is just splitting out a commonly done operation into a macro.
2023-07-31 16:51:04 +02:00
Benjamin Otte
4f03537a28 pathbuilder: Redo semantics for starting curves
We now always have a "current point" which is either the last point an
operation was made to, or (0, 0) if no drawing operation has
been made yet.

Adding a contour of any kind to the builder will always update the
current point to that contour's end point.
2023-07-31 16:51:04 +02:00
Benjamin Otte
1621b53570 xxx: demo 2023-07-31 16:51:04 +02:00
Benjamin Otte
7e66dfe902 pathbuilder: Rename "builder" variables to "self"
This is a pure find/replace that is now possible after
the split in the previous commit.
2023-07-31 16:51:04 +02:00
Benjamin Otte
7bc6fabbf7 path: Split GskPathBuilder into its own file
... and add missing API docs.
2023-07-31 16:51:04 +02:00
Benjamin Otte
26c8702400 testsuite: Add a test using get_point() and get_closest_point() 2023-07-31 16:51:04 +02:00
Benjamin Otte
1b7c4420dc testsuite: Add a test for get_point() 2023-07-31 16:51:04 +02:00
Benjamin Otte
ece3153b1f testsuite: Update create_random_path()
1. Allow specifying the max number of contours
2. Be smarter about creating the paths:
   With 10% chance, create a "weird" path like the empty one or only
   points or things like that.
   Otherwise create a bunch of contours, with 2/3 a standard contour,
   with 1/3 a predetermined one.
2023-07-31 16:51:04 +02:00
Benjamin Otte
74dc039c7a gtk-demo: Add cute maze demo 2023-07-31 16:51:04 +02:00
Benjamin Otte
3e1c3aca2a testsuite: Add tests for gsk_path_measure_get_closest_point() 2023-07-31 16:51:04 +02:00
Benjamin Otte
51bc26b314 path: Add gsk_path_measure_get_closest_point()
... and gsk_path_measure_get_closest_point_full().

Those 2 functions allow finding the closest point on a path to a given
point.
2023-07-31 16:51:04 +02:00
Benjamin Otte
51a1adf312 spline: Use Skia's tolerance checks
This avoids measuring being too far off (it's still off, but it's less
than a percent now.
2023-07-31 16:51:04 +02:00
Benjamin Otte
d84132824f testsuite: Add tests for gsk_path_measure_add_segment() 2023-07-31 16:51:03 +02:00
Benjamin Otte
ffecc89352 gtk-demo: Add a text-on-path demo 2023-07-31 16:51:03 +02:00
Benjamin Otte
77518895ea demos: Add a simple demo filling a path 2023-07-31 16:51:03 +02:00
Benjamin Otte
9685a47693 path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2023-07-31 16:51:03 +02:00
Matthias Clasen
7f9825919c path: Add gsk_path_add_circle()
Adds a circle contour, too.
2023-07-31 16:51:03 +02:00
Benjamin Otte
2795fc53c1 pathmeasure: Implement support for beziers
Instead of treating bezier curves as lines, we properly decompose them
into line segments now so that we can treat those as lines.
2023-07-31 16:51:03 +02:00
Benjamin Otte
20ba4a225c path: Implement gsk_path_to_cairo() using foreach() 2023-07-31 16:51:03 +02:00
Benjamin Otte
eadbfc3433 path: Add gsk_path_foreach() 2023-07-31 16:51:03 +02:00
Benjamin Otte
b8ee48de63 path: Collect flags
We don't need them yet, but maybe later.
2023-07-31 16:51:03 +02:00