Commit Graph

2261 Commits

Author SHA1 Message Date
Matthias Clasen
1e6a124665 Correct the docs of gsk_path_builder_add_rect
The path does *not* always go clockwise!
2023-08-27 12:18:36 -04:00
Matthias Clasen
8d1844135b path: Add a comment 2023-08-27 10:10:08 -04:00
Matthias Clasen
b5dd9dae0d rounded rect contour: Fix an oversight
The close operation takes 2 points, so our array
was one too short. Oops.
2023-08-27 10:09:32 -04:00
Matthias Clasen
ebcb518e4f Cosmetics 2023-08-27 09:50:16 -04:00
Matthias Clasen
b7ea22f168 Drop unused code
Nobody is calling gsk_contour_get_start_end, so drop
this internal API.
2023-08-27 09:39:59 -04:00
Matthias Clasen
822e988efe path: Recognize rounded rects when parsing
We can look out for M-L-O-L-O-L-O-L-O-Z patterns
with matching numbers.
2023-08-27 09:31:17 -04:00
Matthias Clasen
cee043f977 Add a rounded rect contour
This special contour takes advantage of its
rounded-rect-ness for speeding up bounding
boxes and winding numbers. It falls back
to the standard contour code for everything
else.
2023-08-27 09:29:19 -04:00
Matthias Clasen
031c0ec3e5 pathpoint: Add some debug API
Add a private gsk_path_point_to_string that
can be called in the debugger if you want
to see the contents of a GskPathPoint and
are too lazy to cast it to GskRealPathPoint
yourself.
2023-08-27 09:14:47 -04:00
Matthias Clasen
ba3a657c48 contour: Add some debug API
Add a private  way to get the class of a contour,
so we can test that roundtrips through gsk_path_parse
work as expected.
2023-08-27 09:13:32 -04:00
Matthias Clasen
5f2f116c28 circle contour: Fix a typo 2023-08-27 07:43:55 -04:00
Matthias Clasen
2297a353b8 Merge branch 'circle-contour' into 'main'
path: Add a circle contour

See merge request GNOME/gtk!6345
2023-08-27 11:12:51 +00:00
Bilal Elmoussaoui
7342ce5bca gi: Add missing since annotation 2023-08-27 08:17:00 +00:00
Matthias Clasen
167b38dfa1 contour: Some reactoring
Make a default print implementation, and use it.
2023-08-26 23:42:52 -04:00
Matthias Clasen
b8a3d7fa00 path: Recognize circles when parsing
We can look out for the tell-tale
M-O-O-O-O-Z and turn it into a circle
contour.
2023-08-26 23:42:52 -04:00
Matthias Clasen
0fce24674a path: Add a circle contour
This special contour takes advantage of the
circle definition to speed up things like
hit testing and closest point determination.
2023-08-26 23:42:52 -04:00
Matthias Clasen
99ad585252 Merge branch 'measure-speedups' into 'main'
contour: Stop doing the roundtrip test

See merge request GNOME/gtk!6342
2023-08-27 01:13:41 +00:00
Matthias Clasen
6defdb4e8a Drop unused code
we are not using any gsk_spline functions currently.
2023-08-26 11:29:09 -04:00
Matthias Clasen
c989a06718 pathmeasure: compute samples on demand
Only do the work for a curve the first time
we need it. This should greatly speed up
use cases where you only create a measure
to get the length of the path.
2023-08-26 10:23:02 -04:00
Matthias Clasen
1c8bd8658d curve: Cosmetics 2023-08-26 10:23:02 -04:00
Matthias Clasen
ab50cba4e9 curve: Reduce the order of our approximation
Use 24 samples instead of 32.
2023-08-26 10:23:02 -04:00
Matthias Clasen
57918813e2 contour: Stop doing the roundtrip test
Doing inverse arclength computations is
a very high overhead operation. And the
tests still pass without it.
2023-08-26 09:39:49 -04:00
Matthias Clasen
677e19042d Docs: Cosmetics 2023-08-25 22:21:27 -04:00
Matthias Clasen
bd79f61cc5 pathpoint: Update the docs
We have gained some more ways of getting points.
2023-08-25 22:03:42 -04:00
Matthias Clasen
361cdecfe4 Merge branch 'path-measure-reredone' into 'main'
Add GskPathMeasure

See merge request GNOME/gtk!6326
2023-08-26 01:05:19 +00:00
Matthias Clasen
007cfeac94 Add GskPathMeasure
GskPathMeasure is the public API for path lengths.
2023-08-25 20:16:49 -04:00
Matthias Clasen
553499522c contour: Add measure API
In order to compute path lengths efficiently, we need
to cache lookup tables. This commit adds API to let
contours allocate and free such measure data, as well
as API to use the data to go length -> point and
vice versa.
2023-08-25 20:16:49 -04:00
Benjamin Otte
81821978ae Merge branch 'wip/otte/for-main' into 'main'
gltexture: Restore previous GL context

