backend/x11: check buffer format in output_test()

This commit is contained in:
Kirill Primak 2023-11-26 23:05:44 +03:00
parent 4fbe648faf
commit 4102b722d9

View file

@ -113,6 +113,9 @@ static void output_destroy(struct wlr_output *wlr_output) {
static bool output_test(struct wlr_output *wlr_output, static bool output_test(struct wlr_output *wlr_output,
const struct wlr_output_state *state) { 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; uint32_t unsupported = state->committed & ~SUPPORTED_OUTPUT_STATE;
if (unsupported != 0) { if (unsupported != 0) {
wlr_log(WLR_DEBUG, "Unsupported output state fields: 0x%"PRIx32, 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) { if (state->committed & WLR_OUTPUT_STATE_MODE) {
assert(state->mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM); assert(state->mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM);