From 4102b722d9812dbdc6bc0a8cb816e429d4533424 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Sun, 26 Nov 2023 23:05:44 +0300 Subject: backend/x11: check buffer format in output_test() --- backend/x11/output.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'backend') diff --git a/backend/x11/output.c b/backend/x11/output.c index 0940c9b7..585e037a 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -113,6 +113,9 @@ static void output_destroy(struct wlr_output *wlr_output) { static bool output_test(struct wlr_output *wlr_output, const struct wlr_output_state *state) { + struct wlr_x11_output *output = get_x11_output_from_output(wlr_output); + struct wlr_x11_backend *x11 = output->x11; + uint32_t unsupported = state->committed & ~SUPPORTED_OUTPUT_STATE; if (unsupported != 0) { wlr_log(WLR_DEBUG, "Unsupported output state fields: 0x%"PRIx32, @@ -132,6 +135,22 @@ static bool output_test(struct wlr_output *wlr_output, } } + if (state->committed & WLR_OUTPUT_STATE_BUFFER) { + struct wlr_buffer *buffer = state->buffer; + struct wlr_dmabuf_attributes dmabuf_attrs; + struct wlr_shm_attributes shm_attrs; + uint32_t format = DRM_FORMAT_INVALID; + if (wlr_buffer_get_dmabuf(buffer, &dmabuf_attrs)) { + format = dmabuf_attrs.format; + } else if (wlr_buffer_get_shm(buffer, &shm_attrs)) { + format = shm_attrs.format; + } + if (format != x11->x11_format->drm) { + wlr_log(WLR_DEBUG, "Unsupported buffer format"); + return false; + } + } + if (state->committed & WLR_OUTPUT_STATE_MODE) { assert(state->mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM); -- cgit v1.2.3