From 065fb5acee12d0149a567258f835900dd1047a4e Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Thu, 17 Mar 2022 14:08:07 +0000 Subject: [PATCH] (Wayland) Skip splash screen if window is not ready --- gfx/drivers_context/wayland_ctx.c | 3 ++- gfx/drivers_context/wayland_vk_ctx.c | 3 ++- input/common/wayland_common.c | 10 +++++++++- input/common/wayland_common.h | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 1cbfcebcd9..35aa1b5f31 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -616,7 +616,8 @@ static void *gfx_ctx_wl_init(void *video_driver) /* Bind SHM based wl_buffer to wl_surface until the vulkan surface is ready. * This shows the window which assigns us a display (wl_output) * which is usefull for HiDPI and auto selecting a display for fullscreen. */ - draw_splash_screen(wl); + if (!draw_splash_screen(wl)) + RARCH_ERR("[Wayland/GL]: Failed to draw splash screen\n"); wl_display_roundtrip(wl->input.dpy); diff --git a/gfx/drivers_context/wayland_vk_ctx.c b/gfx/drivers_context/wayland_vk_ctx.c index 6a9e650f68..fd68f6073c 100644 --- a/gfx/drivers_context/wayland_vk_ctx.c +++ b/gfx/drivers_context/wayland_vk_ctx.c @@ -519,7 +519,8 @@ static void *gfx_ctx_wl_init(void *video_driver) /* Bind SHM based wl_buffer to wl_surface until the vulkan surface is ready. * This shows the window which assigns us a display (wl_output) * which is usefull for HiDPI and auto selecting a display for fullscreen. */ - draw_splash_screen(wl); + if (!draw_splash_screen(wl)) + RARCH_ERR("[Wayland/Vulkan]: Failed to draw splash screen\n"); wl_display_roundtrip(wl->input.dpy); diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index 2f69dcb082..4dcea829b9 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -1027,6 +1027,9 @@ shm_buffer_t *create_shm_buffer(gfx_ctx_wayland_data_t *wl, int width, stride = width * 4; size = stride * height; + if (size <= 0) + return NULL; + fd = create_shm_file(size); if (fd < 0) { RARCH_ERR("[Wayland] [SHM]: Creating a buffer file for %d B failed: %s\n", @@ -1084,7 +1087,7 @@ void shm_buffer_paint_checkerboard(shm_buffer_t *buffer, } -void draw_splash_screen(gfx_ctx_wayland_data_t *wl) +bool draw_splash_screen(gfx_ctx_wayland_data_t *wl) { shm_buffer_t *buffer; @@ -1092,6 +1095,10 @@ void draw_splash_screen(gfx_ctx_wayland_data_t *wl) wl->width * wl->buffer_scale, wl->height * wl->buffer_scale, WL_SHM_FORMAT_XRGB8888); + + if (buffer == NULL) + return false; + shm_buffer_paint_checkerboard(buffer, wl->width, wl->height, wl->buffer_scale, 16, 0xffbcbcbc, 0xff8e8e8e); @@ -1103,5 +1110,6 @@ void draw_splash_screen(gfx_ctx_wayland_data_t *wl) wl->width * wl->buffer_scale, wl->height * wl->buffer_scale); wl_surface_commit(wl->surface); + return true; } diff --git a/input/common/wayland_common.h b/input/common/wayland_common.h index 1f6159950c..ee859726f9 100644 --- a/input/common/wayland_common.h +++ b/input/common/wayland_common.h @@ -215,7 +215,7 @@ void shm_buffer_paint_checkerboard(shm_buffer_t *buffer, int width, int height, int scale, size_t chk, uint32_t bg, uint32_t fg); -void draw_splash_screen(gfx_ctx_wayland_data_t *wl); +bool draw_splash_screen(gfx_ctx_wayland_data_t *wl); extern const struct wl_keyboard_listener keyboard_listener;