Commit Graph

67934 Commits

Author SHA1 Message Date
Matthias Clasen
a817faad73 Add gsk_path_stroke
Add the plumbing that will let us do special-case stroking
for rectangles, circles and other special contours. There
is no implementation yet.
2020-12-22 09:55:04 -05:00
Matthias Clasen
c4357a1442 Add a test for gsk_curve_offset
The stroker relies on offsetting.
This only tests a few very simple cases.
2020-12-22 09:54:47 -05:00
Matthias Clasen
e9699ce171 Add a test for gsk_curve_reverse
The stroker relies on this working.
2020-12-22 09:54:47 -05:00
Matthias Clasen
723809fbff Add a test for tangents of degenerate curves
The stroker relies on these to work.
2020-12-22 09:54:47 -05:00
Matthias Clasen
4c09c3fec2 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.
2020-12-22 09:54:47 -05:00
Matthias Clasen
66721f62e5 Add gsk_curve_reverse
This will be used in stroking.
2020-12-22 09:54:47 -05:00
Matthias Clasen
0f3b1fa768 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.
2020-12-22 09:54:47 -05:00
Matthias Clasen
4f6130923c Add conic decomposition tests
We don't have good error bounds here, unfortunately.
2020-12-22 09:54:47 -05:00
Matthias Clasen
f7e03f959c path: support conic->curve in foreach 2020-12-22 09:54:47 -05:00
Matthias Clasen
5da8603b66 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.
2020-12-22 09:54:47 -05:00
Matthias Clasen
aea826fc75 Add a performance test for curve eval
All curve types are equally fast here.
2020-12-22 09:54:47 -05:00
Matthias Clasen
d67b40f77d Add a performance test for curve intersection
This shows how much more expensive curve
intersections are.
2020-12-22 09:54:47 -05:00
Matthias Clasen
fa9bb82040 Add curve split tests 2020-12-22 09:54:47 -05:00
Matthias Clasen
047bbebff7 Add another intersection testcase
This tests horizontal line/conic intersection,
which failed before the fix in the previous commit.
2020-12-22 09:54:47 -05:00
Matthias Clasen
275c158653 xxx: work around bounding box problems
graphene_rect_intersect returns FALSE when you
intersect the bounding boxes of axis-aligned
lines, so we never find intersections with those.

Make things better by making the bounding boxes worse.
2020-12-22 09:54:47 -05:00
Matthias Clasen
3ceee6d3ff Add curve intersection tests
These tests check that gsk_curve_intersect finds
the intersections we want.
2020-12-22 09:54:47 -05:00
Matthias Clasen
c78436e8d4 Add gsk_curve_intersect
Add a way to find the intersections of two curves.
This will be used in stroking.
2020-12-22 09:54:47 -05:00
Matthias Clasen
d3b1fdbd1e Add gsk_curve_get_bounds
Add getters for bounding boxes of curves.
2020-12-22 09:54:47 -05:00
Matthias Clasen
906f3092c4 Only test conic weights between 1/20 and 20
The rest just give us no end of numeric trouble.
2020-12-22 09:54:47 -05:00
Benjamin Otte
d76b5d4a08 ottie: Add a snapshot test 2020-12-22 07:45:37 +01:00
Benjamin Otte
b55eb88f3c ottie: Add a command-line tool
Supports:

 * Taking a screenie:
   ottie image file.lottie image.png

 * Recording a rendernode:
   ottie node file.lottie render.node

 * Encoding an image:
   ottie video file.lottie video.webm
2020-12-22 07:45:37 +01:00
Benjamin Otte
2e02174fa4 Ottie: Add 2020-12-22 07:45:37 +01:00
Benjamin Otte
4b9dce7755 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.
2020-12-19 18:35:12 +01:00
Benjamin Otte
75f50dd939 path: Add gsk_path_measure_is_closed () 2020-12-19 18:35:12 +01:00
Benjamin Otte
4708d17cb8 path: Add gsk_path_measure_restrict_to_contour() 2020-12-19 18:35:12 +01:00
Matthias Clasen
6e9bb79aa1 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.
2020-12-19 18:35:12 +01:00
Benjamin Otte
b0848aa827 xxx path)_fill 2020-12-19 18:35:12 +01:00
Matthias Clasen
de6c996b0b Add gsk_path_get_stroke_bounds
A relatively cheap way to get bounds for the area
that would be affected by stroking a path.
2020-12-19 18:35:12 +01:00
Benjamin Otte
c3144853fd testsuite: Add tests for the dasher 2020-12-19 18:35:12 +01:00
Benjamin Otte
e4910cef0d path: Add a foreach function that dashes a path 2020-12-19 18:35:12 +01:00
Benjamin Otte
65f8338a30 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.
2020-12-19 18:35:12 +01:00
Benjamin Otte
9abf9bb3b2 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.
2020-12-19 18:35:12 +01:00
Matthias Clasen
6bd5ffde76 testsuite Add curve tangent tests 2020-12-19 18:35:12 +01:00
Benjamin Otte
2bac9f4c1f testsuite: Add a test for the conic that got us segment() 2020-12-19 18:35:12 +01:00
Benjamin Otte
e0ed8006dc path: Add gsk_curve_segment()
Using split() twice with scaled t values does not work with conics.
2020-12-19 18:35:12 +01:00
Benjamin Otte
2a55b9d0df testsuite: Add a test for gsk_curve_decompose() 2020-12-19 18:35:12 +01:00
Benjamin Otte
afbbc79b3a testuite: Add tests for gsk_curve_get_tangent() 2020-12-19 18:35:12 +01:00
Matthias Clasen
636093f85e 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.
2020-12-19 18:35:12 +01:00
Benjamin Otte
520fc04d4c 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.
2020-12-19 18:35:12 +01:00
Matthias Clasen
a384b2a5fc 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.
2020-12-19 18:35:12 +01:00
Benjamin Otte
1108968272 testsuite: Add conics to the random paths 2020-12-19 18:35:12 +01:00
Benjamin Otte
076f2dc68c 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.
2020-12-19 18:34:42 +01:00
Benjamin Otte
53e0bb187f 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.
2020-12-19 18:34:42 +01:00
Benjamin Otte
844a5d439c 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-19 18:34:42 +01:00
Benjamin Otte
042d87ea7f WIP: pathbuilder: Add gsk_path_builder_add_rounded_rect()
It works, but does not use a custom contour yet.
2020-12-19 18:34:42 +01:00
Benjamin Otte
ccbff7d27d 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-19 18:34:42 +01:00
Benjamin Otte
410753353e path: Rename to gtk_path_builder_add_segment()
It's about bulding paths, not about measuring them.
2020-12-19 18:34:42 +01:00
Benjamin Otte
7f3e5c5c00 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-19 18:34:42 +01:00
Benjamin Otte
d667ae7e9e path: Make all private contour APIs take a GskContour
... instead of a path, index tuple.
2020-12-19 18:34:42 +01:00
Benjamin Otte
1290639650 stroke: Add support for dashes
... and hook it up in the node parser and for Cairo rendering.
2020-12-19 18:34:42 +01:00