Commit Graph

254 Commits

Author SHA1 Message Date
Kirill Primak
62cc96b3a4 scene: update output geom on commit after dropping pending damage
Otherwise the whole output damage gets ignored.
2024-08-20 19:27:13 +03:00
Kirill Primak
5c98d1a04a xdg-surface: fix window geometry handling
It was completely wrong: according to the protocol, the effective
geometry is only updated on commit time if there pending state has
new state from xdg_surface.set_window_geometry or
xdg_surface.set_window_geometry has never been sent at all.

This commit adds wlr_xdg_surface.geometry which correctly matches the
effective window geometry and removes now-useless
wlr_xdg_surface_get_geometry().
2024-08-14 18:52:13 +00:00
Alexander Orzechowski
515275ee72 wlr_scene: Introduce wlr_scene_set_gamma_control_manager_v1 2024-08-14 13:18:56 -04:00
Alexander Orzechowski
23202e192c wlr_scene: Introduce wlr_scene_output_needs_frame
It seems that some scene compositors want to avoid wlr_scene_output_commit
and use the lower lever wlr_scene_output_build_state. However, build
state does not early return if a frame is not needed so compositors will
implement the check themselves. Let's add a helper function that compositors
can use to implement the check.

Technically pending_commit_damage is a private interface, so this lets
compositors not interface with private interfaces to implement the check.
2024-08-14 12:51:15 -04:00
Alexander Orzechowski
2463a4723e wlr_scene: Ensure we restack all xwayland surfaces to the bottom when scene node is disabled 2024-08-14 11:53:20 -04:00
Alexander Orzechowski
291df10fe5 wlr_scene: Extract function to get xwayland surface from node 2024-08-14 11:53:05 -04:00
Alexander Orzechowski
235c8e922a Revert "wlr_scene: Ensure scene_node_update is updating entire node."
This reverts commit 66d96d244c.
2024-08-14 11:51:44 -04:00
Alexander Orzechowski
4f1104654f wlr_scene: Fix WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT when output is transformed 2024-08-14 11:23:30 -04:00
Alexander Orzechowski
14e1987f50 wlr_scene: Don't special case swapchain buffers
This fixes direct scanout VRR. As direct scanout buffers are not part
of the swapchain, we would mistakenly union instead of subtract the damage
meaning it will just accumulate indefinitely.

The reason for this existing in the first place is for compositors that
might want to sidestep scene and commit their own buffers to the output.
In this case, scene could theoretically acknowledge that and update the
damage. Except, this really didn't work because WLR_OUTPUT_STATE_DAMAGE
would need to be defined which is optional. This patch also properly
acknowledges commits without damage.

In the use case of a weird compositor that might want to sidestep scene,
they can just trash the damage ring themselves.

Fixes: #3871
2024-08-14 11:23:02 -04:00
Alexander Orzechowski
3e1358fec9 wlr_scene: Inline output_state_apply_damage 2024-08-14 11:23:02 -04:00
Alexander Orzechowski
147c5c37e3 wlr_scene: Immediately apply pending output commit damage
There were two problems with the old implementation:
1. wlr_scene_output_commit would bail early if a frame wasn't requested
and there was no commit damage, however commit damage could never accumulate
until rendering happens. The check was subtly wrong as a result.
2. Previously, we would fill the pending commit damage based on the
current state of the damage ring. However, during direct scanout, the
damage would accumulate which would mean we would submit damage from
previous frames even if we didn't need to.
2024-08-14 11:23:01 -04:00
Alexander Orzechowski
78dfa4f06d wlr_scene: Funnel all damage operations through scene_output_damage
We want to add logic to this function later
2024-08-14 11:21:00 -04:00
Alexander Orzechowski
1133bc15ce wlr_scene: Transparently restack xwayland surfaces
Scene will now automatically restack xwayland windows. Scene
compositors should drop calls to wlr_xwayland_surface_restack()
2024-08-06 20:00:01 -04:00
Alexander Orzechowski
66d96d244c wlr_scene: Ensure scene_node_update is updating entire node.
The old logic might not update the entire scene node when a node is
disabled. It would only consider the damage last time (the damage was
based on the visible region of the node).

