Commit Graph

94 Commits

Author SHA1 Message Date
Simon Ser 78c76ddd09 backend: add wlr_backend_{test,commit}() 2024-03-14 22:03:10 +00:00
Simon Ser e8b7fe8f39 output: use output_pending_enabled() in output_basic_test() 2024-02-26 17:20:12 +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
Alexander Orzechowski cca2bfbe92 output: Drop pending state 2024-01-24 18:46:45 +00:00
Simon Zeni 5d639394f3 types/output: emit destroy event before destroying global 2023-11-30 13:29:18 -05:00
Alexander Orzechowski 7702a19739 output: Drop back_buffer 2023-11-29 16:00:24 -05:00
Simon Ser 56ec13596a Cleanup wlr_matrix.h includes
Many files used to require wlr_matrix but no longer do.
2023-11-25 08:37:43 +01:00
Alexander Orzechowski 26158d0718 output: Drop transform matrix 2023-11-23 16:32:58 -05:00
Kirill Primak 78a09573af output: fix display destroy listener double removal
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3762
2023-11-23 21:20:46 +03:00
Simon Ser d61ec694b3 output: take wl_event_loop in wlr_output_init()
We don't need the whole wl_display here anymore. The wl_event_loop
is enough.
2023-11-23 11:39:25 +00:00
Simon Ser d23d8ed3ba output: setup display destroy listener in wlr_output_create_global()
The wl_display destroy listener cleans up the global (if any).
wlr_output.display will go away, so setup the listener in
wlr_output_create_global() instead of wlr_output_init().
2023-11-23 11:39:25 +00:00
Simon Ser 5717e27c06 output: take wl_display in wlr_output_create_global()
Currently wlr_output holds a wl_display, but it will go away soon.
Instead of relying on that field in wlr_output_create_global(),
make the dependency explicit by taking a wl_display as argument.
2023-11-23 11:39:25 +00:00
Simon Ser 1c24b1182b backend: drop wlr_backend_get_presentation_clock()
We can just assume CLOCK_MONOTONIC everywhere.

Simplifies the backend API, and fixes clock mismatches when multiple
backends are used together with different clocks.
2023-10-30 18:39:39 +01:00
Alexander Orzechowski 5fb0007e02 output_event_commit: Remove committed and buffer
The newly introduced state struct can be used to retrieve this.
2023-10-06 10:06:01 +00:00
Alexander Orzechowski 03e240a7f2 wlr_output: Add applied state to commit event 2023-10-06 10:06:01 +00:00
Alexander Orzechowski 5ef42e8e8a output_defer_present: Calloc right struct 2023-10-02 10:11:26 -04:00
Rose Hudson 83af3202f9 output: defer fake present events until after commit
Since headless and wayland-without-presentation-feedback were firing
present inside their commit impls, present was getting fired before
commit, which is cursed. Defer this with an idle timer so that commit
handlers can run before present handlers.
2023-10-02 12:34:06 +00:00
vaxerski c2aa7fd965 backend/drm: Add async page flip support to legacy
Atomic doesn't support such flags yet.
2023-09-28 16:53:08 +00:00
Alexander Orzechowski 6c54c34713 output: Mutate frame_pending needs_frame when there is an explicit output commit
These states would be set if output_init is invoked with a enabled state.
This would make frame_pending == true which means wlroots will ignore
any further frame events and the compositor will appear dead.
2023-09-11 03:28:01 -04:00
Simon Ser e5fc8cd4c7 output: trigger frame/present events on all commits on enabled output
Up until now, frame/present events were only triggered when the
user submitted a buffer. Change the wlr_output API so that these
events are triggered when any commit is applied on an enabled
output.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3708
2023-08-23 15:42:22 +00:00
Rose Hudson 462f04db9e output: don't forbid multiple commits per frame
It's still not possible to commit while a page flip is pending in DRM,
but we don't need to enforce that here and allowing it through the
common interface can be useful for other backends.

This decouples commits from frame scheduling, which is going to make the
new frame schedulers easier to implement.
2023-08-23 16:37:07 +02:00
Alexander Orzechowski e85c79051c wlr_output: Set current_mode during new custom mode
When setting a custom mode current_mode will not be reset. That means
that next time the compositor tries to reset back from the custom mode,
it will compare against the stale current_mode and unset
WLR_OUTPUT_STATE_MODE erroneously.
2023-08-22 09:46:24 +00:00
Alexander Orzechowski 568b1943b9 wlr_output: Nuke wlr_output_update_enabled 2023-08-16 18:37:55 +02:00
Alexander Orzechowski 63351cf81f output: Schedule mode updates to happen with rest of output events 2023-08-16 18:37:55 +02:00
Alexander Orzechowski f042de3f51 output: Inline wlr_output_update_{custom,}_mode 2023-08-16 18:37:55 +02:00
Alexander Orzechowski f1ba70ffa6 wlr_output: Make wlr_output_update_{custom,}_mode private
Backends should be using wlr_output_send_request_state to request
modesets to the compositor. This will be inlined and removed next commit.
2023-08-16 18:37:55 +02:00
Alexander Orzechowski 6cda3e251c output: Add initialization state to wlr_output_init 2023-08-16 11:46:27 -04:00
Alexander Orzechowski 8f67446cc7 output: Extract common commit logic 2023-08-16 11:46:26 -04:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Alexander Orzechowski 8243399385 output: Set output mode during main commit
Removes duplication across all the backends to finally apply the mode
to the output.
2023-06-27 11:47:58 -04:00
Simon Ser be05097968 output: add wlr_output_state_init()
This changes the semantics of wlr_output_state. Instead of having
fields with uninitialized memory when missing from the committed
bitflag, all fields are always initialized (and maybe NULL/empty),
just like we do in wlr_surface_state. This reduces the chances of
footguns when reading a field, and removes the need to check for
the committed bitfield everywhere.

