Commit Graph

465 Commits

Author SHA1 Message Date
Matthias Clasen
f5159e1ecb gsk: Make glyph parsing more flexible
It is a bit annoying that one has to specify the glyph width
when specifying glyphs numerically for a text node, since this
information really is part of the font.

Make the parser more flexible, and allow to specify just the glyph
ids, without an explicit width. In this case, the width will be
determined from the font.

With this, glyphs can now be specified in any of the follwing
ways:

glyphs: "ABC";              (ASCII)
glyphs: 23, 45, 1001;       (Glyph IDs)
glyphs: 23 10, 100 11.1;    (Glyph IDs and advance widths)
glyphs: 23 10 1 2 color;    (with offsets and flags)

Tests have been updated to cover these variants.
2024-03-01 11:22:28 -05:00
Matthias Clasen
aec2f50d82 testsuite: Add a forgotten test 2024-03-01 09:23:41 -05:00
Matthias Clasen
a82de96e1a Add a testsuite for nodeparser tests
This helps when changing the node parser.
2024-02-29 21:59:04 -05:00
Matthias Clasen
9fd5558acd Update nodeparser tests
The node serialization code now prints fonts with pixel sizes.
Update affected tests.
2024-02-27 23:46:33 -05:00
Matthias Clasen
427a52a9ad Make one of the tests more robust
The text-mixed-color-nocairo test was using a 20pt font, which
results in 16.6 pixels, which is prone to triggering rounding
errors and problems with fractional node bounds. Make it use
20px instead.
2024-02-25 20:03:35 -05:00
Matthias Clasen
24de5ffd4e gsk: Stop padding text node bounds
This should not be necessary, provided that the ink extents that
pango provides are accurate.

Update affected tests.
2024-02-16 14:45:20 -05:00
Matthias Clasen
5552b5c0ec ci: Add another xfail
This is reported in
https://gitlab.gnome.org/GNOME/gtk/-/issues/6450
2024-02-16 11:13:57 -05:00
Matthias Clasen
aaaddd1b47 testsuite: Mark the randomized path tests as flaky
They are, and having them run in ci is counterproductive for now.
2024-02-16 10:24:58 -05:00
Matthias Clasen
bb82e3e1fb Merge branch 'matthiasc/for-main' into 'main'
testsuite: Drop duplicated rounded-rect tests

See merge request GNOME/gtk!6907
2024-02-14 20:21:47 +00:00
Matthias Clasen
a4583b03a1 testsuite: Drop duplicated rounded-rect tests
No need to test this twice in a row.
2024-02-14 14:12:43 -05:00
Benjamin Otte
b12169776e testsuite: Print random clip rect
That makes it in test log output, which helps when figuring out why a
test failed if the node was not saved/is already deleted.
2024-02-14 20:12:05 +01:00
Benjamin Otte
afc7b46264 gpu: Add an epsilon before ceil()ing for offscreen size
Avoids getting the scale wrong when due to a rounding error our
pixel-aligned rectangle is 5.000000003px big and we ceil() to 6px
and produce blurry output.

Fixes #6439
2024-02-14 20:11:59 +01:00
Benjamin Otte
1afc7a9210 testsuite: Add a test for scaled texture clipping
This tests that the result is suitably clipped for doing linear
blending - the rightmost green pixel that is technically offscreen
is blending into the red pixel and turning the test yellow.

Cairo gets this wrong for some reason I didn't investigate.
2024-02-14 20:11:30 +01:00
Benjamin Otte
cb6c720d37 gpu: Render enough of a scaled texture offscreen
We were not thinking about pixel alignment and the potential later
linear blend for the final composite.

Fixes #6428
2024-02-14 20:11:29 +01:00
Matthias Clasen
a246d1a995 ci: Add an xfail
Add an xfail for the issue reported in #6444.
2024-02-14 13:32:37 -05:00
Matthias Clasen
370ecd5d15 Add more rounded-rect intersection tests
Add rounded rect intersection tests with difficult rounded rects
where the corners are not disjoint (the 'evil eye').

The first half of these tests were provided by Benjamin Otte
in #6440, the other half was added by me to cover the flipped
version of the evil eye.
2024-02-14 10:37:56 -05:00
Matthias Clasen
fdff21ae13 testsuite: Don't use g_test_init
g_test_init has the ugly habit of aborting if G_DISABLE_ASSERT
is defined, and we want to run our tests in a release build too.

