From 95c232d31a2c4ed8cf8c3ee43ec2405c6d5bab1b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Jun 2020 12:40:11 +0200 Subject: [PATCH] - fixed: The scissor rectangle must be clipped to the upper left edge of the screen. Negative coordinates are treated as "disable scissor", so if some transformation results in something off-screen it needs to be handled before passing it to the backend. --- src/common/rendering/hwrenderer/hw_draw2d.cpp | 3 +++ src/common/textures/texturemanager.h | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/rendering/hwrenderer/hw_draw2d.cpp b/src/common/rendering/hwrenderer/hw_draw2d.cpp index fc0b850a9..1d5c47773 100644 --- a/src/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/src/common/rendering/hwrenderer/hw_draw2d.cpp @@ -150,6 +150,9 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) sciY = screen->ScreenToWindowY(cmd.mScissor[3]); sciW = screen->ScreenToWindowX(cmd.mScissor[2]) - sciX; sciH = screen->ScreenToWindowY(cmd.mScissor[1]) - sciY; + // If coordinates turn out negative, clip to sceen here to avoid undefined behavior. + if (sciX < 0) sciW += sciX, sciX = 0; + if (sciY < 0) sciH += sciY, sciY = 0; } else { diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 2aa53da24..90ad35209 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -11,7 +11,6 @@ class FxAddSub; struct BuildInfo; class FMultipatchTextureBuilder; class FScanner; -int PalCheck(int tex); // Texture manager class FTextureManager