Commit Graph

67987 Commits

Author SHA1 Message Date
Benjamin Otte
9759262a67 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.
2020-12-27 20:08:53 +01:00
Benjamin Otte
60a28864df WIP: pathbuilder: Add gsk_path_builder_add_rounded_rect()
It works, but does not use a custom contour yet.
2020-12-27 20:08:53 +01:00
Benjamin Otte
28d5833348 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.
2020-12-27 20:08:53 +01:00
Benjamin Otte
70b84a7cc8 path: Rename to gtk_path_builder_add_segment()
It's about bulding paths, not about measuring them.
2020-12-27 20:08:53 +01:00
Benjamin Otte
8959654dcf 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.
2020-12-27 20:08:53 +01:00
Benjamin Otte
0b7e0d4a9a path: Make all private contour APIs take a GskContour
... instead of a path, index tuple.
2020-12-27 20:08:53 +01:00
Benjamin Otte
6fdbe228c0 stroke: Add support for dashes
... and hook it up in the node parser and for Cairo rendering.
2020-12-27 20:08:53 +01:00
Matthias Clasen
662001cc72 gsk: Implement parsing fill and stroke nodes
Make serialization and deserialization work for stroke and
fill nodes.
2020-12-27 20:08:53 +01:00
Benjamin Otte
1dd85f0a41 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.
2020-12-27 20:08:53 +01:00
Benjamin Otte
745a879b27 testsuite: Add an in_fill() test 2020-12-27 20:08:53 +01:00
Matthias Clasen
04b9746bd5 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.
2020-12-27 20:08:53 +01:00
Benjamin Otte
fe31eef4a1 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.
2020-12-27 20:08:53 +01:00
Matthias Clasen
ca4d1de2c0 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.
2020-12-27 20:08:52 +01:00
Matthias Clasen
68a35611a2 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
01536b4849 testsuite: Add librsvg path tests 2020-12-27 20:08:52 +01:00
Matthias Clasen
358a7e8659 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.
2020-12-27 20:08:52 +01:00
Matthias Clasen
b7931f94ed 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.
2020-12-27 20:08:52 +01:00
Matthias Clasen
62925199e7 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.
2020-12-27 20:08:52 +01:00
Matthias Clasen
5c15a265c5 Documentation typo fixes 2020-12-27 20:08:52 +01:00
Benjamin Otte
47ca0834a1 testsuite: Add relative path functions
They're making the paths slightly weirder, but they test public API, so
woohoo!
2020-12-27 20:08:52 +01:00
Benjamin Otte
d0f6346922 pathbuilder: Add relative path commands
And gsk_path_builder_get_current_point().

They will be needed by the string parser.
2020-12-27 20:08:52 +01:00
Benjamin Otte
8b330e3772 path: Add GSK_CIRCLE_POINT_INIT() to initialize points on the circle
This is just splitting out a commonly done operation into a macro.
2020-12-27 20:08:52 +01:00
Benjamin Otte
01a12b0fc8 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
f3dfcbde4c xxx: demo 2020-12-27 20:08:52 +01:00
Benjamin Otte
1c308f00b9 path: Split GskPathBuilder into its own file
... and add missing API docs.
2020-12-27 20:08:52 +01:00
Benjamin Otte
4d38358b3a testsuite: Add a test using get_point() and get_closest_point() 2020-12-27 20:08:52 +01:00
Benjamin Otte
e9f4047251 testsuite: Add a test for get_point() 2020-12-27 20:08:52 +01:00
Benjamin Otte
cc2523b12f 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
0c3c5c95f7 gtk-demo: Add cute maze demo 2020-12-27 20:08:52 +01:00
Benjamin Otte
3533d58ff0 testsuite: Add tests for gsk_path_measure_get_closest_point() 2020-12-27 20:08:52 +01:00
Benjamin Otte
2cd08ecf77 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
758958a56e 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
8cd37aa678 testsuite: Add tests for gsk_path_measure_add_segment() 2020-12-27 20:08:52 +01:00
Benjamin Otte
e6249c6318 gtk-demo: Add a text-on-path demo 2020-12-27 20:08:52 +01:00
Benjamin Otte
073c98aaeb xxx: path_fill demo 2020-12-27 20:08:52 +01:00
Benjamin Otte
4a1dcefca6 path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2020-12-27 20:08:52 +01:00
Matthias Clasen
e024982055 path: Add gsk_path_add_circle()
Adds a circle contour, too.
2020-12-27 20:08:52 +01:00
Benjamin Otte
9fd1dea356 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.
2020-12-27 20:08:52 +01:00
Benjamin Otte
865c4dabda path: Implement gsk_path_to_cairo() using foreach() 2020-12-27 20:08:52 +01:00
Benjamin Otte
7ff39c6b60 path: Add gsk_path_foreach() 2020-12-27 20:08:52 +01:00
Benjamin Otte
811d24895d path: Collect flags
We don't need them yet, but maybe later.
2020-12-27 20:08:52 +01:00
Benjamin Otte
cda8d6608d testsuite: Add path tests 2020-12-27 20:08:52 +01:00
Benjamin Otte
53b64f63f1 pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2020-12-27 20:08:52 +01:00
Benjamin Otte
1783c9bdd8 path: Add gsk_path_builder_add_path() 2020-12-27 20:08:52 +01:00
Benjamin Otte
0e69f58c2b gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2020-12-27 20:08:52 +01:00
Benjamin Otte
d270456645 path: Change data structure for standard path
Instead of the Cairo method and imitating cairo_path_data_t, use the
Skia method and keep points and operations separate.

That way we get a points array that includes the starting point -
because it's always the end point of the previous operation.
2020-12-27 20:08:52 +01:00
Benjamin Otte
1a03d73f2d popover: Use fill and stroke nodes instead of Cairo
... to render the arrow.

The arrow should really be turned into a real thing - maybe an icon?
2020-12-27 20:08:52 +01:00
Benjamin Otte
ca2059bb13 snapshot: Add gtk_snapshot_push_stroke() 2020-12-27 20:08:52 +01:00
Benjamin Otte
7752462914 gsk: Add GskStrokeNode 2020-12-27 20:08:52 +01:00
Benjamin Otte
b9c6586d96 gsk: Add GskStroke
It's unused in this commit. This just prepares the new object.
2020-12-27 20:08:52 +01:00