Commit Graph

79233 Commits

Author SHA1 Message Date
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
9a30ea1f69 subsurface: Have a source rectangle
This will let us use a subset of the full texture, which can
be necessary in the case that converters put padding around
content in dmabufs. The naming follows the Wayland viewporter
spec.

For now, make all callers pass the full texture rect.
2024-02-11 21:44:27 -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
29c0babdda Merge branch 'matthiasc/for-main' into 'main'
testdmabuf: Add another shortcut

See merge request GNOME/gtk!6888
2024-02-12 02:15:22 +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
70205f59a4 Merge branch 'render-clip-tests' into 'main'
gsk: Add a clip variant to compare tests

See merge request GNOME/gtk!6880
2024-02-12 01:45:55 +00:00
Matthias Clasen
df7889d7f3 testdmabuf: Add another shortcut
Make the picture not expand, and add Ctrl-S to toggle the
horizontal alignment between start and center. This makes the
offloaded picture move under the overlaid controls, or out
from under them, triggering some offloading transitions.
2024-02-11 20:43:56 -05:00
Matthias Clasen
26c25cc6b7 Simplify gsk_subsurface_node_diff
Most of the time, the subsurfaces will be the same. And if they
aren't, can_diff() will return FALSE anyway.
2024-02-11 20:24:28 -05:00
Matthias Clasen
2cf90b6158 tests: Add a note
Point out a little gotcha.
2024-02-11 20:24:28 -05:00
Matthias Clasen
f8e89f2224 offload: Do diff collection later
We were collecting diffs based on the can_offload/can_raise
information, but attaching the texture to the subsurface can
fail (e.g. if its not a dmabuf texture), in which case can_offload
turned out to be wrong. So move the diff collection to the end
and do it based on the whether we actually succeeded in attaching
the texture.
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
Benjamin Otte
e4ca3a285e gsk: Split out a function
I want to use it elsewhere.

I didn't come up with a better name, if anyone knows one, please
rename.
2024-02-11 20:24:28 -05:00
Benjamin Otte
30b5a33444 rendernode: Fix subsurface diff code 2024-02-11 20:24:28 -05:00
Benjamin Otte
e647ebae87 rendernode: Do full diff when starting/stopping offload
When a subsurface goes from not offloaded to offloaded (or vice versa),
we need to add the whole node to the diff region, because we switch from
whatever contents were drawn to a punched hole.
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
a9949a102b Merge branch 'matthiasc/for-main' into 'main'
gsk: Make matrix transforms roundtrip better

See merge request GNOME/gtk!6886
2024-02-12 01:18:34 +00:00
Matthias Clasen
90296dab76 Merge branch 'wip/otte/for-main' into 'main'
dmabuf: Make init_dmabuf() restore the previous GL context

Closes #6398

See merge request GNOME/gtk!6887
2024-02-12 01:04:14 +00: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
9bd6d431af ci: Capture generated node files for gsk tests
For some of the compare render variations (mask, clip, etc), it
can be quite useful to have the generated node file around to
reproduce the problem.
2024-02-11 19:41:21 -05:00
Benjamin Otte
f126986c2b dmabuf: Make init_dmabuf() restore the previous GL context
Random code can call that function and cause unexpected GL context
changes. This is especially bad because it can happen nested.

Fixes the NGL renderer breaking in the inspector when importing a dmabuf
initializes the dmabuf backend which creates a GL renderer which creates
a GL context and makes it current causing the NGL renderer to break when
it continues rendering.

Fixes #6398
2024-02-12 01:39:32 +01: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
3ae6da10b1 Merge branch 'wip/otte/for-main' into 'main'
Fix pixel alignment on fractional scales

See merge request GNOME/gtk!6885
2024-02-11 20:10:33 +00:00
Benjamin Otte
1b9002afd3 ngl: Check for GL 3.3
The default check is still for GL 3.0 and we don't support that.
2024-02-11 20:04:54 +01: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
Benjamin Otte
6ed4eece04 gpu: debug-print the used shader clip
When using GSK_DEBUG=verbose, print the clip mode used in the shader.

