Commit Graph

28 Commits

Author SHA1 Message Date
Benjamin Otte
3221a8bdab gdk: Rename GdkTextureTransform to GdkDihedral
... and put it into its own header.

We want to use it in more places and the name and location are awkward.
2024-07-10 12:36:07 +02:00
Matthias Clasen
880c33a777 offload: Don't assert things that might fail
We can in fact meet complex transforms here. Asserting that they
are simple doesn't make it so. Instead, simply bail out if a
transform is too complex; in this case we can't offload anyway,
so no need to walk the tree further.

Test included.

Fixes: #6824
2024-07-08 08:15:02 -04:00
Matthias Clasen
3fc9de7539 offload: Make logging more compact
Use a format of

[XXX] SYMBOL DETAILS

where SYMBOL indicates the offloading status:
 🗙 - no offload
 ▲ - offload above, with background
 △ - offload above, no background
 ▼ - offload below, with background
 ▽ - offload below, no background
2024-04-24 22:01:56 -04:00
Matthias Clasen
b21708c5e4 offload: Consolidate logging a bit
Spew a bit less per-frame. Unfortunately, we still spew for
every frame, and fixing that would require more extensive
refactoring to centralize all logging in gskoffload.c
2024-04-21 20:18:38 -04:00
Matthias Clasen
e583e823b5 Use our defines for color
We have GDK_RGBA_WHITE, GDK_RGBA_BLACK and GDK_RGBA_TRANSPARENT,
lets use it instead of open-coding it.
2024-04-15 22:57:01 -04:00
Matthias Clasen
4aac64edf0 offload: Some renaming
Rename things to be more in line with the subsurface api.
2024-04-15 19:53:46 -04:00
Matthias Clasen
c97bbfdfb1 offload: Use subsurface bounds for diffing
When adding the whole subsurface to the diff, use the subsurface
bounds, which takes both the texture and the background into
account.
2024-04-15 19:53:46 -04:00
Matthias Clasen
933a0e5a98 subsurface: Some api revision and documentation
Rename things so they make more sense. The dest/source naming got
a bit unclear when we added background into the mix. Now we're going
for:

source_rect - the texture region to display
texture_rect - dimensions of the subsurface showing the texture
background_rect - dimensions of the background subsurface
bounds - union of texture_rect and background_rect

Also use this opportunity to add some api docs.
2024-04-15 19:53:46 -04:00
Matthias Clasen
0108a5f56d offload: Use subsurface background optimization
Detect a black color node below the texture node and pass that
information to the subsurface, to take advange of the single-pixel
buffer optimization.

To make this work, we need to stop using the bounds of the subsurface
node for sizing the offload, and instead use either the clip or
the texture node for that.
2024-04-15 19:53:46 -04:00
Matthias Clasen
3f9bdaa4c8 Add background to subsurfaces
Make it possible for subsurfaces to have a black background on a
secondary subsurface below the actual subsurface. Using a single-pixel
buffer for that background increases the changes that the compositor
will use direct scanout for the actual subsurface.

This changes the private subsurface API. All callers have been
updated to pass an empty background rect.
2024-04-15 19:53:46 -04:00
Matthias Clasen
704ee6a9d0 offload: Determine output transforms
When we look for the texture to attach to the subsurface, keep
track of transforms we see along the way, and look at their scale
component to determine if the texture needs to be flipped.
We currently don't allow rotations here.

This fixes glarea rendering being upside-down when offloaded.
2024-04-07 11:12:06 -04:00
Matthias Clasen
72e9f30937 subsurface: Add transforms
Allow to specify a D₂ transform when attaching a texture to a
subsurface, to handle flipped and rotated content. The Wayland
implementation handles these transforms by setting a buffer
transform on the subsurface.

All callers have been updated to pass GDK_TEXTURE_TRANSFORM_NORMAL.
2024-04-07 11:02:40 -04: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
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
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
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
be2dcdd897 offload: Fix our tree walk
We were not finding an overlaid spinner, since it is implemented
as a texture in a (most of the time) non-affine transform, and
we were aborting our treewalk when we see such transforms.

Instead, don't abort the walk on any transforms, but check if we
are in an affine context before deciding to offload a subsurface.
2024-02-09 12:43:38 -05:00
Matthias Clasen
46cb0c5fc8 offload: Small optimization
Don't transform bounds more often than necessary.
2024-02-09 12:19:16 -05:00
Matthias Clasen
36314f28e2 gsk: Some more rect inlining 2023-11-24 10:35:57 -05:00
Matthias Clasen
a90a6c4517 Address various static analysis complaints
These were picked out of the scan_build logs in ci.
2023-11-22 00:07:47 -05:00
Matthias Clasen
160fa969d4 subsurface: Replace place_above/below
Instead, do it all in attach(), which becomes more and more like
ConfigureWindow. This is good, because it will let us take the
above-ness into account when making decisions about attaching.
2023-11-21 13:24:04 -05:00
Matthias Clasen
fb969f5431 offload: Raise all subsurfaces that can be
If two subsurfaces don't overlap and aren't otherwise obstructed,
we can just raise them  both.

Tests included.
2023-11-18 08:19:43 -05:00
Matthias Clasen
ef6ed31853 offload: Drop unused api 2023-11-18 08:19:43 -05:00
Matthias Clasen
f9fd78b67e offload: Keep was-raised for each subsurface
We need this information for proper diffing.
2023-11-18 08:19:43 -05:00
Benjamin Otte
653bf46494 offload: Refactor texture finding
It's the same code, but with way more debose debug messages.
2023-11-14 15:04:38 +01:00
Benjamin Otte
4920ac4a57 offload: Move a debug message
If we fail to attach a buffer, we don't want to print this.
2023-11-14 15:04:38 +01:00
Matthias Clasen
34c16b0df2 gsk: Add code to offload to subsurfaces
This code walks the node tree, finds subsurface nodes, determines
if we can offload to the subsurface, and if yes, does so. This
isn't used yet.
2023-11-13 22:17:35 +01:00