From ef79230bbefd9d414da75c5e802ef4833e49abff Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Wed, 29 Sep 2021 16:39:40 -0400 Subject: [PATCH] types/output: use request_swapchain signal to create swapchain --- types/wlr_output.c | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index 210e2d384f..6ccdb8789d 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include "render/drm_format_set.h" #include "render/swapchain.h" #include "render/wlr_renderer.h" +#include "types/wlr_output.h" #include "util/global.h" #include "util/signal.h" @@ -499,45 +499,26 @@ static bool output_create_swapchain(struct wlr_output *output, return true; } - struct wlr_allocator *allocator = backend_get_allocator(output->backend); - if (allocator == NULL) { - wlr_log(WLR_ERROR, "Failed to get backend allocator"); - return false; - } + wlr_log(WLR_DEBUG, "output '%s' requesting swapchain of size %dx%d", + output->name, width, height); - const struct wlr_drm_format_set *display_formats = NULL; - if (output->impl->get_primary_formats) { - display_formats = - output->impl->get_primary_formats(output, allocator->buffer_caps); - if (display_formats == NULL) { - wlr_log(WLR_ERROR, "Failed to get primary display formats"); - return false; - } - } - - struct wlr_drm_format *format = output_pick_format(output, display_formats); - if (format == NULL) { - wlr_log(WLR_ERROR, "Failed to pick primary buffer format for output '%s'", - output->name); - return false; - } - wlr_log(WLR_DEBUG, "Choosing primary buffer format 0x%"PRIX32" for output '%s'", - format->format, output->name); + struct wlr_output_swapchain_request request = { + .output = output, + .width = width, + .height = height, + .allow_modifiers = allow_modifiers, + .swapchain = NULL, + }; - if (!allow_modifiers && (format->len != 1 || format->modifiers[0] != DRM_FORMAT_MOD_LINEAR)) { - format->len = 0; - } + wlr_signal_emit_safe(&output->events.request_swapchain, &request); - struct wlr_swapchain *swapchain = - wlr_swapchain_create(allocator, width, height, format); - free(format); - if (swapchain == NULL) { + if (request.swapchain == NULL) { wlr_log(WLR_ERROR, "Failed to create output swapchain"); return false; } wlr_swapchain_destroy(output->swapchain); - output->swapchain = swapchain; + output->swapchain = request.swapchain; return true; }