Commit Graph

77013 Commits

Author SHA1 Message Date
Matthias Clasen
3b79ad1e7e 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-01 17:36:54 -04:00
Benjamin Otte
1b57e5ac80 testsuite: Add librsvg path tests 2023-07-01 17:36:54 -04:00
Matthias Clasen
5aaa4cc452 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-01 17:36:54 -04:00
Matthias Clasen
56022d3a58 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-01 17:36:54 -04:00
Matthias Clasen
3f356d0b59 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-01 17:36:54 -04:00
Matthias Clasen
dced4a4796 Documentation typo fixes 2023-07-01 17:36:54 -04:00
Benjamin Otte
256d537242 testsuite: Add relative path functions
They're making the paths slightly weirder, but they test public API, so
woohoo!
2023-07-01 17:36:54 -04:00
Benjamin Otte
2c2ee6a27a pathbuilder: Add relative path commands
And gsk_path_builder_get_current_point().

They will be needed by the string parser.
2023-07-01 17:36:54 -04:00
Benjamin Otte
eed54eac7a 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-01 17:36:53 -04:00
Benjamin Otte
098c402a97 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-01 17:36:53 -04:00
Benjamin Otte
b87095330a xxx: demo 2023-07-01 17:36:53 -04:00
Benjamin Otte
1037fc8387 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-01 17:36:53 -04:00
Benjamin Otte
3fc0df814c path: Split GskPathBuilder into its own file
... and add missing API docs.
2023-07-01 17:36:53 -04:00
Benjamin Otte
ae552b3064 testsuite: Add a test using get_point() and get_closest_point() 2023-07-01 17:36:53 -04:00
Benjamin Otte
12d9d71449 testsuite: Add a test for get_point() 2023-07-01 17:36:53 -04:00
Benjamin Otte
7772e4f925 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-01 17:36:53 -04:00
Benjamin Otte
88055f62c5 gtk-demo: Add cute maze demo 2023-07-01 17:36:53 -04:00
Benjamin Otte
4c7f009cc1 testsuite: Add tests for gsk_path_measure_get_closest_point() 2023-07-01 17:36:53 -04:00
Benjamin Otte
7c084b78f6 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-01 17:36:53 -04:00
Benjamin Otte
e207e1ee9d 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-01 17:36:53 -04:00
Benjamin Otte
598e14868c testsuite: Add tests for gsk_path_measure_add_segment() 2023-07-01 17:36:53 -04:00
Benjamin Otte
ae09d17590 gtk-demo: Add a text-on-path demo 2023-07-01 17:36:53 -04:00
Benjamin Otte
d2e8c639ca demos: Add a simple demo filling a path 2023-07-01 17:36:53 -04:00
Benjamin Otte
06f0ab7e8f path: Add gsk_path_measure_get_point()
Allows querying the coordinates and direction of any specific point on a
path.
2023-07-01 17:36:53 -04:00
Matthias Clasen
0d1fd1ce72 path: Add gsk_path_add_circle()
Adds a circle contour, too.
2023-07-01 17:36:53 -04:00
Benjamin Otte
d18ecca089 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-01 17:36:53 -04:00
Benjamin Otte
47560f8369 path: Implement gsk_path_to_cairo() using foreach() 2023-07-01 17:36:53 -04:00
Benjamin Otte
260be0300e path: Add gsk_path_foreach() 2023-07-01 17:36:53 -04:00
Benjamin Otte
dca9fb5801 path: Collect flags
We don't need them yet, but maybe later.
2023-07-01 17:36:53 -04:00
Benjamin Otte
f2012c6185 testsuite: Add path tests 2023-07-01 17:36:53 -04:00
Benjamin Otte
cc43dee619 pathmeasure: Add gsk_path_measure_add_segment()
This allows chunking paths, weeee.
2023-07-01 17:36:53 -04:00
Benjamin Otte
78f3d86a25 path: Add gsk_path_builder_add_path() 2023-07-01 17:36:53 -04:00
Benjamin Otte
3869e4a818 gsk: Add GskPathMeasure
An object to do measuring operations on paths - determining their
length, cutting off subpaths, things like that.
2023-07-01 17:36:53 -04:00
Benjamin Otte
7a6b489dc6 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.
2023-07-01 17:36:53 -04:00
Benjamin Otte
282c065b77 snapshot: Add gtk_snapshot_push_stroke() 2023-07-01 17:36:53 -04:00
Benjamin Otte
1f0622b27e gsk: Add GskStrokeNode 2023-07-01 17:36:53 -04:00
Benjamin Otte
0a85189e04 gsk: Add GskStroke
It's unused in this commit. This just prepares the new object.
2023-07-01 17:36:53 -04:00
Benjamin Otte
3301a1af0b snapshot: Add gtk_snapshot_push_fill() 2023-07-01 17:36:53 -04:00
Benjamin Otte
245479f71d gsk: Add GskFillNode
Take a rendernode as source and a GskPath and fill the region in the
path just like cairo_fill() would.
2023-07-01 17:36:53 -04:00
Benjamin Otte
d92b659d02 gsk: Add GskPath 2023-07-01 17:36:53 -04:00
Daniel Boles
7bee50c4f6 Image: Fix missing closing backtick 2023-06-29 14:33:29 +01:00
Matthias Clasen
bad2324318 Merge branch 'dboles/gtk-demo_dnd_dark' into 'main'
gtk-demo/dnd: Fix, generalise detecting dark theme

