From fe82a8a607415d804c5d1c0cbe5b4db6bdf06748 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 15 Oct 2022 05:04:19 +0200 Subject: [PATCH] #178 fix blt/bltfast clipping --- src/ddsurface.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ddsurface.c b/src/ddsurface.c index 591ff7e..8c5540e 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -115,12 +115,18 @@ HRESULT dds_Blt( } */ + if (dst_rect.right < 0) + dst_rect.right = 0; + if (dst_rect.left < 0) { src_rect.left += (LONG)(abs(dst_rect.left) * scale_w); dst_rect.left = 0; } + if (dst_rect.bottom < 0) + dst_rect.bottom = 0; + if (dst_rect.top < 0) { src_rect.top += (LONG)(abs(dst_rect.top) * scale_h); @@ -147,9 +153,15 @@ HRESULT dds_Blt( if (src_surface) { + if (src_rect.right < 0) + src_rect.right = 0; + if (src_rect.left < 0) src_rect.left = 0; + if (src_rect.bottom < 0) + src_rect.bottom = 0; + if (src_rect.top < 0) src_rect.top = 0; @@ -439,9 +451,15 @@ HRESULT dds_BltFast( if (src_surface) { + if (src_rect.right < 0) + src_rect.right = 0; + if (src_rect.left < 0) src_rect.left = 0; + if (src_rect.bottom < 0) + src_rect.bottom = 0; + if (src_rect.top < 0) src_rect.top = 0; @@ -463,9 +481,15 @@ HRESULT dds_BltFast( RECT dst_rect = { dst_x, dst_y, (src_rect.right - src_rect.left) + dst_x, (src_rect.bottom - src_rect.top) + dst_y }; + if (dst_rect.right < 0) + dst_rect.right = 0; + if (dst_rect.left < 0) dst_rect.left = 0; + if (dst_rect.bottom < 0) + dst_rect.bottom = 0; + if (dst_rect.top < 0) dst_rect.top = 0;