From d5ba5bb05f60f922306265539ae264a9bad6c9a3 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 4 Oct 2023 21:17:13 +0200 Subject: [PATCH 1/7] blit_slow: don't read destination pixel when you're going to discard it anyways (cherry picked from commit 4cd0c13823551cce279c9ff3d284c41c28deb3d8) (cherry picked from commit 2d5c05a69cca65e0eb01b4bae23737fe970f7bb1) --- src/video/SDL_blit_slow.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c index 9ea5c384d18b5d..fb8516bd897f10 100644 --- a/src/video/SDL_blit_slow.c +++ b/src/video/SDL_blit_slow.c @@ -106,15 +106,20 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (flags & SDL_COPY_MODULATE_COLOR) { From 36eb4845b52a8c0c63c2adb8fa3a2f7f8ba28dd1 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 5 Oct 2023 13:40:09 +0200 Subject: [PATCH 2/7] triangle: don't read destination pixel when you're going to discard it anyways --- src/render/software/SDL_triangle.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index fc429db6e20731..a4c04b2ddc2a4f 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -789,15 +789,20 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (!is_uniform) { From 1f7ec57d3b963931a3f2febf6061d22614f1660c Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Sat, 18 Mar 2023 12:03:08 -0400 Subject: [PATCH 3/7] wayland: Unref the libdecor window when hiding Hiding the decorations while not unreferencing the frame was a workaround for an internal libdecor use-after-free bug that was fixed some time ago. Revert to unreferencing the window when hiding to ensure that it is properly destroyed. Reverts dd2e318 --- src/video/wayland/SDL_waylandwindow.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 303f5982b7d965..ff323083e4b1e7 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1322,21 +1322,15 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) /* Create the shell surface and map the toplevel/popup */ #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame) { - /* If the frame already exists, just set the visibility. */ - libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true); - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, + data->surface, + &libdecor_frame_interface, + data); + if (data->shell_surface.libdecor.frame == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); } else { - data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, - data->surface, - &libdecor_frame_interface, - data); - if (data->shell_surface.libdecor.frame == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); - } else { - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); - libdecor_frame_map(data->shell_surface.libdecor.frame); - } + libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + libdecor_frame_map(data->shell_surface.libdecor.frame); } } else #endif @@ -1540,8 +1534,8 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (wind->shell_surface.libdecor.frame) { - libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false); - libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname); + libdecor_frame_unref(wind->shell_surface.libdecor.frame); + wind->shell_surface.libdecor.frame = NULL; } } else #endif From 6fc17b0e2b421c6f8b996b28f76447ea0956c08e Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 10 Oct 2023 10:40:00 +0300 Subject: [PATCH 4/7] artsaudio: revert bad arts_init return code check from commit ce5da5d. --- src/audio/arts/SDL_artsaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index ea4f3119b53ac0..f3aa94b1504e34 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -300,12 +300,12 @@ static void ARTS_Deinitialize(void) } -static SDL_bool ARTS_Init(SDL_AudioDriverImpl * impl) +static SDL_bool ARTS_Init(SDL_AudioDriverImpl *impl) { if (LoadARTSLibrary() < 0) { return SDL_FALSE; } else { - if (SDL_NAME(arts_init) () != NULL) { + if (SDL_NAME(arts_init) () != 0) { UnloadARTSLibrary(); SDL_SetError("ARTS: arts_init failed (no audio server?)"); return SDL_FALSE; From 2abefb1c16e32cff1e2814a7569455c80a198862 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 11 Oct 2023 00:22:30 +0200 Subject: [PATCH 5/7] ci: stop FreeBSD job after 30 minutes (cherry picked from commit aee4862958d3365d3995d017d4d3b4642edd6358) --- .github/workflows/vmactions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/vmactions.yml b/.github/workflows/vmactions.yml index 4485f5c59d96f7..50eb5e8f405df4 100644 --- a/.github/workflows/vmactions.yml +++ b/.github/workflows/vmactions.yml @@ -6,6 +6,7 @@ jobs: freebsd: runs-on: macos-12 name: FreeBSD + timeout-minutes: 30 steps: - uses: actions/checkout@v3 - name: Build From 5be746acbcdb8fa8a3265dc78f0c2d1a7089857a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 11 Oct 2023 00:50:53 -0400 Subject: [PATCH 6/7] x11: Properly check for XInput2 support before using it. This specifically fixes a crash in X11_WarpMouseInternal if XInput2 was missing at runtime, but also cleans up a few other existing checks. Fixes #8378. (cherry picked from commit 82f54af6177f3d50be1db42a528027ada6ea0a20) (cherry picked from commit 2849ca404e040245e90fdf7b81e3878aa31204b5) --- src/video/x11/SDL_x11mouse.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 978a3058479d9c..7c3d2021679a5c 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -330,13 +330,16 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) Display *display = videodata->display; #if SDL_VIDEO_DRIVER_X11_XINPUT2 int deviceid = 0; - /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: - * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea - */ - if (ScreenCount(display) == 1) { - X11_XIGetClientPointer(display, None, &deviceid); + if (X11_Xinput2IsInitialized()) { + /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: + * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea + */ + if (ScreenCount(display) == 1) { + X11_XIGetClientPointer(display, None, &deviceid); + } } if (deviceid != 0) { + SDL_assert(SDL_X11_HAVE_XINPUT2); X11_XIWarpPointer(display, deviceid, None, xwindow, 0.0, 0.0, 0, 0, (double)x, (double)y); } else #endif @@ -369,14 +372,7 @@ static int X11_WarpMouseGlobal(int x, int y) static int X11_SetRelativeMouseMode(SDL_bool enabled) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 - if (X11_Xinput2IsInitialized()) { - return 0; - } -#else - SDL_Unsupported(); -#endif - return -1; + return X11_Xinput2IsInitialized() ? 0 : SDL_Unsupported(); } static int X11_CaptureMouse(SDL_Window *window) @@ -414,12 +410,9 @@ static Uint32 X11_GetGlobalMouseState(int *x, int *y) /* !!! FIXME: should we XSync() here first? */ -#if !SDL_VIDEO_DRIVER_X11_XINPUT2 - videodata->global_mouse_changed = SDL_TRUE; -#else - if (!SDL_X11_HAVE_XINPUT2) + if (!X11_Xinput2IsInitialized()) { videodata->global_mouse_changed = SDL_TRUE; -#endif + } /* check if we have this cached since XInput last saw the mouse move. */ /* !!! FIXME: can we just calculate this from XInput's events? */ From a85cf62c1239081403bb6944b7c07b5aa560e005 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 21 Mar 2023 12:24:45 +0100 Subject: [PATCH 7/7] Fix sdltest_randomAsciiStringWithMaximumLength() where it requests a string a size 0 seen with: ./testautomation --seed MILAFAP2AKVP3V4G --filter sdltest_randomAsciiStringWithMaximumLength --- src/test/SDL_test_fuzzer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index b59cbb32dca1f1..9e2e757e45b7f4 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -471,7 +471,9 @@ char *SDLTest_RandomAsciiStringWithMaximumLength(int maxLength) } size = (SDLTest_RandomUint32() % (maxLength + 1)); - + if (size == 0) { + size = 1; + } return SDLTest_RandomAsciiStringOfSize(size); }