From 7b735f74b307ffbbd6b279878beb95c46c9c128b Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Fri, 14 Jul 2017 19:00:47 +1100 Subject: [PATCH] Use pixel format enums for creating surfaces instead color mask values This bumps the min SDL version to 2.0.5, but it's a lot easier to read. --- src/font/text.cpp | 4 ++-- src/sdl/utils.cpp | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/font/text.cpp b/src/font/text.cpp index 91b84cae74da..7841da4861b2 100644 --- a/src/font/text.cpp +++ b/src/font/text.cpp @@ -741,8 +741,8 @@ void pango_text::rerender(const bool force) } } - surface_.assign(SDL_CreateRGBSurfaceFrom( - &surface_buffer_[0], width, height, 32, stride, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)); + surface_.assign(SDL_CreateRGBSurfaceWithFormatFrom( + &surface_buffer_[0], width, height, 32, stride, SDL_PIXELFORMAT_ARGB8888)); // ...and add it to the cache. rendered_text_cache.emplace(hash_, texture(surface_)); diff --git a/src/sdl/utils.cpp b/src/sdl/utils.cpp index fb5e465c29fd..a7cfef111c93 100644 --- a/src/sdl/utils.cpp +++ b/src/sdl/utils.cpp @@ -41,21 +41,21 @@ bool is_neutral(const surface& surf) } static SDL_PixelFormat& get_neutral_pixel_format() - { - static bool first_time = true; - static SDL_PixelFormat format; - - if(first_time) { - first_time = false; - surface surf(SDL_CreateRGBSurface(0,1,1,32,SDL_RED_MASK,SDL_GREEN_MASK, - SDL_BLUE_MASK,SDL_ALPHA_MASK)); - format = *surf->format; - format.palette = nullptr; - } +{ + static bool first_time = true; + static SDL_PixelFormat format; - return format; + if(first_time) { + first_time = false; + surface surf(SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888)); + + format = *surf->format; + format.palette = nullptr; } + return format; +} + surface make_neutral_surface(const surface &surf) { if(surf == nullptr) {