output: use pending resolution when allocating swapchain

This allows the swapchain to be created with the correct resolution
during a mode change.
This commit is contained in:
Simon Ser 2021-06-11 18:41:34 +02:00
parent d6f0fc251e
commit 1a5b6722a8
1 changed files with 13 additions and 4 deletions

View File

@ -477,9 +477,15 @@ static void output_state_clear_buffer(struct wlr_output_state *state) {
static struct wlr_drm_format *output_pick_format(struct wlr_output *output, static struct wlr_drm_format *output_pick_format(struct wlr_output *output,
const struct wlr_drm_format_set *display_formats); const struct wlr_drm_format_set *display_formats);
static void output_pending_resolution(struct wlr_output *output, int *width,
int *height);
static bool output_create_swapchain(struct wlr_output *output) { static bool output_create_swapchain(struct wlr_output *output) {
if (output->swapchain != NULL) { int width, height;
output_pending_resolution(output, &width, &height);
if (output->swapchain != NULL && output->swapchain->width == width &&
output->swapchain->height == height) {
return true; return true;
} }
@ -508,14 +514,17 @@ static bool output_create_swapchain(struct wlr_output *output) {
wlr_log(WLR_DEBUG, "Choosing primary buffer format 0x%"PRIX32" for output '%s'", wlr_log(WLR_DEBUG, "Choosing primary buffer format 0x%"PRIX32" for output '%s'",
format->format, output->name); format->format, output->name);
output->swapchain = wlr_swapchain_create(allocator, output->width, struct wlr_swapchain *swapchain =
output->height, format); wlr_swapchain_create(allocator, width, height, format);
free(format); free(format);
if (output->swapchain == NULL) { if (swapchain == NULL) {
wlr_log(WLR_ERROR, "Failed to create output swapchain"); wlr_log(WLR_ERROR, "Failed to create output swapchain");
return false; return false;
} }
wlr_swapchain_destroy(output->swapchain);
output->swapchain = swapchain;
return true; return true;
} }