It's important that we update the entire node region because xwayland
stacking will depend on this.
2024-08-06 20:00:01 -04:00
Alexander Orzechowski
823a64bf7d wlr_scene: Store update box in update data
We'll use it later
2024-08-06 20:00:01 -04:00
Simon Ser
5f88635118 scene: add explicit synchronization for rendered buffers 2024-08-06 17:37:06 +00:00
Simon Ser
9e9636f675 scene: add support for linux-drm-syncobj-v1 2024-08-06 17:37:06 +00:00
Simon Ser
c7035da5e2 scene: add timeline point to wlr_scene_buffer_set_buffer() options 2024-08-06 17:37:06 +00:00
Simon Ser
48f0902a36 scene: add wlr_scene_buffer_set_buffer_with_options()
This is an extensible version of wlr_scene_buffer_set_buffer().
2024-08-06 17:37:06 +00:00
Alexander Orzechowski
4481c6b243 wlr_scene: Force blend mode to PREMULTIPLIED if calculate visibility is disabled
We do it here so WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION doesn't break
2024-08-05 14:46:30 -04:00
Simon Ser
e34cc23549 scene: only skip bottom-most black rects with fractional scaling
We were relying on the fact that we wouldn't paint anything on top
of the black background in the region of a black rect. However
when fractional scaling is used the repaint region might get
expanded to nearby pixels by scale_output_damage(). As a result
the neighbour scene nodes might leak into the skipped black rect's
region.

Avoid this by using this optimization for bottom-most black rects
only when fractional scaling is used.

References: https://github.com/swaywm/sway/issues/8233
2024-07-11 21:03:27 +02:00
Alexander Orzechowski
ee24201e26 wlr_scene: Don't disable scene nodes at creation time 2024-07-04 14:35:52 -04:00
Alexander Orzechowski
a9375d6bac wlr_scene: Drop map/unmap listeners from layer_shell_v1
Redundant.
2024-07-04 14:10:33 -04:00
Alexander Orzechowski
48b9b7d406 wlr_scene: Drop map/unmap listeners from drag_icon
Redundant.
2024-07-04 14:09:47 -04:00
Alexander Orzechowski
24a9f88873 wlr_scene: Drop map/unmap listeners from xdg_shell
subsurface_tree will handle it. This was redundant.
2024-07-04 14:08:24 -04:00
Alexander Orzechowski
65e6579c56 wlr_scene: send preferred buffer transform 2024-06-28 13:44:35 -04:00
Kenny Levinsen
13b9b54f3f wlr_scene: Skip direct scanout on color transform
If we need to apply a color transform to rendered content, we will not
be able to use direct scanout. Explicitly skip it to not accidentally
show frames lacking the color transform.
2024-05-24 17:24:32 +02:00
Alexander Orzechowski
53be443f39 wlr_scene: Add WLR_SCENE_HIGHLIGHT_TRANSPARENT_REGION env 2024-05-05 02:22:50 +03:00
Kirill Primak
8fdf9dc4f0 scene: fix double scaling of opaque region for blend mode optimization 2024-05-05 01:54:59 +03:00
Simon Ser
027d453f6a scene/surface: add support for alpha-modifier-v1 2024-04-30 17:49:34 +02:00
Manuel Stoeckl
391410deb5 wlr_scene: add color transform argument for rendering 2024-04-26 17:17:36 +00:00
Alexander Orzechowski
41fd552f53 wlr_scene: Set wlr_damage_ring_set_bounds earlier
Fixes the _HIGHLIGHT option not highlighting the buffer correctly after
a resize
2024-04-24 12:58:17 -04:00
Alexander Orzechowski
1dc44a1afe wlr_scene: Schedule new frame for WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT in output commit handler
We were doing it too early before and the output would disregard a
scheduled frame if called when we were first putting together the output
state
2024-04-24 12:58:17 -04:00
Alexander Orzechowski
14692a7c55 wlr_scene: Fix WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT output damage 2024-04-24 12:58:17 -04:00
Consolatis
e70afebfc9 scene: do not reset scene_buffer state on buffer release
This fixes an issue with some buffers not rendering anymore due
to buffer_width and buffer_height being reset on buffer release.
2024-04-23 19:37:28 +02:00
Isaac Freund
cb01c63a8d
scene: ensure layer surface usable area >0
Clients may, for example, commit an exclusive zone larger than the
output dimensions. Compositors must handle this gracefully, which likely
requires more work on the compositor side but returning a usable area
with negative width or height in wlr_scene_layer_surface_v1_configure()
is nonsensical.
2024-04-16 11:49:08 +02:00
Isaac Freund
b7d003caef
scene: constify subsurface_tree_set_clip() 2024-03-20 12:56:28 +01:00
Simon Ser
859373b253 scene: listen to renderer destroy in wlr_scene_buffer
When a renderer is destroyed, so are all textures. Reset the
texture in that case.
2024-03-14 22:07:42 +01:00
Simon Ser
3d9f330ee0 scene: add scene_buffer_set_texture() 2024-03-14 22:06:10 +01:00
Alexander Orzechowski
86e1b24d84 wlr_scene: Track damage of null textures
If we hit this case, we effectively failed to render something, this might
be because a texture failed to upload or the texture is momentarily
unavailable after a GPU reset. If we fail to render, we have to continue
to track damage for the next frame in hopes that the texture becomes
available then.