Use gtk_test_init instead, which works around this issue.
2024-02-14 10:37:56 -05:00
Matthias Clasen
3b794c4951 Add a test for node bounds normalization
This tests the fixes in the previous commits for some node types.
2024-02-13 20:06:16 -05:00
Matthias Clasen
1e8d7c7891 tests: Add a new xfail for a failing test
This is filed as #6439
2024-02-13 18:35:13 -05:00
Matthias Clasen
73316a83c4 tests: Remove xfails for tests that work now
We fixed some things, yay.
2024-02-13 17:31:18 -05:00
Benjamin Otte
d4203d147a testsuite: Add a test for shadow offset clipping 2024-02-13 21:56:01 +01:00
Benjamin Otte
f9b66dff8b testsuite: Add a test for shadows with large offset
This was causing crashes in the GPU renderer.

Related: #6425
2024-02-13 21:56:01 +01:00
Matthias Clasen
ea9e414ad6 Skip one more failing clipped render test 2024-02-11 22:38:52 -05:00
Matthias Clasen
1db696be79 offload: Find and use source rectangle
Look for nodes like subsurface { clip { texture {} } }, and use
the clip to provide a source rectangle for subsetting the texture.

Update affected tests, and add a new one.
2024-02-11 21:44:47 -05:00
Matthias Clasen
0495359eca subsurface: Rename rect to dest
We are going to introduce another rect, so better to be clear in
naming. We are following the naming of the Wayland viewporter spec
and call the rectangle that we drawing into the dest(ination).
2024-02-11 21:43:51 -05:00
Matthias Clasen
1995b9d92c Merge branch 'wip/otte/offload' into 'main'
Rework offload diff handling

See merge request GNOME/gtk!6879
2024-02-12 02:33:14 +00:00
Matthias Clasen
5b55456b75 Rework diffing one more time
Pass the surface along. We need it to identify the inspector case
in gsk_subsurface_node_diff.
2024-02-11 20:48:59 -05:00
Matthias Clasen
2cf90b6158 tests: Add a note
Point out a little gotcha.
2024-02-11 20:24:28 -05:00
Benjamin Otte
30afac9a6b offload: No need to pass the offload to the diff
We can just check if the subsurfaces contain content - and if they do,
they will be offloading and we can ignore the diff.

This essentially reverts 48740de71a
2024-02-11 20:24:28 -05:00
Benjamin Otte
dac56dd757 offload: Change the way we compute damage regions
Instead of relying on diffing subsurface nodes, we track damage
generated by offloaded contents inside GskOffload.

There are 3 stages a subsurface node can be in:

1. not offloaded
   Drawing is done by the renderer
2. offloaded above
   The renderer draws nothing
3. offloaded below
   The renderer needs to punch a hole.

Whenever the stage changes, we need to repaint.
And that can happen without the subsurface's contents changing, like
when a widget is put above the subsurface and it needs to to go from
offloaded above to below.

So we now recruit GskOffload for tracking these changes, instead of
relying on the subsurface diffing.

But we still need the subsurface diffing code to work for the
non-offloaded case, because then the offloading code is not used.
So we keep using it whenever that happens.

Not that when a subsurface transitions between being offloaded and not
being offloaded, we may diff it twice - once in the offload code and
once in the node diffing - but that shouldn't matter.
2024-02-11 20:24:28 -05:00
Matthias Clasen
0b34af438f ci: Add more xfails
These showed up in ci.
2024-02-11 20:22:16 -05:00
Matthias Clasen
ed605f01a2 testsuite: Give up on cairo for clipping tests
Cairo has a number of problems with clipping, such as

https://gitlab.freedesktop.org/cairo/cairo/-/issues/821
https://gitlab.gnome.org/GNOME/gtk/-/issues/6426
https://gitlab.gnome.org/GNOME/gtk/-/issues/6427

These require cairo fixes that are hard to come by, given
the maintainership situation. And since these the clipping
tests are randomized, such failures will pop up randomly,
making it very frustrating to deal with ci.

So lets focus these tests on the places where it is easier
to get fixes, and run the clipping tests only for the
other renderers.
2024-02-11 19:50:18 -05:00
Matthias Clasen
bed3c6f807 ci: Add xfails for some known issues
Add xfails for failing compare tests where we have known issues,
and annotate them.
2024-02-11 19:50:18 -05:00
Matthias Clasen
f6221835ef build: Compactify compare test setup
Make a loop over the variants we have, rather than duplicating
so much code.
2024-02-11 19:50:18 -05:00
Matthias Clasen
7e9ce1b266 compare-render: Add a --plain argument
This is entirely ignored, but having an argument to specify
for 'run tests as-is' makes the meson code simpler.
2024-02-11 19:50:18 -05:00
Matthias Clasen
c40f29cb54 build: Drop an unused array 2024-02-11 19:50:18 -05:00
Matthias Clasen
d7afa91023 gsk: Add a clip variant to compare tests
This creates a random clip rect and applies it as a clip node.

