From 12e7e3e5d5583ff01ce26002d8d73e5e5c9975cb Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Tue, 23 Jul 2019 11:28:07 +1100 Subject: [PATCH] Removed set_pixel_format This is rather redundant. It's only called once when the CVideo subsystem is initialized and nowhere else, and we already use the ARGB8888 format for all surfaces (which is what my testing has revealed the SDL framebuffer surface's format is). --- src/picture.cpp | 35 ----------------------------------- src/picture.hpp | 4 ---- src/video.cpp | 10 ---------- 3 files changed, 49 deletions(-) diff --git a/src/picture.cpp b/src/picture.cpp index d49bb7a25148..cfcca0ea259d 100644 --- a/src/picture.cpp +++ b/src/picture.cpp @@ -792,41 +792,6 @@ manager::~manager() flush_cache(); } -static SDL_PixelFormat last_pixel_format; - -void set_pixel_format(SDL_PixelFormat* format) -{ - assert(format != nullptr); - - SDL_PixelFormat& f = *format; - SDL_PixelFormat& l = last_pixel_format; - // if the pixel format change, we clear the cache, - // because some images are now optimized for the wrong display format - // FIXME: 8 bpp use palette, need to compare them. For now assume a change - if(format->BitsPerPixel == 8 - || f.BitsPerPixel != l.BitsPerPixel - || f.BytesPerPixel != l.BytesPerPixel - || f.Rmask != l.Rmask - || f.Gmask != l.Gmask - || f.Bmask != l.Bmask -// || f.Amask != l.Amask This field in not checked, not sure why. - || f.Rloss != l.Rloss - || f.Gloss != l.Gloss - || f.Bloss != l.Bloss -// || f.Aloss != l.Aloss This field in not checked, not sure why. - || f.Rshift != l.Rshift - || f.Gshift != l.Gshift - || f.Bshift != l.Bshift -// || f.Ashift != l.Ashift This field in not checked, not sure why. - ) - { - LOG_DP << "detected a new display format\n"; - flush_cache(); - } - - last_pixel_format = *format; -} - void set_color_adjustment(int r, int g, int b) { if(r != red_adjust || g != green_adjust || b != blue_adjust) { diff --git a/src/picture.hpp b/src/picture.hpp index 6ca3b4ae2e2c..491af4faa817 100644 --- a/src/picture.hpp +++ b/src/picture.hpp @@ -174,10 +174,6 @@ namespace image { const std::vector& get_team_colors(); - ///sets the pixel format used by the images. Is called every time the - ///video mode changes. Invalidates all images. - void set_pixel_format(SDL_PixelFormat* format); - ///sets the amount scaled images should be scaled. Invalidates all ///scaled images. void set_zoom(unsigned int zoom); diff --git a/src/video.cpp b/src/video.cpp index d184e88e21a5..d5c4b957ad97 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -179,8 +179,6 @@ void CVideo::make_fake() #else frameBuffer = SDL_CreateRGBSurface(0, 16, 16, 24, 0xFF0000, 0xFF00, 0xFF, 0); #endif - - image::set_pixel_format(frameBuffer->format); } void CVideo::make_test_fake(const unsigned width, const unsigned height) @@ -191,8 +189,6 @@ void CVideo::make_test_fake(const unsigned width, const unsigned height) frameBuffer = SDL_CreateRGBSurface(0, width, height, 32, 0xFF0000, 0xFF00, 0xFF, 0); #endif - image::set_pixel_format(frameBuffer->format); - fake_interactive = true; refresh_rate_ = 1; } @@ -251,9 +247,6 @@ void CVideo::init_window() event_handler_.join_global(); update_framebuffer(); - if(frameBuffer) { - image::set_pixel_format(frameBuffer->format); - } } void CVideo::set_window_mode(const MODE_EVENT mode, const point& size) @@ -286,9 +279,6 @@ void CVideo::set_window_mode(const MODE_EVENT mode, const point& size) } update_framebuffer(); - if(frameBuffer) { - image::set_pixel_format(frameBuffer->format); - } } SDL_Rect CVideo::screen_area(bool as_pixels) const