Commit d710e0be2743a5241766cd8368e5b66dbe190a93

Simon McVittie 2023-09-09T14:36:21

render: Enable clipping for zero-sized rectangles Battle for Wesnoth apparently relies on being able to disable rendering of UI elements by setting the clip rectangle to be empty. Resolves: https://github.com/libsdl-org/SDL/issues/6896 Fixes: 00f05dcf "render: only enable clipping when the rectangle is valid" Signed-off-by: Simon McVittie <smcv@collabora.com> (cherry picked from commit 8ad043fc38f09e5a88aca266ae6b70f572d66a1f)

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 21d6324..b650c6a 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2481,7 +2481,7 @@ int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect)
     int retval;
     CHECK_RENDERER_MAGIC(renderer, -1)
 
-    if (rect && rect->w > 0 && rect->h > 0) {
+    if (rect && rect->w >= 0 && rect->h >= 0) {
         renderer->clipping_enabled = SDL_TRUE;
         renderer->clip_rect.x = (double)rect->x * renderer->scale.x;
         renderer->clip_rect.y = (double)rect->y * renderer->scale.y;