mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
SDL_RenderCopy: scale before doing intersection
this prevents drawing 1 pixel outside the screen, in letterbox mode
This commit is contained in:
parent
86b81abea6
commit
9efdafd43d
@ -2999,24 +2999,25 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
SDL_RenderGetViewport(renderer, &r);
|
||||
real_dstrect.x = 0.0f;
|
||||
real_dstrect.y = 0.0f;
|
||||
real_dstrect.w = (float) r.w;
|
||||
real_dstrect.h = (float) r.h;
|
||||
real_dstrect.w = (float) r.w * renderer->scale.x;
|
||||
real_dstrect.h = (float) r.h * renderer->scale.y;
|
||||
if (dstrect) {
|
||||
if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
|
||||
SDL_FRect dstrect_scaled;
|
||||
dstrect_scaled.x = dstrect->x * renderer->scale.x;
|
||||
dstrect_scaled.y = dstrect->y * renderer->scale.y;
|
||||
dstrect_scaled.w = dstrect->w * renderer->scale.x;
|
||||
dstrect_scaled.h = dstrect->h * renderer->scale.y;
|
||||
|
||||
if (!SDL_HasIntersectionF(&dstrect_scaled, &real_dstrect)) {
|
||||
return 0;
|
||||
}
|
||||
real_dstrect = *dstrect;
|
||||
real_dstrect = dstrect_scaled;
|
||||
}
|
||||
|
||||
if (texture->native) {
|
||||
texture = texture->native;
|
||||
}
|
||||
|
||||
real_dstrect.x *= renderer->scale.x;
|
||||
real_dstrect.y *= renderer->scale.y;
|
||||
real_dstrect.w *= renderer->scale.x;
|
||||
real_dstrect.h *= renderer->scale.y;
|
||||
|
||||
texture->last_command_generation = renderer->render_command_generation;
|
||||
|
||||
retval = QueueCmdCopy(renderer, texture, &real_srcrect, &real_dstrect);
|
||||
|
Loading…
Reference in New Issue
Block a user