A new wlr_output_state_init() function takes care of initializing
the Pixman region.
2023-06-23 18:07:26 +00:00
Simon Ser c4d4409deb output: stop using wlr_output.back_buffer in output_ensure_buffer()
This allows us to use the new render pass API, and drops some
implicit state usage.
2023-06-20 16:33:41 +00:00
Simon Ser b625a13156 output: attach buffer to state in output_ensure_buffer() 2023-06-20 16:33:41 +00:00
Simon Ser 670915eeea output: add wlr_output_state_set_layers() 2023-06-13 12:02:49 +00:00
Simon Ser 5d5cf34486 output: add wlr_output_state_set_gamma_lut() 2023-06-08 18:47:46 +00:00
Alexander Orzechowski 90d08f8f1c wlr_drm_format: Rework wlr_drm_format_intersect
Now it takes a reference to a destination format
2023-05-11 18:24:43 +02:00
Alexander Orzechowski b45396c790 wlr_drm_format: Introduce drm_format_finish 2023-05-11 03:51:01 -04:00
Simon Ser d933f5204b output: drop wlr_output_cursor_set_surface 2023-05-06 13:59:05 -04:00
Simon Ser 44069dfd5e output-layer: add cropping support
Add a src_box state field. Use the SRC_* KMS props in the DRM
backend, reject the layers in the Wayland backend (for now, we can
support it later via viewporter).
2023-04-20 10:39:46 +02:00
Simon Ser 7abda952d0 output: drop direct scan-out check in output_basic_test()
wlr_output is not well-suited to checking whether direct scan-out
is happening or not. Compositors may want to use their own external
swapchains, for instance.

Additionally, ab7eabac84 ("output: leverage
wlr_output_configure_primary_swapchain()") makes it so
output_basic_test() is called before the output swapchain is
initialized, resulting in false positives.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3620
2023-04-06 21:46:45 +02:00
Simon Ser 079ff9e6fb output: add wlr_output_is_direct_scanout_allowed()
This lets compositors check whether direct scan-out is possible.
Compositors will soon be responsible for manually calling this
function.
2023-04-06 21:42:08 +02:00
Simon Ser 835208db98 output-layer: add support for scaling buffers
This allows callers to set a destination size different from the
buffer size to scale them.

The DRM backend supports this. The Wayland backend doesn't yet
(we'd need to wire up viewporter).
2023-04-04 19:39:38 +02:00
Simon Ser e00c4cd7dc output-layer: cache current state
The will be used by the Wayland backend to figure out whether
updating sub-surface position is necessary.
2023-03-28 22:58:29 +00:00
Simon Ser 1b6fac4aa6 output-layer: require all layers in wlr_output_state.layers
- Simplifies the backends
- Avoids having two ways to do the same thing: previously one could
  disable a layer by either omitting it from wlr_output_state.layers,
  or by passing a NULL buffer
- We can change our mind in the future: we can allow users to omit
  some layers and define a meaning without breaking the API.

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4017#note_1783997
2023-03-10 11:16:01 +00:00
Simon Ser 5079000e49 output: allow modeset with buffer while frame is pending
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3600
2023-02-26 18:42:31 +01:00
Simon Ser b33ab26fe7 render/swapchain: make public
We've had this struct for a while. It'd be useful for compositors
if they want to manage the swap chains themselves instead of being
forced to use wlr_output's. Some compositors might also want to use
a swapchain without an output.
2023-02-21 17:14:31 +01:00
Simon Ser 7215bd1e0f output: expose wlr_output_state_set_buffer() 2023-02-21 09:43:43 +00:00
Simon Ser 4629d0ef40 output: expose wlr_output_state_finish()
Same as the original function, but check for the bitfield before
calling pixman_region32_fini(), because that function expects an
initialized region.
2023-02-21 09:43:43 +00:00
Simon Ser 3e0ce761ad output: add wlr_output_set_layers() 2023-02-20 18:38:09 +01:00
Simon Ser 2f29b0c438 Add wlr_output_layer
This is based on previous work [1] [2].

This new API allows compositors to display buffers without needing to
perform rendering operations. This API can be implemented on Wayland
using subsurfaces and on DRM using KMS planes.

Compared to [1], this approach leverages wlr_addon_set to let backends
attach their own private state to layers, removes the pending
state (necessary for interop with wlr_output_commit_state()) and
enum wlr_output_layer_state_field.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/1985
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3447
2023-02-20 18:38:09 +01:00