From c11bdeeb6975e00ecf7d7be0d13b47669a50abf9 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Tue, 21 Jun 2022 13:28:14 -0400 Subject: [PATCH] wayland: Round fractional backbuffer sizes halfway away from zero Use SDL_lroundf() to round fractional backbuffer sizes halfway away from zero, as this is the rounding method recommended by the forthcoming Wayland fractional scaling protocol. --- src/video/wayland/SDL_waylandwindow.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index cfd835b76..8ca084221 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -184,8 +184,9 @@ GetBufferSize(SDL_Window *window, int *width, int *height) if (FullscreenModeEmulation(window)) { GetFullScreenDimensions(window, NULL, NULL, &buf_width, &buf_height); } else if (NeedViewport(window)) { - buf_width = (int)SDL_ceil(window->w * data->scale_factor); - buf_height = (int)SDL_ceil(window->h * data->scale_factor); + /* Round fractional backbuffer sizes halfway away from zero. */ + buf_width = (int)SDL_lroundf(window->w * data->scale_factor); + buf_height = (int)SDL_lroundf(window->h * data->scale_factor); } else { /* * Integer scaled windowed or fullscreen with no viewport @@ -1897,8 +1898,8 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) } #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ - data->drawable_width = SDL_ceilf(window->w * data->scale_factor); - data->drawable_height = SDL_ceilf(window->h * data->scale_factor); + data->drawable_width = SDL_lroundf(window->w * data->scale_factor); + data->drawable_height = SDL_lroundf(window->h * data->scale_factor); if (window->flags & SDL_WINDOW_OPENGL) { data->egl_window = WAYLAND_wl_egl_window_create(data->surface, data->drawable_width, data->drawable_height);