diff options
author | Simon Ser <contact@emersion.fr> | 2022-06-28 18:22:42 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-02-20 18:38:09 +0100 |
commit | 2f29b0c4381a8b544eff89d8be306154a808302e (patch) | |
tree | e99465fd568d7f924bcde08aec4c3e27509b7442 /include/wlr | |
parent | 0335ae9566310e1aa06f17a4b87d98775fd03622 (diff) |
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
Diffstat (limited to 'include/wlr')
-rw-r--r-- | include/wlr/interfaces/wlr_output.h | 3 | ||||
-rw-r--r-- | include/wlr/types/wlr_output.h | 7 | ||||
-rw-r--r-- | include/wlr/types/wlr_output_layer.h | 68 |
3 files changed, 77 insertions, 1 deletions
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 073ed023..6c0bbd6c 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -22,7 +22,8 @@ WLR_OUTPUT_STATE_SCALE | \ WLR_OUTPUT_STATE_TRANSFORM | \ WLR_OUTPUT_STATE_RENDER_FORMAT | \ - WLR_OUTPUT_STATE_SUBPIXEL) + WLR_OUTPUT_STATE_SUBPIXEL | \ + WLR_OUTPUT_STATE_LAYERS) /** * A backend implementation of struct wlr_output. diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 45a93d47..5731eb91 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -67,6 +67,7 @@ enum wlr_output_state_field { WLR_OUTPUT_STATE_GAMMA_LUT = 1 << 7, WLR_OUTPUT_STATE_RENDER_FORMAT = 1 << 8, WLR_OUTPUT_STATE_SUBPIXEL = 1 << 9, + WLR_OUTPUT_STATE_LAYERS = 1 << 10, }; enum wlr_output_state_mode_type { @@ -104,6 +105,10 @@ struct wlr_output_state { // only valid if WLR_OUTPUT_STATE_GAMMA_LUT uint16_t *gamma_lut; size_t gamma_lut_size; + + // only valid if WLR_OUTPUT_STATE_LAYERS + struct wlr_output_layer_state *layers; + size_t layers_len; }; struct wlr_output_impl; @@ -191,6 +196,8 @@ struct wlr_output { struct wlr_buffer *cursor_front_buffer; int software_cursor_locks; // number of locks forcing software cursors + struct wl_list layers; // wlr_output_layer.link + struct wlr_allocator *allocator; struct wlr_renderer *renderer; struct wlr_swapchain *swapchain; diff --git a/include/wlr/types/wlr_output_layer.h b/include/wlr/types/wlr_output_layer.h new file mode 100644 index 00000000..92980108 --- /dev/null +++ b/include/wlr/types/wlr_output_layer.h @@ -0,0 +1,68 @@ +/* + * This an unstable interface of wlroots. No guarantees are made regarding the + * future consistency of this API. + */ +#ifndef WLR_USE_UNSTABLE +#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" +#endif + +#ifndef WLR_TYPES_WLR_OUTPUT_LAYER_H +#define WLR_TYPES_WLR_OUTPUT_LAYER_H + +#include <wlr/types/wlr_output.h> +#include <wlr/util/addon.h> + +/** + * An output layer. + * + * Output layers are displayed between the output primary buffer (see + * wlr_output_attach_buffer() and wlr_output_attach_render()) and the cursor + * buffer. They can offload some rendering work to the backend. + * + * To configure output layers, callers should call wlr_output_layer_create() to + * create layers, attach struct wlr_output_layer_state onto + * struct wlr_output_state to describe their new state, and commit the output. + * + * Backends may have arbitrary limitations when it comes to displaying output + * layers. Backends indicate whether or not a layer can be displayed via + * wlr_output_layer_state.accepted after wlr_output_test() or + * wlr_output_commit() is called. Compositors using the output layers API + * directly are expected to setup layers, call wlr_output_test(), paint the + * layers that the backend rejected with the renderer, then call + * wlr_output_commit(). + */ +struct wlr_output_layer { + struct wl_list link; // wlr_output.layers + struct wlr_addon_set addons; + + void *data; +}; + +/** + * State for an output layer. + */ +struct wlr_output_layer_state { + struct wlr_output_layer *layer; + + // Buffer to display, or NULL to disable the layer + struct wlr_buffer *buffer; + // Position in output-buffer-local coordinates + int x, y; + + // Populated by the backend after wlr_output_test() and wlr_output_commit(), + // indicates whether the backend has acknowledged and will take care of + // displaying the layer + bool accepted; +}; + +/** + * Create a new output layer. + */ +struct wlr_output_layer *wlr_output_layer_create(struct wlr_output *output); + +/** + * Destroy an output layer. + */ +void wlr_output_layer_destroy(struct wlr_output_layer *layer); + +#endif |