diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 33cdee353..e8d323b8a 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -833,19 +833,14 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, SDL_Surface *surface = SW_ActivateRenderer(renderer); Uint32 src_format; void *src_pixels; - SDL_Rect final_rect; if (!surface) { return -1; } - if (renderer->viewport.x || renderer->viewport.y) { - final_rect.x = renderer->viewport.x + rect->x; - final_rect.y = renderer->viewport.y + rect->y; - final_rect.w = rect->w; - final_rect.h = rect->h; - rect = &final_rect; - } + /* NOTE: The rect is already adjusted according to the viewport by + * SDL_RenderReadPixels. + */ if (rect->x < 0 || rect->x+rect->w > surface->w || rect->y < 0 || rect->y+rect->h > surface->h) {