SDL: render: Fix line clipping with translated viewports

From 66209135df10742354afd4953853cd5001717b7e Mon Sep 17 00:00:00 2001
From: Alberto Mardegan <[EMAIL REDACTED]>
Date: Thu, 11 Jan 2024 22:15:17 +0300
Subject: [PATCH] render: Fix line clipping with translated viewports

The previous code was working incorrectly on viewports not having the
top left corner on the origin: even in those cases we only need to look
at the width and height of the viewport, because the drawing coordinates
are translated.

Fixes #8828
---
 src/render/SDL_render.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index ee96b5b98602..4035afa24a73 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2815,8 +2815,8 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
     /* the backend might clip this further to the clipping rect, but we
        just want a basic safety against generating millions of points for
        massive lines. */
-    clip_rect.x = (int) renderer->viewport.x;
-    clip_rect.y = (int) renderer->viewport.y;
+    clip_rect.x = 0;
+    clip_rect.y = 0;
     clip_rect.w = (int) renderer->viewport.w;
     clip_rect.h = (int) renderer->viewport.h;
     if (!SDL_IntersectRectAndLine(&clip_rect, &x1, &y1, &x2, &y2)) {