From d872484e4ee04c465d939c51a3c9d4416cd485e5 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 2 Dec 2023 17:52:34 +0100 Subject: [PATCH] Apply guichan fix 79e81ca83f124b961eedfc7ecd5fd5618c5d97df (Jan 2nd 2008). * A fix has been applied to correctly clamp a pushed clip area to the top clip area. --- TODO | 2 +- src/graphics.cpp | 16 +++++++++------- src/sdl/sdl2graphics.cpp | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index e393ac8..f0346e3 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* Continue rebasing from b62d153a5dd699add2109671d4569578dd4f2671 +* Continue rebasing from f385b61e8f328c325d72d84280670771672a6509 * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/src/graphics.cpp b/src/graphics.cpp index 7e00dc2..bdb5a32 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -96,22 +96,24 @@ namespace gcn // Clamp the pushed clip rectangle. if (carea.x < top.x) { - carea.x = top.x; + carea.width += carea.x - top.x; + carea.x = top.x; } - + if (carea.y < top.y) { - carea.y = top.y; + carea.height += carea.y - top.y; + carea.y = top.y; } - + if (carea.width > top.width) { - carea.width = top.width; + carea.width = top.width; } - + if (carea.height > top.height) { - carea.height = top.height; + carea.height = top.height; } bool result = carea.intersect(top); diff --git a/src/sdl/sdl2graphics.cpp b/src/sdl/sdl2graphics.cpp index ce44789..59d38cd 100644 --- a/src/sdl/sdl2graphics.cpp +++ b/src/sdl/sdl2graphics.cpp @@ -126,8 +126,10 @@ namespace gcn rect.y = carea.y; rect.w = carea.width; rect.h = carea.height; - - SDL_RenderSetClipRect(mRenderTarget, &rect); + if (result) + { + SDL_RenderSetClipRect(mRenderTarget, &rect); + } return result; }