See merge request GNOME/gtk!6157
2023-06-29 10:26:41 +00:00
Matthias Clasen
dd15accb79 Merge branch 'matthiasc/for-main' into 'main'
build: Try harder to work with nongnu ld

See merge request GNOME/gtk!6159
2023-06-28 23:31:41 +00:00
Matthias Clasen
1d1f35576a build: Try harder to work with nongnu ld
Only try to be fast with gnu ld.
2023-06-28 16:54:34 -04:00
Daniel Boles
15458b5af3 gtk-demo/dnd: Fix, generalise detecting dark theme
Our default theme is now Default, not Adwaita, & HighContrastInverse was
renamed to Default-hc. So these checks did not work anymore. Rather than
hard-coding the new names, & possibly running into the same issue again,
we can just look for the convention of appending -dark to the theme name
and/or the Settings:prefer-dark-theme prop. The latter, we can & likely
SHOULD also apply to all themes - not just ours as before. We also check
for the :dark suffix as that means the theme variant - & before checking
GtkSettings check the GTK_THEME env var, just as GtkSettings itself does
2023-06-28 14:40:06 +01:00
Matthias Clasen
5ffe9a68ed Merge branch 'matthiasc/for-main' into 'main'
build: Move objcopy checks to one place

Closes #5672

See merge request GNOME/gtk!6156
2023-06-28 12:06:49 +00:00
Matthias Clasen
f341bd563b build: Look for ld.bfd
The objcopy+ld approach to fast resource building
relies on behavior that is specific to the binutils
linker, and does not work with the llvm one.

Therefore, check for ld.bfd. We still fall back
to trying with just ld, since I'm not 100% sure
if binutils unconditionally installs ld.bfd.

Fixes: #5672
2023-06-28 07:12:07 -04:00
Matthias Clasen
70edacc68d build: Move objcopy checks to one place
We were doing the same thing in three places.
Move it to the toplevel meson.build, so we
can change it in one place.
2023-06-28 07:11:51 -04:00
Matthias Clasen
091176ae48 Updates 2023-06-28 06:47:32 -04:00
Matthias Clasen
d9cfb94a80 Merge branch 'fix_dropdown_set_expression' into 'main'
GtkDropDown: Force redisplay of the drop-down items after expression change

See merge request GNOME/gtk!6145
2023-06-28 09:57:04 +00:00