From 5b453d604e3065641aae62d86981fe46ed621ebf Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 20 Nov 2018 05:50:22 +1100 Subject: [PATCH] [client] remove other render modes from font ABI --- client/fonts/sdl.c | 19 ++++--------------- client/lg-font.h | 20 ++++---------------- client/renderers/opengl.c | 4 ++-- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/client/fonts/sdl.c b/client/fonts/sdl.c index e9acd6c5..c2a4fadc 100644 --- a/client/fonts/sdl.c +++ b/client/fonts/sdl.c @@ -102,21 +102,10 @@ static void lgf_sdl_destroy(LG_FontObj opaque) TTF_Quit(); } -static bool lgf_sdl_supports(LG_FontObj opaque, LG_FontMode mode) -{ - return (mode == LG_FONT_BITMAP); -} - -static LG_FontOut lgf_sdl_render(LG_FontObj opaque, LG_FontMode mode, unsigned int fg_color, const char * text) +static LG_FontBitmap * lgf_sdl_render(LG_FontObj opaque, unsigned int fg_color, const char * text) { struct Inst * this = (struct Inst *)opaque; - if (mode != LG_FONT_BITMAP) - { - DEBUG_ERROR("Unsupported render mode"); - return false; - } - SDL_Surface * surface; SDL_Color color; color.r = (fg_color & 0xff000000) >> 24; @@ -144,13 +133,14 @@ static LG_FontOut lgf_sdl_render(LG_FontObj opaque, LG_FontMode mode, unsigned i out->bpp = surface->format->BytesPerPixel; out->pixels = surface->pixels; - return (LG_FontOut*)out; + return out; } -static void lgf_sdl_release(LG_FontObj opaque, LG_FontOut font) +static void lgf_sdl_release(LG_FontObj opaque, LG_FontBitmap * font) { LG_FontBitmap * bitmap = (LG_FontBitmap *)font; SDL_FreeSurface(bitmap->reserved); + free(bitmap); } struct LG_Font LGF_SDL = @@ -158,7 +148,6 @@ struct LG_Font LGF_SDL = .name = "SDL", .create = lgf_sdl_create, .destroy = lgf_sdl_destroy, - .supports = lgf_sdl_supports, .render = lgf_sdl_render, .release = lgf_sdl_release }; \ No newline at end of file diff --git a/client/lg-font.h b/client/lg-font.h index a10ea87c..898bd471 100644 --- a/client/lg-font.h +++ b/client/lg-font.h @@ -22,16 +22,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include typedef void * LG_FontObj; -typedef void * LG_FontOut; - -typedef enum LG_FontMode -{ - LG_FONT_BITMAP, - LG_FONT_OPENGL, - LG_FONT_VULKAN -} -LG_FontMode; - typedef struct LG_FontBitmap { void * reserved; @@ -42,11 +32,10 @@ typedef struct LG_FontBitmap } LG_FontBitmap; -typedef bool (* LG_FontCreate )(LG_FontObj * opaque, const char * font_name, unsigned int size); -typedef void (* LG_FontDestroy )(LG_FontObj opaque); -typedef bool (* LG_FontSupports )(LG_FontObj opaque, LG_FontMode mode); -typedef LG_FontOut (* LG_FontRender )(LG_FontObj opaque, LG_FontMode mode, unsigned int fg_color, const char * text); -typedef void (* LG_FontRelease )(LG_FontObj opaque, LG_FontOut font); +typedef bool (* LG_FontCreate )(LG_FontObj * opaque, const char * font_name, unsigned int size); +typedef void (* LG_FontDestroy )(LG_FontObj opaque); +typedef LG_FontBitmap * (* LG_FontRender )(LG_FontObj opaque, unsigned int fg_color, const char * text); +typedef void (* LG_FontRelease )(LG_FontObj opaque, LG_FontBitmap * bitmap); typedef struct LG_Font { @@ -54,7 +43,6 @@ typedef struct LG_Font const char * name; LG_FontCreate create; LG_FontDestroy destroy; - LG_FontSupports supports; LG_FontRender render; LG_FontRelease release; } diff --git a/client/renderers/opengl.c b/client/renderers/opengl.c index aacaab91..cc56293e 100644 --- a/client/renderers/opengl.c +++ b/client/renderers/opengl.c @@ -414,7 +414,7 @@ void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * m break; } - if (!(a->text = this->font->render(this->alertFontObj, LG_FONT_BITMAP, 0xffffff00, message))) + if (!(a->text = this->font->render(this->alertFontObj, 0xffffff00, message))) { DEBUG_ERROR("Failed to render alert text: %s", TTF_GetError()); free(a); @@ -632,7 +632,7 @@ void opengl_update_fps(void * opaque, const float avgFPS, const float renderFPS) snprintf(str, sizeof(str), "UPS: %8.4f, FPS: %8.4f", avgFPS, renderFPS); LG_FontBitmap *textSurface = NULL; - if (!(textSurface = this->font->render(this->fontObj, LG_FONT_BITMAP, 0xffffff00, str))) + if (!(textSurface = this->font->render(this->fontObj, 0xffffff00, str))) DEBUG_ERROR("Failed to render text"); bitmap_to_texture(textSurface, this->textures[FPS_TEXTURE]);