avoid runtime conversion to SDL_Color for font colors
This commit is contained in:
parent
e26e994a9c
commit
6fa5d86b7b
3 changed files with 6 additions and 4 deletions
|
@ -127,7 +127,7 @@ public:
|
|||
static CFontColor *Get(const std::string &ident);
|
||||
|
||||
std::string Ident;
|
||||
CColor Colors[MaxFontColors];
|
||||
SDL_Color *Colors;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -15,6 +15,6 @@ class CFontColor
|
|||
static CFontColor *New(const std::string ident);
|
||||
static CFontColor *Get(const std::string ident);
|
||||
|
||||
CColor Colors[MaxFontColors];
|
||||
SDL_Color Colors[MaxFontColors];
|
||||
};
|
||||
|
||||
|
|
|
@ -139,8 +139,7 @@ static void VideoDrawChar(const CGraphic &g,
|
|||
{
|
||||
SDL_Rect srect = {Sint16(gx), Sint16(gy), Uint16(w), Uint16(h)};
|
||||
SDL_Rect drect = {Sint16(x), Sint16(y), 0, 0};
|
||||
std::vector<SDL_Color> sdlColors(fc.Colors, fc.Colors + MaxFontColors);
|
||||
SDL_SetPaletteColors(g.Surface->format->palette, &sdlColors[0], 0, MaxFontColors);
|
||||
SDL_SetPaletteColors(g.Surface->format->palette, fc.Colors, 0, MaxFontColors);
|
||||
SDL_BlitSurface(g.Surface, &srect, TheScreen, &drect);
|
||||
}
|
||||
|
||||
|
@ -1006,10 +1005,13 @@ void ReloadFonts()
|
|||
CFontColor::CFontColor(const std::string &ident)
|
||||
{
|
||||
Ident = ident;
|
||||
Colors = (SDL_Color*)calloc(sizeof(SDL_Color), MaxFontColors);
|
||||
Assert(Colors);
|
||||
}
|
||||
|
||||
CFontColor::~CFontColor()
|
||||
{
|
||||
free(Colors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue