Commit Graph

2522 Commits

Author SHA1 Message Date
Matthias Clasen
6d16776e27 tests: Cosmetics 2023-09-16 08:27:08 -04:00
Matthias Clasen
d21ee115d0 Update private path tests
Our parser only recognizes 'complete' rounded
rects, so don't test roundtrips for incomplete
ones.
2023-09-15 16:46:23 -04:00
Matthias Clasen
2dd8e3b0eb contour: Add more tests for rounded rects
This is covering special cases where some
of the curves are omitted.
2023-09-15 16:46:23 -04:00
Matthias Clasen
eb6ca8f39a contour: Add more tests for rects
Spot-check the special cases:
rects with zero height or width.
2023-09-15 16:31:09 -04:00
Benjamin Otte
41af8ee2e2 testsuite: Add another test
his is the opposite of the test in 1502c21e97.

Also change the numbers in that test so it doesn't need a ref file.

Related: #6075
2023-09-15 16:34:00 +02:00
Benjamin Otte
e9089f65e3 gl: Change rounded_rect_shrink()
The code now follows gsk_rounded_rect_shrink() and with it the behavior
of the Cairo renderer and Webkit.

The old code did what the GL renderer and Cairo do, but I consider that
wrong.

I did not test Chrome.

Test attached
2023-09-15 16:34:00 +02:00
Benjamin Otte
1c971c595f glrenderer: Shadows without offset do exist
Not for opaque contents, but stuff can be semi-transparent.

Testcase included.
2023-09-15 03:46:27 +02:00
Benjamin Otte
f8627755b5 rendernode: Shadow nodes need offscreen for opacity
Otherwise the shadow will not be properly computed as opaque regions
become translucent after applying opacity.

Testcase included.
2023-09-15 03:46:27 +02:00
Matthias Clasen
1502c21e97 rendernode: Fix handling of color glyphs
The rendernode parser was mixing up its flags.

Test included.

Related: #6075
2023-09-13 15:37:57 -04:00
Benjamin Otte
a05a021fd1 rendernode: Fix Cairo rendering of repeating gradients
Cairo and the GL renderer have a different idea of how to handle
transitioning of colors outside the defined range.

Consider these stops:
  black 50%, white 50%

What color is at 0%?

Cairo would transition between the last and first stop, ie it'd do a
white-to-black transition and end up at rgb(0.5,0.5,0.5) at 0%.
GL would behave as it would for non-repeating gradients and use black
for the range [0%..50%] and white for [50%..100%].
The web would rescale the range so the first stop would be at 0% and
the last stop would be at 100%, so this gradient would be illegal.

Considering that it's possible for code to transition between the
different behaviors by adding explicit stops at 0%/100%, I could choose
any method.
So I chose the simplest one, which is what the GL renderer does and
which treats repeating and non-repeating gradients the same.

Tests attached.
2023-09-07 16:19:20 +02:00
Mike FABIAN
c8a43da526 Add test case for single char compose sequence 2023-08-29 13:30:05 -04:00
Michael Orlitzky
7a0e27b6e8 testsuite/gsk: add explicit dimensions to <svg> elements
Without an explicit width, height, and viewBox, there is no single
correct way to render an SVG. In the absense of said information,
librsvg is capable of making a guess by rendering the SVG to a Cairo
surface and then analyzing that surface; however, this process is
merely heuristic.

There are three GTK tests for SVG images that are missing dimensions.
While this is not a violation of the SVG specification, it does
implicitly couple the test to the librsvg rendering heuristic. In this
commit we add that dimension information so that the expected result
is unambiguous.
2023-08-28 17:14:18 -04:00
Matthias Clasen
827bbc0cc1 Change gsk_path_get_closest_point to return distance
We already compute it, so lets return it.
Bindings seems fine with this change - they
already return (success, point) as a tuple
anyway.
2023-08-28 11:22:30 -04:00
Matthias Clasen
2e24a9ece4 Make GskPathPoint public
The contents are still /*< private >*/, but we
let our tests and the debugger see them, which
helps.
2023-08-28 00:07:50 -04:00
Matthias Clasen
0dbff14555 Allow circles with radius of zero
Not very useful, but we allow rects with
width and height of zero, so lets be consistent.
Curvature is infinite for such contours.

