commit a9173b09d799006ab09e3def8c4b43b6b8668c1a
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Fri Sep 18 08:20:56 2015 +0200
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Fri Sep 18 08:20:56 2015 +0200
create a new texture only if the upscale factor has changed
---
src/i_video.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/i_video.c b/src/i_video.c
index 73447780..de001a53 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1016,11 +1016,7 @@ static void CreateUpscaledTexture(int w, int h)
const int w_scale = (w / SCREENWIDTH) + 1;
const int h_scale = (h / SCREENHEIGHT) + 1;
int upscale;
-
- if (texture_upscaled)
- {
- SDL_DestroyTexture(texture_upscaled);
- }
+ static int upscale_old;
// When the screen or window dimensions do not match the aspect ratio
// of the texture, the rendered area is scaled down to fit
@@ -1029,11 +1025,27 @@ static void CreateUpscaledTexture(int w, int h)
// Limit upscaling factor to 6 (1920x1200)
- if (upscale > 6)
+ if (upscale < 2)
+ {
+ upscale = 2;
+ }
+ else if (upscale > 6)
{
upscale = 6;
}
+ if (upscale == upscale_old)
+ {
+ return;
+ }
+
+ upscale_old = upscale;
+
+ if (texture_upscaled)
+ {
+ SDL_DestroyTexture(texture_upscaled);
+ }
+
// Set the scaling quality for rendering the upscaled texture to "linear",
// which looks much softer and smoother than "nearest" but does a better
// job at downscaling from the upscaled texture to screen.