mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-22 14:15:28 +00:00
render: Clip lines before Bresenham algorithm generates points.
Otherwise, a massive line might generate gigabytes worth of points to render, which the backend would simply throw away anyhow. Fixes #8113.
This commit is contained in:
parent
a391dd5fef
commit
4339647d90
|
@ -2810,6 +2810,18 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
|
|||
int retval;
|
||||
SDL_bool isstack;
|
||||
SDL_FPoint *points;
|
||||
SDL_Rect clip_rect;
|
||||
|
||||
/* 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.w = (int) renderer->viewport.w;
|
||||
clip_rect.h = (int) renderer->viewport.h;
|
||||
if (!SDL_IntersectRectAndLine(&clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
deltax = SDL_abs(x2 - x1);
|
||||
deltay = SDL_abs(y2 - y1);
|
||||
|
|
Loading…
Reference in a new issue