See merge request GNOME/gtk!6335
2023-08-25 21:44:17 +00:00
Matthias Clasen
04e6fc3f74 curve: Add length computation
Add api to go t<>length.

The code here is inspired by
https://pomax.github.io/bezierinfo/#arclength
2023-08-25 16:13:36 -04:00
Benjamin Otte
54d2f0063a Merge branch 'replay' into 'main'
Node replay tests

See merge request GNOME/gtk!6299
2023-08-25 19:45:34 +00:00
Benjamin Otte
ae7ec40cf2 rendernodeparser: Generate better default child
... for fill and stroke nodes.

It's most likely we want the path bounds (or path stroke bounds),
so make the parser use those by default.
2023-08-25 21:12:12 +02:00
Matthias Clasen
eec90d1026 pathbuilder: Add rel-variants for arc-to
Add rel-variants for all our arc-to APIs. This is
a pretty harmless addition, and it is more consistent
to have these for all ..._to functions.
2023-08-25 09:45:45 -04:00
Matthias Clasen
f4fb4d04e5 Some pathbuilder doc clarifications
Mention the end point of the html arc-to call.
2023-08-25 09:37:07 -04:00
Matthias Clasen
3283157352 Bring arc_to back as convenience API
It is our main use of conics, so make it an API,
and use it internally.
2023-08-25 09:31:19 -04:00
Sergey Bugaev
d07a6b8566 snapshot, gsktransform: Mention that rotation happens around (0, 0)
...and not around the center of the render node, as one could expect
given that the render node syntax for rotation, transform: rotate(90);,
happens to match the CSS syntax for the same thing, and CSS does rotate
around the center by default.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Matthias Clasen
5bc82f4141 Change curve derivative api
We don't need to have the derivative as a curve,
it is enough for us to compute values of the
derivative at a given t, which we can also do
for conics.
2023-08-25 07:33:16 -04:00
Matthias Clasen
25e6231a88 path: Switch back to conics
Arcs were appealing, but they have a fatal flaw: we can't
split our arcs without changing the ellipse they trace.
That could be fixed by adding an extra parameter, but then
it is no longer any better than conics.

So switch back to conics, which have the advantage that they
are used elsewhere.
2023-08-25 07:33:16 -04:00
Matthias Clasen
5dc0cbc20f Expand the path docs a bit 2023-08-24 15:00:14 -04:00
Matthias Clasen
e1faf28310 Make curvature api more flexible
Add an extra direction argument to get_curvature to
allow picking the limit on either side, for sharp turns.

Update all callers.
2023-08-24 14:32:33 -04:00
Matthias Clasen
854c695153 pathpoint docs: Fix a link
Links gsk->gtk must be done manually, since we
don't have a dependency.
2023-08-24 13:41:39 -04:00
Matthias Clasen
ebd4ceca15 path docs: Clarify curvature
The curvature of lines is zero, not infinite.
2023-08-24 11:15:51 -04:00
Matthias Clasen
d873643407 path docs: Add another illustration 2023-08-24 11:09:28 -04:00
Matthias Clasen
4229a37e90 arc: Fix the derivative
Scale the derivative such that computing the arc length
of a unit quarter circle wil produce the expected result
of PI/2.
2023-08-23 22:18:52 -04:00
Matthias Clasen
12297fd88a arc curve: Simplify derivative 2023-08-23 22:11:22 -04:00
Matthias Clasen
7943610066 curve: Fix arc decomposition 2023-08-23 22:11:15 -04:00
Matthias Clasen
f6c2b6bb88 Make foreach work efficiently with arcs 2023-08-23 14:51:31 -04:00
Matthias Clasen
4ab03e79b7 Drop some unnecessary code
We tell path_foreach to split into lines or cubics,
so no point in having code to handle quads and arcs.
2023-08-23 14:33:25 -04:00
Matthias Clasen
7a12abdea3 Incorporate review feedback 2023-08-23 14:16:43 -04:00
Matthias Clasen
71584107b0 Add gsk_path_builder_html_arc_to
This one draws circular arcs with a given radius.
2023-08-23 12:43:52 -04:00
Matthias Clasen
88c0ace644 Make gsk_path_builder_svg_arc_to public
This is useful to port SVG paths using this syntax.
2023-08-23 12:43:52 -04:00
Matthias Clasen
d33ed4f9ab path: Add elliptical arcs
Add a new curve type for elliptical arcs
and use it for rounded rectangles and circles.
We use the 'E' command to represent elliptical
arcs in serialized paths.
2023-08-23 12:43:52 -04:00