An alternative approach would be to fail the commit completely if we
find this case, but in the case of gpu resets, clients may not commit
a new buffer for a while, and a frozen display does not help.

This fixes damage tracking issues after a gpu reset.
2024-03-13 07:53:33 +00:00
Alexander Orzechowski
2aebb8e444 wlr_scene: Fix crash when committing NULL buffer
If we commit a null buffer, we want to avoid the buffer damage path and
instead just update the node to avoid it.
2024-03-13 07:50:54 +00:00
Alexander Orzechowski
8da93e5936 wlr_scene: Add support for custom swapchains 2024-03-12 11:26:03 -04:00
Alexander Orzechowski
239354d644 wlr_scene: Decide when to commit output damage with buffers in damage ring
We will soon support custom swapchains. In order to track output damage
we should instead use the damage_ring which will hold all the buffers
we are currently tracking anyway across an arbitrary amount of swapchains.
2024-03-12 11:25:58 -04:00
Alexander Orzechowski
8220184a72 wlr_scene: Assert that buffer returned from swapchain is the right size 2024-03-12 11:16:30 -04:00
Simon Ser
c79ed0706d scene: simplify scene_node_update() condition when setting buffer 2024-03-12 12:11:35 +01:00
Alexander Orzechowski
2d97935e82 wlr_scene: Call surface enter scale events on surface create
We would fail to call scene_node_update() which would then call output
events for us. We need to make sure to update the node when we first map
a buffer, as the comment explained.
2024-03-12 01:57:07 -04:00
Simon Ser
431e8a7fd7 scene: ignore duplicate wlr_scene_output_layout_add_output() calls
An assert was added in [1] to avoid tracking the same output multiple
times. However, this is cumbersome for compositors [2]: they need to
add a special check for this. Additionally, this is inconsistent with
wlr_output_layout_add().

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4380
[2]: https://github.com/cage-kiosk/cage/pull/315
2024-02-20 11:04:46 +01:00
Simon Ser
842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Paul Cercueil
220df2aa0f
Add more POSIX compliance macros to fix uClibc support
- Add POSIX 1993.09 compliance macro in source files that use
  "struct timespec";
- Add POSIX 2001.12 compliance macro in source files that use
  "struct sigaction" and the SA_SIGINFO macro, or the fchmod()
  function;
- Add POSIX 2008.09 compliance macro in source files that use the
  getline() function.

These compliance macros are enough for wlroots to compile with the
git-master version of uClibc-ng.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2024-02-12 17:41:45 +01:00
Simon Ser
4ec901bb33 scene: release shm buffers once uploaded
Once a shm buffer is uploaded there's no reason for wlr_scene_buffer
to keep it locked any further. Allow the compositor to re-use it.
2024-01-27 12:21:54 +00:00