mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
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
This commit is contained in:
parent
0335ae9566
commit
2f29b0c438
6 changed files with 124 additions and 1 deletions
|
|
@ -56,6 +56,7 @@ wlr_files += files(
|
|||
'wlr_linux_dmabuf_v1.c',
|
||||
'wlr_matrix.c',
|
||||
'wlr_output_damage.c',
|
||||
'wlr_output_layer.c',
|
||||
'wlr_output_layout.c',
|
||||
'wlr_output_management_v1.c',
|
||||
'wlr_output_power_management_v1.c',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output_layer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "render/allocator/allocator.h"
|
||||
#include "render/swapchain.h"
|
||||
|
|
@ -356,6 +357,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|||
output->scale = 1;
|
||||
output->commit_seq = 0;
|
||||
wl_list_init(&output->cursors);
|
||||
wl_list_init(&output->layers);
|
||||
wl_list_init(&output->resources);
|
||||
wl_signal_init(&output->events.frame);
|
||||
wl_signal_init(&output->events.damage);
|
||||
|
|
@ -399,6 +401,11 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
wlr_output_cursor_destroy(cursor);
|
||||
}
|
||||
|
||||
struct wlr_output_layer *layer, *tmp_layer;
|
||||
wl_list_for_each_safe(layer, tmp_layer, &output->layers, link) {
|
||||
wlr_output_layer_destroy(layer);
|
||||
}
|
||||
|
||||
wlr_swapchain_destroy(output->cursor_swapchain);
|
||||
wlr_buffer_unlock(output->cursor_front_buffer);
|
||||
|
||||
|
|
@ -665,6 +672,12 @@ static bool output_basic_test(struct wlr_output *output,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (state->committed & WLR_OUTPUT_STATE_LAYERS) {
|
||||
for (size_t i = 0; i < state->layers_len; i++) {
|
||||
state->layers[i].accepted = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -823,6 +836,15 @@ bool wlr_output_commit_state(struct wlr_output *output,
|
|||
output->needs_frame = false;
|
||||
}
|
||||
|
||||
if (pending.committed & WLR_OUTPUT_STATE_LAYERS) {
|
||||
// Commit layer ordering
|
||||
for (size_t i = 0; i < pending.layers_len; i++) {
|
||||
struct wlr_output_layer *layer = pending.layers[i].layer;
|
||||
wl_list_remove(&layer->link);
|
||||
wl_list_insert(output->layers.prev, &layer->link);
|
||||
}
|
||||
}
|
||||
|
||||
if ((pending.committed & WLR_OUTPUT_STATE_BUFFER) &&
|
||||
output->swapchain != NULL) {
|
||||
wlr_swapchain_set_buffer_submitted(output->swapchain, pending.buffer);
|
||||
|
|
|
|||
24
types/wlr_output_layer.c
Normal file
24
types/wlr_output_layer.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdlib.h>
|
||||
#include <wlr/types/wlr_output_layer.h>
|
||||
|
||||
struct wlr_output_layer *wlr_output_layer_create(struct wlr_output *output) {
|
||||
struct wlr_output_layer *layer = calloc(1, sizeof(*layer));
|
||||
if (layer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wl_list_insert(&output->layers, &layer->link);
|
||||
wlr_addon_set_init(&layer->addons);
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
void wlr_output_layer_destroy(struct wlr_output_layer *layer) {
|
||||
if (layer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_addon_set_finish(&layer->addons);
|
||||
wl_list_remove(&layer->link);
|
||||
free(layer);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue