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
This commit is contained in:
Alberto Mardegan 2024-01-11 22:15:17 +03:00 committed by Sam Lantinga
parent 01fa4dd9d1
commit 66209135df

View File

@ -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)) {