Tests included.
2023-08-28 00:07:50 -04:00
Matthias Clasen
0a28a5d53a Add a rectangle contour
Add a contour that optimizes some things for
rectangles. Also add rectangle detection to the
path parser, and add tests similar to what we
have for the other special contours.
2023-08-27 12:36:56 -04:00
Matthias Clasen
ddd4855bbc Add a test for rectangle segments 2023-08-27 12:36:30 -04:00
Matthias Clasen
78c5aff956 Test special contours harder
Check that the start- and endpoint work
as expected and verify that their winding
numbers match the ones of the standard contour,
and are negated when the contour is reversed.
2023-08-27 11:47:40 -04:00
Matthias Clasen
0796c72049 Add roundtrip tests for rounded rect contours
These should survive roundtrips through the
path parser as well now.
2023-08-27 09:31:17 -04:00
Matthias Clasen
43b6822eb0 Add roundtrip tests for special contours
So far, we only have a circle contour.
Check that it survives a roundtrip through
gsk_path_to_string and gsk_path_parse.
2023-08-27 09:14:03 -04:00
Matthias Clasen
ead88c36ec path: Add circle tests 2023-08-26 23:42:52 -04:00
Matthias Clasen
9fdad6d4ee Make randomized path tests less precise
Bump the epsilon in test_split to make these
tests survive longer. They still fail eventually,
unfortunately.
2023-08-26 11:23:02 -04:00
Matthias Clasen
b6e285844f Make curve tests pass 2023-08-26 11:22:58 -04:00
Matthias Clasen
889688c978 Add more fill and stroke node tests 2023-08-26 07:39:23 -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
581ad5fc04 Make curve tests more robust
Add a few fudge factors that let these
tests survive extended runs.
2023-08-25 20:23:08 -04:00
Matthias Clasen
ff40dcffec Make the measure tests waste less time
No need to produce multiple contours, when
the test is just about splitting a single
curve.
2023-08-25 20:23:08 -04:00
Matthias Clasen
eb2fa4195a Make the measure tests run in ci
Marking them as slow has the unintended
side-effect of keeping them from running.
2023-08-25 20:23:08 -04:00
Matthias Clasen
2097b15f9c Add randomized measure tests
Test that lengths behave as expected when
we split paths, do roundtrips through points,
and subset paths.
2023-08-25 20:16:49 -04:00
Matthias Clasen
46a8f57735 Add tests for path length 2023-08-25 20:16:49 -04:00
Matthias Clasen
2e5639a077 Add a circle test 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
787b1a661e curve: Add tests for length
Add some tests for gsk_curve_get_length.
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
Sergey Bugaev
9f811ccee5 testsuite: Add color-matrix-merge testcase
This tests the merging of nested color matrix nodes feature of
GtkSnapshot, which was broken before commit 082fdfdb24.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-08-25 15:54:05 +03:00
Sergey Bugaev
6cd6da050b testsuite: Add render node replay tests
This takes a render node tree and "replays" it by using the GtkSnapshot
machinery. We don't necesserily expect to get back an exactly equal
render node tree back, since GtkSnapshot applies various small
optimizations where possible, but the original and the replayed nodes
should render to identical textures.

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
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
8d0654db6b Add some more arc tests 2023-08-24 07:40:05 -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
e19246d2db tests: Include arcs in curve tests 2023-08-23 22:10:51 -04:00
Matthias Clasen
0f7b9e686c Add a rounded rect test
This checks that our path-in-fill computations
agree with rounded_rect_contains_point. Sadly,
they don't do that, 100%.
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
Simon McVittie
0f125aad90 tests: Accept slightly different numeric results
FLT_EPSILON is the distance between 1.0 and the next distinct floating
point number, and doesn't necessarily have anything to do with the
precision we can expect from a series of floating-point calculations.
Experimentally, 1e-6 is achievable, even on platforms with unusual
floating point implementations like i387.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/6051
Bug-Debian: https://bugs.debian.org/1050076
Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-22 17:24:17 +01:00
G.Willems
b4977decc1 gtktexthistory: restore 'modified' flag on redo
When redoing a history entry, its `is_modified` flag is not
reflected to the history state tracker. So GtkTextBuffers may
expose a modified=FALSE status, despite a change was actually
applied to the buffer.

For the undo case, an `is_modified_set` flag was set on the last
entry of the undo queue when a change of the modified state of
the history is requested. This commit does the same on the first
entry of the redo queue.

Closes #5777
2023-08-17 22:26:00 +02:00
Matthias Clasen
87430be658 Fix up a testcase
I had gotten the path direction enum mixed up here.
2023-08-14 15:59:45 -04:00
Matthias Clasen
a85ab3585e Revise gsk_path_point_get_tangent
Update the directions enum to allow all four
tangents to be obtained. Add an illustration
to the docs for clarity.

Update all callers.
2023-08-14 14:58:22 -04:00
Matthias Clasen
6ace4b60d8 pathpoint: Revise argument order
In order for introspection and documentation to
not be confused, we need to have the GskPathPoint
be the first argument.

Update all callers.
2023-08-14 13:20:34 -04:00