diff --git a/gfx/common/d3d9_common.c b/gfx/common/d3d9_common.c index 5aa9f4af5b..cada59594a 100644 --- a/gfx/common/d3d9_common.c +++ b/gfx/common/d3d9_common.c @@ -1078,17 +1078,14 @@ void d3d9_apply_state_changes(void *data) void d3d9_set_osd_msg(void *data, const char *msg, - const void *params, void *font) + const struct font_params *params, void *font) { d3d9_video_t *d3d = (d3d9_video_t*)data; LPDIRECT3DDEVICE9 dev = d3d->dev; - const struct font_params *d3d_font_params = (const - struct font_params*)params; - d3d9_set_font_rect(d3d, d3d_font_params); + d3d9_set_font_rect(d3d, params); IDirect3DDevice9_BeginScene(dev); - font_driver_render_msg(d3d, - msg, d3d_font_params, font); + font_driver_render_msg(d3d, msg, params, font); IDirect3DDevice9_EndScene(dev); } diff --git a/gfx/common/d3d9_common.h b/gfx/common/d3d9_common.h index f534b06be8..7b60cc40d9 100644 --- a/gfx/common/d3d9_common.h +++ b/gfx/common/d3d9_common.h @@ -262,7 +262,7 @@ uintptr_t d3d9_load_texture(void *video_data, void *data, void d3d9_set_osd_msg(void *data, const char *msg, - const void *params, void *font); + const struct font_params *params, void *font); void d3d9_unload_texture(void *data, bool threaded, uintptr_t id); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index d5c05d1052..90b65adde2 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -2357,9 +2357,8 @@ void ctr_overlay_interface(void *data, const video_overlay_interface_t **iface) } #endif -static void ctr_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) +static void ctr_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { ctr_video_t* ctr = (ctr_video_t*)data; diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 540db928af..49fe7fe758 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -1762,16 +1762,15 @@ static void d3d10_gfx_apply_state_changes(void* data) } static void d3d10_gfx_set_osd_msg( - void* data, - const char* msg, const void* params, void* font) + void* data, const char *msg, + const struct font_params *params, void* font) { d3d10_video_t* d3d10 = (d3d10_video_t*)data; if (d3d10) { if (d3d10->flags & D3D10_ST_FLAG_SPRITES_ENABLE) - font_driver_render_msg(d3d10, msg, - (const struct font_params*)params, font); + font_driver_render_msg(d3d10, msg, params, font); } } diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 086bffccab..69249b3f54 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -2600,17 +2600,13 @@ static void d3d11_gfx_apply_state_changes(void* data) } static void d3d11_gfx_set_osd_msg( - void* data, - const char* msg, - const void* params, - void* font) + void* data, const char *msg, + const struct font_params *params, void *font) { d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (d3d11 && (d3d11->flags & D3D11_ST_FLAG_SPRITES_ENABLE)) - font_driver_render_msg(d3d11, - msg, - (const struct font_params*)params, font); + font_driver_render_msg(d3d11, msg, params, font); } static uintptr_t d3d11_gfx_load_texture( diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 5944ec23f8..3c7ffc1f7f 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -3030,17 +3030,13 @@ static void d3d12_gfx_apply_state_changes(void* data) } static void d3d12_gfx_set_osd_msg( - void* data, - const char* msg, - const void* params, + void* data, const char *msg, + const struct font_params *params, void* font) { d3d12_video_t* d3d12 = (d3d12_video_t*)data; - if (d3d12 && (d3d12->flags & D3D12_ST_FLAG_SPRITES_ENABLE)) - font_driver_render_msg(d3d12, - msg, - (const struct font_params*)params, font); + font_driver_render_msg(d3d12, msg, params, font); } static uintptr_t d3d12_gfx_load_texture( diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 05e933280d..4d738b6464 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1076,9 +1076,8 @@ static void d3d8_apply_state_changes(void *data) d3d->should_resize = true; } -static void d3d8_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) +static void d3d8_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { d3d8_video_t *d3d = (d3d8_video_t*)data; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 1ee401033f..c4652dc5ea 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1462,18 +1462,8 @@ static void exynos_set_texture_enable(void *data, bool state, bool full_screen) } static void exynos_set_osd_msg(void *data, const char *msg, - const struct font_params *params) -{ - (void)data; - (void)msg; - (void)params; -} - -static void exynos_show_mouse(void *data, bool state) -{ - (void)data; - (void)state; -} + const struct font_params *params) { } +static void exynos_show_mouse(void *data, bool state) { } static const video_poke_interface_t exynos_poke_interface = { NULL, /* get_flags */ diff --git a/gfx/drivers/fpga_gfx.c b/gfx/drivers/fpga_gfx.c index 0416cb9a2e..be15b7a4d7 100644 --- a/gfx/drivers/fpga_gfx.c +++ b/gfx/drivers/fpga_gfx.c @@ -342,9 +342,8 @@ static void fpga_set_texture_frame(void *data, } /* TODO/FIXME - implement */ -static void fpga_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) { } +static void fpga_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { } static void fpga_get_video_output_size(void *data, unsigned *width, unsigned *height, char *desc, size_t desc_len) { } static void fpga_get_video_output_prev(void *data) { } diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 7282ce5cd7..7687061370 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -938,16 +938,8 @@ static bool gl1_gfx_frame(void *data, const void *frame, if (video_info->statistics_show) { if (osd_params) - { font_driver_render_msg(gl1, video_info->stat_text, osd_params, NULL); -#if 0 - osd_params->y = 0.350f; - osd_params->scale = 0.75f; - font_driver_render_msg(gl1, video_info->chat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); -#endif - } } #ifdef HAVE_GFX_WIDGETS diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index 3a97bcc352..9f8d097409 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -1732,9 +1732,8 @@ static void wiiu_gfx_set_texture_enable(void *data, bool state, bool full_screen } -static void wiiu_gfx_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) +static void wiiu_gfx_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { wiiu_video_t *wiiu = (wiiu_video_t *)data; if (wiiu && wiiu->render_msg_enabled) diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index 5b2c23fbd8..7b45b653e8 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -702,9 +702,8 @@ static void ps2_set_texture_enable(void *data, bool enable, bool fullscreen) ps2->menuVisible = enable; } -static void ps2_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) +static void ps2_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { ps2_video_t *ps2 = (ps2_video_t *)data; diff --git a/gfx/drivers/rsx_gfx.c b/gfx/drivers/rsx_gfx.c index 9203ec80f0..5494df000c 100644 --- a/gfx/drivers/rsx_gfx.c +++ b/gfx/drivers/rsx_gfx.c @@ -1559,7 +1559,7 @@ static void rsx_viewport_info(void* data, struct video_viewport* vp) static void rsx_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, - const void *params, void *font) + const struct font_params *params, void *font) { rsx_t* gcm = (rsx_t*)data; if (gcm && gcm->msg_rendering_enabled) diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index f2932eea8a..395400dfb0 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -659,9 +659,8 @@ static void sdl2_poke_texture_enable(void *data, vid->menu.active = enable; } -static void sdl2_poke_set_osd_msg(void *data, - const char *msg, - const void *params, void *font) +static void sdl2_poke_set_osd_msg(void *data, const char *msg, + const struct font_params *params, void *font) { sdl2_video_t *vid = (sdl2_video_t*)data; sdl2_render_msg(vid, msg); diff --git a/gfx/drivers/switch_gfx.c b/gfx/drivers/switch_gfx.c index 0fa035123d..68b526bf18 100644 --- a/gfx/drivers/switch_gfx.c +++ b/gfx/drivers/switch_gfx.c @@ -236,14 +236,6 @@ static bool switch_frame(void *data, const void *frame, } #endif -#if 0 - if (frame_count > 6000) - { - display_finalize(); - exit(0); - } -#endif - r = surface_dequeue_buffer(&sw->surface, &out_buffer); if (r != RESULT_OK) return true; /* just skip the frame */ diff --git a/gfx/font_driver.c b/gfx/font_driver.c index f8ccf3378a..bc537a12cf 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -29,8 +29,7 @@ static void *video_font_driver = NULL; int font_renderer_create_default( const font_renderer_driver_t **drv, - void **handle, - const char *font_path, unsigned font_size) + void **handle, const char *font_path, unsigned font_size) { static const font_renderer_driver_t *font_backends[] = { #ifdef HAVE_FREETYPE @@ -74,416 +73,6 @@ int font_renderer_create_default( return 0; } -#ifdef HAVE_D3D8 -static bool d3d8_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - static const font_renderer_t *d3d8_font_backends[] = { -#if defined(_XBOX1) - &d3d_xdk1_font, -#endif - NULL - }; - unsigned i; - - for (i = 0; i < ARRAY_SIZE(d3d8_font_backends); i++) - { - void *data = d3d8_font_backends[i] ? d3d8_font_backends[i]->init( - video_data, font_path, font_size, - is_threaded) : NULL; - - if (!data) - continue; - - *font_driver = d3d8_font_backends[i]; - *font_handle = data; - - return true; - } - - return false; -} -#endif - -#ifdef HAVE_D3D9 -static bool d3d9_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - static const font_renderer_t *d3d9_font_backends[] = { -#if defined(_WIN32) && defined(HAVE_D3DX) - &d3d_win32_font, -#endif - NULL - }; - unsigned i; - - for (i = 0; i < ARRAY_SIZE(d3d9_font_backends); i++) - { - void *data = d3d9_font_backends[i] ? d3d9_font_backends[i]->init( - video_data, font_path, font_size, - is_threaded) : NULL; - - if (!data) - continue; - - *font_driver = d3d9_font_backends[i]; - *font_handle = data; - - return true; - } - - return false; -} -#endif - -#ifdef HAVE_OPENGL1 -static bool gl1_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = gl1_raster_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &gl1_raster_font; - *font_handle = data; - return true; -} -#endif - -#if defined(HAVE_OPENGL) -static bool gl_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = gl2_raster_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &gl2_raster_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_OPENGL_CORE -static bool gl3_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = gl3_raster_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &gl3_raster_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_CACA -static bool caca_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = caca_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &caca_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_SIXEL -static bool sixel_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = sixel_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &sixel_font; - *font_handle = data; - return true; -} -#endif - -#ifdef DJGPP -static bool vga_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = vga_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &vga_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_GDI -#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) -static bool gdi_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = gdi_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &gdi_font; - *font_handle = data; - return true; -} -#endif -#endif - -#ifdef HAVE_VULKAN -static bool vulkan_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = vulkan_raster_font.init(video_data, - font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &vulkan_raster_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_METAL -static bool metal_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = metal_raster_font.init(video_data, - font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &metal_raster_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_D3D10 -static bool d3d10_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = d3d10_font.init(video_data, - font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &d3d10_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_D3D11 -static bool d3d11_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = d3d11_font.init(video_data, - font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &d3d11_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_D3D12 -static bool d3d12_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = d3d12_font.init(video_data, - font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &d3d12_font; - *font_handle = data; - return true; -} -#endif - -#ifdef PS2 -static bool ps2_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = ps2_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &ps2_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_VITA2D -static bool vita2d_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = vita2d_vita_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &vita2d_vita_font; - *font_handle = data; - return true; -} -#endif - -#ifdef _3DS -static bool ctr_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = ctr_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &ctr_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_LIBNX -static bool switch_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = switch_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &switch_font; - *font_handle = data; - return true; -} -#endif - -#ifdef WIIU -static bool wiiu_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = wiiu_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &wiiu_font; - *font_handle = data; - return true; -} -#endif - -#ifdef HAVE_GCM -static bool rsx_font_init_first( - const void **font_driver, void **font_handle, - void *video_data, const char *font_path, - float font_size, bool is_threaded) -{ - void *data = rsx_font.init( - video_data, font_path, font_size, - is_threaded); - - if (!data) - return false; - - *font_driver = &rsx_font; - *font_handle = data; - return true; -} -#endif - static bool font_init_first( const void **font_driver, void **font_handle, void *video_data, const char *font_path, float font_size, @@ -496,105 +85,316 @@ static bool font_init_first( { #ifdef HAVE_OPENGL1 case FONT_DRIVER_RENDER_OPENGL1_API: - return gl1_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = gl1_raster_font.init( + video_data, font_path, font_size, is_threaded); + if (data) + { + *font_driver = &gl1_raster_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_OPENGL case FONT_DRIVER_RENDER_OPENGL_API: - return gl_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = gl2_raster_font.init( + video_data, font_path, font_size, is_threaded); + if (data) + { + *font_driver = &gl2_raster_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_OPENGL_CORE case FONT_DRIVER_RENDER_OPENGL_CORE_API: - return gl3_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = gl3_raster_font.init( + video_data, font_path, font_size, is_threaded); + if (data) + { + *font_driver = &gl3_raster_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_VULKAN case FONT_DRIVER_RENDER_VULKAN_API: - return vulkan_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = vulkan_raster_font.init(video_data, + font_path, font_size, is_threaded); + if (data) + { + *font_driver = &vulkan_raster_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_METAL case FONT_DRIVER_RENDER_METAL_API: - return metal_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = metal_raster_font.init(video_data, + font_path, font_size, is_threaded); + if (data) + { + *font_driver = &metal_raster_font; + *font_handle = data; + return true; + } + } #endif #ifdef HAVE_D3D8 case FONT_DRIVER_RENDER_D3D8_API: - return d3d8_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + static const font_renderer_t *d3d8_font_backends[] = { +#if defined(_XBOX1) + &d3d_xdk1_font, +#endif + NULL + }; + unsigned i; + + for (i = 0; i < ARRAY_SIZE(d3d8_font_backends); i++) + { + void *data = d3d8_font_backends[i] ? d3d8_font_backends[i]->init( + video_data, font_path, font_size, is_threaded) : NULL; + if (data) + { + *font_driver = d3d8_font_backends[i]; + *font_handle = data; + + return true; + } + } + } + break; #endif #ifdef HAVE_D3D9 case FONT_DRIVER_RENDER_D3D9_API: - return d3d9_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + static const font_renderer_t *d3d9_font_backends[] = { +#if defined(_WIN32) && defined(HAVE_D3DX) + &d3d_win32_font, +#endif + NULL + }; + unsigned i; + + for (i = 0; i < ARRAY_SIZE(d3d9_font_backends); i++) + { + void *data = d3d9_font_backends[i] ? d3d9_font_backends[i]->init( + video_data, font_path, font_size, is_threaded) : NULL; + if (data) + { + *font_driver = d3d9_font_backends[i]; + *font_handle = data; + + return true; + } + } + } + break; #endif #ifdef HAVE_D3D10 case FONT_DRIVER_RENDER_D3D10_API: - return d3d10_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = d3d10_font.init(video_data, + font_path, font_size, is_threaded); + if (data) + { + *font_driver = &d3d10_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_D3D11 case FONT_DRIVER_RENDER_D3D11_API: - return d3d11_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = d3d11_font.init(video_data, + font_path, font_size, is_threaded); + if (data) + { + *font_driver = &d3d11_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_D3D12 case FONT_DRIVER_RENDER_D3D12_API: - return d3d12_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = d3d12_font.init(video_data, + font_path, font_size, is_threaded); + if (data) + { + *font_driver = &d3d12_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_VITA2D case FONT_DRIVER_RENDER_VITA2D: - return vita2d_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = vita2d_vita_font.init( + video_data, font_path, font_size, is_threaded); + if (data) + { + *font_driver = &vita2d_vita_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef PS2 case FONT_DRIVER_RENDER_PS2: - return ps2_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = ps2_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &ps2_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef _3DS case FONT_DRIVER_RENDER_CTR: - return ctr_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = ctr_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &ctr_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef WIIU case FONT_DRIVER_RENDER_WIIU: - return wiiu_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = wiiu_font.init( + video_data, font_path, font_size, is_threaded); + if (data) + { + *font_driver = &wiiu_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_CACA case FONT_DRIVER_RENDER_CACA: - return caca_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = caca_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &caca_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_SIXEL case FONT_DRIVER_RENDER_SIXEL: - return sixel_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = sixel_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &sixel_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_LIBNX case FONT_DRIVER_RENDER_SWITCH: - return switch_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = switch_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &switch_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_GCM case FONT_DRIVER_RENDER_RSX: - return rsx_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = rsx_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &rsx_font; + *font_handle = data; + return true; + } + } + break; #endif #ifdef HAVE_GDI #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) case FONT_DRIVER_RENDER_GDI: - return gdi_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = gdi_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &gdi_font; + *font_handle = data; + return true; + } + } + break; #endif #endif #ifdef DJGPP case FONT_DRIVER_RENDER_VGA: - return vga_font_init_first(font_driver, font_handle, - video_data, font_path, font_size, is_threaded); + { + void *data = vga_font.init( + video_data, font_path, font_size, + is_threaded); + if (data) + { + *font_driver = &vga_font; + *font_handle = data; + return true; + } + } + break; #endif case FONT_DRIVER_RENDER_DONT_CARE: /* TODO/FIXME - lookup graphics driver's 'API' */ @@ -964,13 +764,9 @@ static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, siz } #endif -void font_driver_render_msg( - void *data, - const char *msg, - const void *_params, - void *font_data) +void font_driver_render_msg(void *data, const char *msg, + const struct font_params *params, void *font_data) { - const struct font_params *params = (const struct font_params*)_params; font_data_t *font = (font_data_t*)(font_data ? font_data : video_font_driver); @@ -979,14 +775,14 @@ void font_driver_render_msg( #ifdef HAVE_LANGEXTRA unsigned char tmp_buffer[64]; char *new_msg = font_driver_reshape_msg(msg, tmp_buffer, sizeof(tmp_buffer)); - font->renderer->render_msg(data, - font->renderer_data, new_msg, params); - if (new_msg != (char*)tmp_buffer) - free(new_msg); #else char *new_msg = (char*)msg; +#endif font->renderer->render_msg(data, font->renderer_data, new_msg, params); +#ifdef HAVE_LANGEXTRA + if (new_msg != (char*)tmp_buffer) + free(new_msg); #endif } } @@ -1071,10 +867,8 @@ int font_driver_get_line_centre_offset(font_data_t *font, float scale) return (int)roundf((1.58f * 0.5f * (float)font_driver_get_message_width(font, "a", 1, scale) / 0.6f) / 2.0f); } -void font_driver_free(void *font_data) +void font_driver_free(font_data_t *font) { - font_data_t *font = (font_data_t*)font_data; - if (font) { bool is_threaded = false; diff --git a/gfx/font_driver.h b/gfx/font_driver.h index b5cf627ebd..e462b74931 100644 --- a/gfx/font_driver.h +++ b/gfx/font_driver.h @@ -28,70 +28,6 @@ RETRO_BEGIN_DECLS -/* All coordinates and offsets are top-left oriented. - * - * This is a texture-atlas approach which allows text to - * be drawn in a single draw call. - * - * It is up to the code using this interface to actually - * generate proper vertex buffers and upload the atlas texture to GPU. */ - -struct font_glyph -{ - unsigned width; - unsigned height; - - /* Texel coordinate offset for top-left pixel of this glyph. */ - unsigned atlas_offset_x; - unsigned atlas_offset_y; - - /* When drawing this glyph, apply an offset to - * current X/Y draw coordinate. */ - int draw_offset_x; - int draw_offset_y; - - /* Advance X/Y draw coordinates after drawing this glyph. */ - int advance_x; - int advance_y; -}; - -struct font_atlas -{ - uint8_t *buffer; /* Alpha channel. */ - unsigned width; - unsigned height; - bool dirty; -}; - -struct font_params -{ - /* Drop shadow offset. - * If both are 0, no drop shadow will be rendered. */ - int drop_x, drop_y; - - /* ABGR. Use the macros. */ - uint32_t color; - - float x; - float y; - float scale; - /* Drop shadow color multiplier. */ - float drop_mod; - /* Drop shadow alpha */ - float drop_alpha; - - enum text_alignment text_align; - - bool full_screen; -}; - -struct font_line_metrics -{ - float height; - float ascender; - float descender; -}; - typedef struct font_renderer { void *(*init)(void *data, const char *font_path, @@ -142,7 +78,7 @@ int font_renderer_create_default( const char *font_path, unsigned font_size); void font_driver_render_msg(void *data, - const char *msg, const void *params, void *font_data); + const char *msg, const struct font_params *params, void *font_data); void font_driver_bind_block(void *font_data, void *block); @@ -150,7 +86,7 @@ int font_driver_get_message_width(void *font_data, const char *msg, size_t len, void font_driver_flush(unsigned width, unsigned height, void *font_data); -void font_driver_free(void *font_data); +void font_driver_free(font_data_t *font); font_data_t *font_driver_init_first( void *video_data, diff --git a/gfx/video_defines.h b/gfx/video_defines.h index 127a5bb97b..6bf67c7ccb 100644 --- a/gfx/video_defines.h +++ b/gfx/video_defines.h @@ -250,6 +250,70 @@ enum shader_program_type SHADER_PROGRAM_COMBINED }; +/* All coordinates and offsets are top-left oriented. + * + * This is a texture-atlas approach which allows text to + * be drawn in a single draw call. + * + * It is up to the code using this interface to actually + * generate proper vertex buffers and upload the atlas texture to GPU. */ + +struct font_glyph +{ + unsigned width; + unsigned height; + + /* Texel coordinate offset for top-left pixel of this glyph. */ + unsigned atlas_offset_x; + unsigned atlas_offset_y; + + /* When drawing this glyph, apply an offset to + * current X/Y draw coordinate. */ + int draw_offset_x; + int draw_offset_y; + + /* Advance X/Y draw coordinates after drawing this glyph. */ + int advance_x; + int advance_y; +}; + +struct font_atlas +{ + uint8_t *buffer; /* Alpha channel. */ + unsigned width; + unsigned height; + bool dirty; +}; + +struct font_params +{ + /* Drop shadow offset. + * If both are 0, no drop shadow will be rendered. */ + int drop_x, drop_y; + + /* ABGR. Use the macros. */ + uint32_t color; + + float x; + float y; + float scale; + /* Drop shadow color multiplier. */ + float drop_mod; + /* Drop shadow alpha */ + float drop_alpha; + + enum text_alignment text_align; + + bool full_screen; +}; + +struct font_line_metrics +{ + float height; + float ascender; + float descender; +}; + RETRO_END_DECLS #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index d7f95845d2..e0b94345b5 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -667,7 +667,7 @@ typedef struct video_poke_interface void (*set_texture_enable)(void *data, bool enable, bool full_screen); void (*set_osd_msg)(void *data, const char *msg, - const void *params, void *font); + const struct font_params *params, void *font); void (*show_mouse)(void *data, bool state); void (*grab_mouse_toggle)(void *data); diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 26eadc4ce4..6b81fbee07 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1166,7 +1166,7 @@ static void thread_set_texture_enable(void *data, bool state, bool full_screen) } static void thread_set_osd_msg(void *data, - const char *msg, const void *params, void *font) + const char *msg, const struct font_params *params, void *font) { thread_video_t *thr = (thread_video_t*)data;