foxygit / doom Log in
commit 93e591e18a0091c038d722d6e2081af7f701bc6d
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Fri Sep 2 20:58:45 2016 +0200
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Fri Sep 2 20:58:45 2016 +0200

    video: call SDL_GetWindowPixelFormat() only once
---
 src/i_video.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index c8f058d3..14302009 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -81,6 +81,8 @@ static SDL_Rect blit_rect = {
     SCREENHEIGHT
 };

+static uint32_t pixel_format;
+
 // palette

 static SDL_Color palette[256];
@@ -607,7 +609,7 @@ static void CreateUpscaledTexture(boolean force)
     SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");

     texture_upscaled = SDL_CreateTexture(renderer,
-                                SDL_GetWindowPixelFormat(screen),
+                                pixel_format,
                                 SDL_TEXTUREACCESS_TARGET,
                                 w_upscale*SCREENWIDTH,
                                 h_upscale*SCREENHEIGHT);
@@ -1057,6 +1059,8 @@ static void SetVideoMode(void)
             SDL_GetError());
         }

+        pixel_format = SDL_GetWindowPixelFormat(screen);
+
         SDL_SetWindowMinimumSize(screen, SCREENWIDTH, EffectiveScreenHeight());

         I_InitWindowTitle();
@@ -1114,7 +1118,7 @@ static void SetVideoMode(void)
     // import the surface data into the texture.
     if (rgbabuffer == NULL)
     {
-        SDL_PixelFormatEnumToMasks(SDL_GetWindowPixelFormat(screen), &unused_bpp,
+        SDL_PixelFormatEnumToMasks(pixel_format, &unused_bpp,
                                    &rmask, &gmask, &bmask, &amask);
         rgbabuffer = SDL_CreateRGBSurface(0,
                                           SCREENWIDTH, SCREENHEIGHT, 32,
@@ -1138,7 +1142,7 @@ static void SetVideoMode(void)
     // is going to change frequently.

     texture = SDL_CreateTexture(renderer,
-                                SDL_GetWindowPixelFormat(screen),
+                                pixel_format,
                                 SDL_TEXTUREACCESS_STREAMING,
                                 SCREENWIDTH, SCREENHEIGHT);