Skip to content

Commit

Permalink
Removed set_pixel_format
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Vultraz committed Jul 23, 2019
1 parent c57de77 commit 12e7e3e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
35 changes: 0 additions & 35 deletions src/picture.cpp
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/picture.hpp
Expand Up @@ -174,10 +174,6 @@ namespace image {

const std::vector<std::string>& 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);
Expand Down
10 changes: 0 additions & 10 deletions src/video.cpp
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 12e7e3e

Please sign in to comment.