Introduce wlr_output_layer

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.

The goal is to make use of this API in a future scene-graph API.

References: https://github.com/swaywm/wlroots/issues/1826
This commit is contained in:
Simon Ser 2020-01-09 18:37:07 +01:00
parent e13f3f8608
commit 999826a11a
7 changed files with 289 additions and 2 deletions

View file

@ -7,6 +7,7 @@
#include <wlr/util/log.h>
#include "render/swapchain.h"
#include "types/wlr_output.h"
#include "types/wlr_output_layer.h"
#include "util/global.h"
#include "util/signal.h"
@ -360,6 +361,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
wl_signal_init(&output->events.description);
wl_signal_init(&output->events.destroy);
pixman_region32_init(&output->pending.damage);
wl_list_init(&output->layers);
wl_list_init(&output->pending.layers);
const char *no_hardware_cursors = getenv("WLR_NO_HARDWARE_CURSORS");
if (no_hardware_cursors != NULL && strcmp(no_hardware_cursors, "1") == 0) {
@ -505,6 +508,42 @@ void output_pending_resolution(struct wlr_output *output, int *width,
}
}
static void output_commit_layers(struct wlr_output *output) {
if (output->pending.committed & WLR_OUTPUT_STATE_LAYERS) {
// Update the layer ordering in the current output state
struct wlr_output_layer *layer;
wl_list_for_each(layer, &output->pending.layers, pending.link) {
wl_list_remove(&layer->current.link);
wl_list_insert(output->layers.prev, &layer->current.link);
}
}
struct wlr_output_layer *layer, *tmp;
wl_list_for_each_safe(layer, tmp, &output->layers, current.link) {
if (wl_list_empty(&layer->pending.link)) {
output_layer_destroy(layer);
} else {
output_layer_state_move(&layer->current, &layer->pending);
}
}
}
static void output_rollback_layers(struct wlr_output *output) {
if (output->pending.committed & WLR_OUTPUT_STATE_LAYERS) {
// Rollback the layer ordering in the pending output state
struct wlr_output_layer *layer;
wl_list_for_each(layer, &output->layers, current.link) {
wl_list_remove(&layer->pending.link);
wl_list_insert(output->pending.layers.prev, &layer->pending.link);
}
}
struct wlr_output_layer *layer, *tmp;
wl_list_for_each_safe(layer, tmp, &output->pending.layers, pending.link) {
output_layer_state_clear(&layer->pending);
}
}
static bool output_basic_test(struct wlr_output *output) {
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
if (output->frame_pending) {
@ -628,7 +667,7 @@ bool wlr_output_commit(struct wlr_output *output) {
if (!output->impl->commit(output)) {
wlr_buffer_unlock(back_buffer);
output_state_clear(&output->pending);
wlr_output_rollback(output);
return false;
}
@ -690,6 +729,7 @@ bool wlr_output_commit(struct wlr_output *output) {
}
uint32_t committed = output->pending.committed;
output_commit_layers(output);
output_state_clear(&output->pending);
struct wlr_output_event_commit event = {
@ -704,6 +744,7 @@ bool wlr_output_commit(struct wlr_output *output) {
void wlr_output_rollback(struct wlr_output *output) {
output_clear_back_buffer(output);
output_rollback_layers(output);
output_state_clear(&output->pending);
}