Fixed bug 5424 - Renderer doesn't use entirely the viewport when scaling is used Viewport/Clip dimensions are calculated usingg SDL_ceil whereas all renders use SDL_floor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index e80cf6c..62684c1 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2007,9 +2007,9 @@ UpdateLogicalSize(SDL_Renderer *renderer)
} else {
scale = (float)(h / renderer->logical_h);
}
- viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
+ viewport.w = (int)SDL_floor(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
- viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
+ viewport.h = (int)SDL_floor(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
@@ -2026,7 +2026,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
scale = (float)h / renderer->logical_h;
viewport.y = 0;
viewport.h = h;
- viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
+ viewport.w = (int)SDL_floor(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
SDL_RenderSetViewport(renderer, &viewport);
} else {
@@ -2034,7 +2034,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
scale = (float)w / renderer->logical_w;
viewport.x = 0;
viewport.w = w;
- viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
+ viewport.h = (int)SDL_floor(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
}
@@ -2047,7 +2047,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
scale = (float)w / renderer->logical_w;
viewport.x = 0;
viewport.w = w;
- viewport.h = (int)SDL_ceil(renderer->logical_h * scale);
+ viewport.h = (int)SDL_floor(renderer->logical_h * scale);
viewport.y = (h - viewport.h) / 2;
SDL_RenderSetViewport(renderer, &viewport);
} else {
@@ -2055,7 +2055,7 @@ UpdateLogicalSize(SDL_Renderer *renderer)
scale = (float)h / renderer->logical_h;
viewport.y = 0;
viewport.h = h;
- viewport.w = (int)SDL_ceil(renderer->logical_w * scale);
+ viewport.w = (int)SDL_floor(renderer->logical_w * scale);
viewport.x = (w - viewport.w) / 2;
SDL_RenderSetViewport(renderer, &viewport);
}
@@ -2127,8 +2127,8 @@ SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect)
if (rect) {
renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
- renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x);
- renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y);
+ renderer->viewport.w = (int)SDL_floor(rect->w * renderer->scale.x);
+ renderer->viewport.h = (int)SDL_floor(rect->h * renderer->scale.y);
} else {
renderer->viewport.x = 0;
renderer->viewport.y = 0;
@@ -2163,8 +2163,8 @@ SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
renderer->clipping_enabled = SDL_TRUE;
renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x);
renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y);
- renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x);
- renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y);
+ renderer->clip_rect.w = (int)SDL_floor(rect->w * renderer->scale.x);
+ renderer->clip_rect.h = (int)SDL_floor(rect->h * renderer->scale.y);
} else {
renderer->clipping_enabled = SDL_FALSE;
SDL_zero(renderer->clip_rect);