avoid runtime conversion to SDL_Color for font colors

This commit is contained in:
Tim Felgentreff 2022-05-22 13:58:57 +02:00
parent e26e994a9c
commit 6fa5d86b7b
3 changed files with 6 additions and 4 deletions
src
include
tolua
video

View file

@ -127,7 +127,7 @@ public:
static CFontColor *Get(const std::string &ident);
std::string Ident;
CColor Colors[MaxFontColors];
SDL_Color *Colors;
};
/*----------------------------------------------------------------------------

View file

@ -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];
};

View file

@ -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);
}
/**