Currently, a bunch of the tests fail and need tracking down.
2024-02-11 19:50:18 -05:00
Matthias Clasen
865564b32f gsk: Make matrix transforms roundtrip better
When we parse a 2D matrix, we produce a 2D transform, and we
can easily regenerate a 2D matrix from it.

Tests included.
2024-02-11 19:39:19 -05:00
Benjamin Otte
9e72260c3b testsuite: Add a compare test for non-integer repeat children
This encodes the problems from the harmless looking example from
  https://blog.gtk.org/2024/01/28/new-renderers-for-gtk/
in a form that we can test.

Unsurprisingly it doesn't work on GL and Cairo.
2024-02-11 20:04:54 +01:00
Benjamin Otte
9d52b4e269 testsuite: Add another test for pixel alignment
Tests the rounding fixes from the previous commit.

I'm not disabling it on GL because it succeeds - but that is somewhat by
accident I guess.
2024-02-11 20:04:54 +01:00
Matthias Clasen
4b34c10d05 testsuite: Plug a memory leak 2024-02-09 00:07:34 -05:00
Alice Mikhaylenko
0bfd4b232b testsuite: Add a compare test for previous commit
Test that scaled border nodes properly scale their offsets.

Related: #6412
2024-02-09 04:28:32 +01:00
Matthias Clasen
c654cb0f37 testsuite: Add a suite for offload tests 2024-02-07 12:38:18 -05:00
Benjamin Otte
2e669099a6 testsuite: Add a test for previous commit
Related: #6389
2024-02-04 21:57:13 +01:00
Matthias Clasen
c1270cf52b gpu: Fix a crash in vulkan
The node processing wasn't skipping 0-size nodes when using the
uber shader, leading to assertions down the road. Since the ngl
renderer doesn't use uber shaders, this only affects vulkan.

Test included.

Fixes: #6370
2024-01-27 10:30:38 -05:00
Matthias Clasen
746cfe48b0 nodeparser: Fix a font handling mishap
When we don't have an embedded font file via a url, then we want
to parse fonts "as normal", i.e. allow fallback for aliases like
"Monospace 10". This was broken when the url support was added.
Make it work again.

Update affected tests. In particular, the output of the text-fail
test goes back to be the same it was before the url changes.
2024-01-26 23:54:58 -05:00
Benjamin Otte
dc1f12682c testsuite: Add a test for zero width borders
See previous commit for an explanation of the problem.

This test actually draws a rounded border, but the rounding is clipped
away. What is remaining is the 4 corners of the border, where the
top/bottom color is red and the left/right color is green. But because
the bottom/right side has a width of zero, the result should be all red.
2024-01-25 19:39:34 +01:00
Benjamin Otte
969fc17737 testsuite: Disable test on cairo
With the --repeat version of this test, Cairo needs to draw partially
clipped glyphs. However, there's a bug in Cairo where it doesn't account
for the subpixel positioning when clipping, so the glyphs get cut off at
the edge.

This is filed as https://gitlab.freedesktop.org/cairo/cairo/-/issues/821
2024-01-23 07:12:33 +01:00
Benjamin Otte
ada0ea0f68 testsuite: Add subpixel positioning test for hidpi
On hidpi (ie scaled by 2x) we want to align to the pixel grid, not the
unit grid.

The GL renderer currently gets that wrong, so it's disabled here.
2024-01-23 06:17:14 +01:00
Benjamin Otte
fff912efd3 testsuite: Add a test for subpixel positioning
Draw a grid of 21x21 box glyphs.

Each glyph is offset by n/20 pixels in the x and y direction.

The background color is carefully selected to be divisible by 16, so
that when the box glyph is subpixel positioned by 1/4th of a pixel
offset from the pixel grid in either direction, the result will be an
edge pixel whose color value can be computed exactly.

Cairo still rounds this wrong for color values >= 128 which is why we
use a dark gray that guarantees the resulting color values are all <128.
2024-01-23 06:17:14 +01:00