Use cute little unicode indicators to not overload the debug output.
2024-02-11 20:04:54 +01:00
Benjamin Otte
cfaddb5d47 gpu: Use nodprocessor infrastructure for offscreening
The just copied over function can just use the same infrastructure as
the other functions we already have that create slightly adjusted
offscreens.
2024-02-11 20:04:54 +01:00
Benjamin Otte
7c861d8b59 gpu: Don't clip again after already clipping
The 2 callers of gsk_gpu_get_node_as_image() were already computing the
minimum clip region and in particular aligning it to the pixel grid, so
intersecting with node bounds again was causing that alignment to be
busted.
2024-02-11 20:04:54 +01:00
Benjamin Otte
1c3457adfb gpu: Fix sizing of fractionally scaled backbuffer
When using a window size and scale that don't multiply to an integer, we
were using the wrong method to adjust it.

The Wayland fractional scaling spec just says:

> For toplevel surfaces, the size is rounded halfway away from zero.

This is meant to be interpreted as "create a large enough buffer to hold
partial pixels) and the compositor will blend it mapping to the pixel
grid" even if that means the buffer slightly overhangs.

Example:
A 11 units wide window at 150% will need a 11 * 1.5 = 16.5 pixel wide
buffer. This should be rounded to 17 pixels but rendered as if only 16.5
pixels are occupied by the window, not as if all 17 pixels are occupied.
2024-02-11 20:04:54 +01:00
Benjamin Otte
a2e46c4d39 gpu: Move function
It is only used by the nodeprocessor, so put it where it belongs.
2024-02-11 20:04:54 +01:00
Benjamin Otte
df1d024059 Revert "gpu: Fix scale fluctuation"
This commit is wrong.
It does achieve what it sets out to do, but the method doesn't work.

It confused multiple things in one commit, the commit message only
describes the symptoms it tries to fix and not why the fix is correct,
it includes no tests and it wsn't properly reviewed.

Related: !6871
2024-02-11 20:04:54 +01:00
Carlos Garnacho
e492dac7fe Merge branch 'gtk4_crash_tablet_pad_remove' into 'main'
gdk/wayland: Clear current_tablet on pad leave

See merge request GNOME/gtk!6883
2024-02-11 17:07:14 +00:00
Colin Kinloch
fabe0516fa gdk/wayland: Clear current_tablet on pad leave
Fixes crash when handling tablet pad removal event after the
current_tablet has already been freed.
2024-02-11 14:52:30 +00:00
Matthias Clasen
84971b9076 Merge branch 'gtkcalendar-issue-2440' into 'main'
GtkCalendar: Add missing accessors

See merge request GNOME/gtk!6849
2024-02-11 14:40:30 +00:00
Ahmed Baïzid
5efc33fe65 GtkCalendar: Add missing accessors 2024-02-11 14:40:30 +00:00
Matthias Clasen
52c228fd9e Merge branch 'macos-dmabuf-tests' into 'main'
macos: skip dmabuf tests

See merge request GNOME/gtk!6874
2024-02-11 13:48:33 +00:00
Matthias Clasen
674b5b808e Merge branch 'gtkcalendar-doc-mentions-gdate' into 'main'
GtkCalendar: Remove a mention of GDate from the doc

See merge request GNOME/gtk!6876
2024-02-11 12:39:04 +00:00
Matthias Clasen
af62aa4497 Apply 1 suggestion(s) to 1 file(s) 2024-02-11 12:04:21 +00:00
Matthias Clasen
137a7096c3 Merge branch 'announcement-priority-docs-fix' into 'main'
Fix docs for GtkAccessibleAnnouncementPriority

See merge request GNOME/gtk!6881
2024-02-11 12:01:46 +00:00
Arjan Molenaar
703e5ab9a8 dmabuf: Skip dmabuf tests for macOS
Dmabuf is not supported for macOS.
2024-02-11 11:27:13 +01:00
Sebastian Dröge
e2dc94d0e8 Fix docs for GtkAccessibleAnnouncementPriority 2024-02-11 11:19:56 +02:00
Matthias Clasen
b821103d1e Merge branch 'sonny/fix-gtkimage.file-desc' into 'main'
gtk: Fix GtkImage.file description

See merge request GNOME/gtk!6878
2024-02-10 21:54:21 +00:00
Sonny Piers
b40c9d8dcd gtk: Fix GtkImage.file description 2024-02-10 22:01:51 +01:00