Consolidate duplicate screen init functions

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3770 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2012-02-13 01:10:40 +00:00
parent dfeaf56b02
commit c7c8916c2e
4 changed files with 27 additions and 48 deletions
-24
View File
@@ -69,30 +69,6 @@ static TFB_GRAPHICS_BACKEND opengl_unscaled_backend = {
TFB_GL_ColorLayer };
static SDL_Surface *
Create_Screen (SDL_Surface *templat, int w, int h)
{
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
templat->format->BitsPerPixel,
templat->format->Rmask, templat->format->Gmask,
templat->format->Bmask, 0);
if (newsurf == 0) {
log_add (log_Error, "Couldn't create screen buffers: %s",
SDL_GetError());
}
return newsurf;
}
static int
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
{
if (*screen)
SDL_FreeSurface (*screen);
*screen = Create_Screen (templat, w, h);
return *screen == 0 ? -1 : 0;
}
static int
AttemptColorDepth (int flags, int width, int height, int bpp)
{
-24
View File
@@ -47,30 +47,6 @@ static TFB_GRAPHICS_BACKEND pure_unscaled_backend = {
TFB_Pure_ScreenLayer,
TFB_Pure_ColorLayer };
static SDL_Surface *
Create_Screen (SDL_Surface *templat, int w, int h)
{
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
templat->format->BitsPerPixel,
templat->format->Rmask, templat->format->Gmask,
templat->format->Bmask, 0);
if (newsurf == 0) {
log_add (log_Error, "Couldn't create screen buffers: %s",
SDL_GetError());
}
return newsurf;
}
static int
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
{
if (*screen)
SDL_FreeSurface (*screen);
*screen = Create_Screen (templat, w, h);
return *screen == 0 ? -1 : 0;
}
// We cannot rely on SDL_DisplayFormatAlpha() anymore. It can return
// formats that we do not expect (SDL v1.2.14 on Mac OSX). Mac likes
// ARGB surfaces, but SDL_DisplayFormatAlpha thinks that only RGBA are fast.
+24
View File
@@ -352,3 +352,27 @@ TFB_SetGamma (float gamma)
{
return (SDL_SetGamma (gamma, gamma, gamma) == 0);
}
SDL_Surface *
Create_Screen (SDL_Surface *templat, int w, int h)
{
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
templat->format->BitsPerPixel,
templat->format->Rmask, templat->format->Gmask,
templat->format->Bmask, 0);
if (newsurf == 0) {
log_add (log_Error, "Couldn't create screen buffers: %s",
SDL_GetError());
}
return newsurf;
}
int
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
{
if (*screen)
SDL_FreeSurface (*screen);
*screen = Create_Screen (templat, w, h);
return *screen == 0 ? -1 : 0;
}
+3
View File
@@ -48,4 +48,7 @@ extern SDL_Surface *format_conv_surf;
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
SDL_Surface* Create_Screen (SDL_Surface *templat, int w, int h);
int ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h);
#endif