From 4c8a2a3f8867d266d004c56b14faf272008a74a1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 5 Dec 2015 10:59:03 +0100 Subject: [PATCH] Create font_driver_bind_block --- gfx/font_driver.c | 9 +++++++++ gfx/font_driver.h | 2 ++ menu/drivers/materialui.c | 5 +---- menu/drivers/xmb.c | 5 +---- menu/drivers/zarch.c | 6 +----- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 728f9c92a3..0366b67193 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -161,6 +161,15 @@ void font_driver_render_msg(void *font_data, const char *msg, const struct font_ font_ctx->render_msg(font_data ? font_data : driver->font_osd_data, msg, params); } +void font_driver_bind_block(void *block) +{ + driver_t *driver = driver_get_ptr(); + const font_renderer_t *font_ctx = driver->font_osd_driver; + + if (font_ctx->bind_block) + font_ctx->bind_block(driver->font_osd_data, block); +} + void font_driver_free(void *data) { driver_t *driver = driver_get_ptr(); diff --git a/gfx/font_driver.h b/gfx/font_driver.h index f48ef7e3ad..820cab8574 100644 --- a/gfx/font_driver.h +++ b/gfx/font_driver.h @@ -65,6 +65,8 @@ bool font_driver_has_render_msg(void); void font_driver_render_msg(void *data, const char *msg, const struct font_params *params); +void font_driver_bind_block(void *block); + void font_driver_free(void *data); bool font_driver_init_first(void *data, const char *font_path, float font_size, diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 44ee6b47f0..a6e74654f5 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1001,16 +1001,13 @@ static void mui_free(void *data) menu_handle_t *menu = (menu_handle_t*)data; driver_t *driver = driver_get_ptr(); mui_handle_t *mui = menu ? (mui_handle_t*)menu->userdata : NULL; - const struct font_renderer *font_driver = driver ? - (const struct font_renderer*)driver->font_osd_driver : NULL; if (!mui) return; gfx_coord_array_free(&mui->list_block.carr); - if (font_driver && font_driver->bind_block) - font_driver->bind_block(driver->font_osd_data, NULL); + font_driver_bind_block(NULL); if (menu->userdata) free(menu->userdata); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index e76c8d8b7e..06cc9e22e6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2025,8 +2025,6 @@ static void xmb_free(void *data) xmb_handle_t *xmb = NULL; menu_handle_t *menu = (menu_handle_t*)data; driver_t *driver = driver_get_ptr(); - const struct font_renderer *font_driver = - (const struct font_renderer*)driver->font_osd_driver; if (menu && menu->userdata) { @@ -2053,8 +2051,7 @@ static void xmb_free(void *data) menu->userdata = NULL; } - if (font_driver->bind_block) - font_driver->bind_block(driver->font_osd_data, NULL); + font_driver_bind_block(NULL); } static void xmb_context_bg_destroy(xmb_handle_t *xmb) diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 02c1616d94..c61552d27d 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1131,8 +1131,6 @@ static void zarch_free(void *data) menu_handle_t *menu = (menu_handle_t*)data; driver_t *driver = driver_get_ptr(); zui_t *zui = (zui_t*)menu->userdata; - const struct font_renderer *font_driver = - (const struct font_renderer*)driver->font_osd_driver; if (!zui || !menu) return; @@ -1144,9 +1142,7 @@ static void zarch_free(void *data) free(menu->userdata); menu->userdata = NULL; - if (font_driver->bind_block) - font_driver->bind_block(driver->font_osd_data, NULL); - + font_driver_bind_block(NULL); } static void zarch_context_bg_destroy(zui_t *zui)