mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 06:40:18 +00:00
Cut down on code duplication
This commit is contained in:
parent
5f27366cb3
commit
988162ed62
@ -401,7 +401,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
sizeof(settings->video.font_path));
|
||||
#endif
|
||||
if (!font_driver_init_first(NULL, NULL,
|
||||
d3d, settings->video.font_path, 0, FONT_DRIVER_RENDER_DIRECT3D_API))
|
||||
d3d, settings->video.font_path, 0, false, FONT_DRIVER_RENDER_DIRECT3D_API))
|
||||
{
|
||||
RARCH_ERR("[D3D]: Failed to initialize font renderer.\n");
|
||||
return false;
|
||||
|
@ -2642,7 +2642,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
if (settings->video.font_enable)
|
||||
{
|
||||
if (!font_driver_init_first(NULL, NULL, gl, *settings->video.font_path
|
||||
? settings->video.font_path : NULL, settings->video.font_size,
|
||||
? settings->video.font_path : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_OPENGL_API))
|
||||
RARCH_ERR("[GL]: Failed to initialize font renderer.\n");
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ static void *vita2d_gfx_init(const video_info_t *video,
|
||||
vita->overlay_enable = false;
|
||||
#endif
|
||||
if (!font_driver_init_first(NULL, NULL, vita, *settings->video.font_path
|
||||
? settings->video.font_path : NULL, settings->video.font_size,
|
||||
? settings->video.font_path : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_VITA2D))
|
||||
{
|
||||
RARCH_ERR("Font: Failed to initialize font renderer.\n");
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "font_driver.h"
|
||||
#include "video_thread_wrapper.h"
|
||||
#include "../general.h"
|
||||
|
||||
#ifdef HAVE_D3D
|
||||
@ -187,14 +188,40 @@ void font_driver_free(void *data)
|
||||
|
||||
bool font_driver_init_first(const void **font_driver, void *font_handle,
|
||||
void *data, const char *font_path, float font_size,
|
||||
bool threading_hint,
|
||||
enum font_driver_render_api api)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
const void **new_font_driver = font_driver ? font_driver
|
||||
: (const void**)&driver->font_osd_driver;
|
||||
void *new_font_handle = font_handle ? font_handle
|
||||
: &driver->font_osd_data;
|
||||
|
||||
if (threading_hint && settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
thread_packet_t pkt;
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
pkt.type = CMD_FONT_INIT;
|
||||
pkt.data.font_init.method = font_init_first;
|
||||
pkt.data.font_init.font_driver = new_font_driver;
|
||||
pkt.data.font_init.font_handle = new_font_handle;
|
||||
pkt.data.font_init.video_data = data;
|
||||
pkt.data.font_init.font_path = font_path;
|
||||
pkt.data.font_init.font_size = font_size;
|
||||
pkt.data.font_init.api = api;
|
||||
|
||||
thr->send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.font_init.return_value;
|
||||
}
|
||||
|
||||
return font_init_first(new_font_driver, new_font_handle,
|
||||
data, font_path, font_size, api);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void font_driver_free(void *data);
|
||||
|
||||
bool font_driver_init_first(const void **font_driver, void *font_handle,
|
||||
void *data, const char *font_path, float font_size,
|
||||
enum font_driver_render_api api);
|
||||
bool threading_hint, enum font_driver_render_api api);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "../../config.def.h"
|
||||
#include "../../gfx/font_renderer_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_thread_wrapper.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include "../../gfx/d3d/d3d.h"
|
||||
#include "../../gfx/common/d3d_common.h"
|
||||
@ -238,38 +237,12 @@ static const float *menu_display_d3d_get_tex_coords(void)
|
||||
return &d3d_tex_coords[0];
|
||||
}
|
||||
|
||||
static bool menu_display_d3d_font_init_first(const void **font_driver,
|
||||
static bool menu_display_d3d_font_init_first(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
|
||||
if (settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
thread_packet_t pkt;
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
pkt.type = CMD_FONT_INIT;
|
||||
pkt.data.font_init.method = font_init_first;
|
||||
pkt.data.font_init.font_driver = (const void**)font_driver;
|
||||
pkt.data.font_init.font_handle = font_handle;
|
||||
pkt.data.font_init.video_data = video_data;
|
||||
pkt.data.font_init.font_path = font_path;
|
||||
pkt.data.font_init.font_size = font_size;
|
||||
pkt.data.font_init.api = FONT_DRIVER_RENDER_DIRECT3D_API;
|
||||
|
||||
thr->send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.font_init.return_value;
|
||||
}
|
||||
|
||||
return font_init_first(font_driver, font_handle, video_data,
|
||||
font_path, font_size, FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_d3d = {
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "../../config.def.h"
|
||||
#include "../../gfx/font_renderer_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_thread_wrapper.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include "../../gfx/common/gl_common.h"
|
||||
|
||||
@ -213,38 +212,12 @@ static const float *menu_display_gl_get_tex_coords(void)
|
||||
return &gl_tex_coords[0];
|
||||
}
|
||||
|
||||
static bool menu_display_gl_font_init_first(const void **font_driver,
|
||||
static bool menu_display_gl_font_init_first(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const struct retro_hw_render_callback *hw_render =
|
||||
(const struct retro_hw_render_callback*)video_driver_callback();
|
||||
|
||||
if (settings->video.threaded && !hw_render->context_type)
|
||||
{
|
||||
thread_packet_t pkt;
|
||||
thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true);
|
||||
|
||||
if (!thr)
|
||||
return false;
|
||||
|
||||
pkt.type = CMD_FONT_INIT;
|
||||
pkt.data.font_init.method = font_init_first;
|
||||
pkt.data.font_init.font_driver = (const void**)font_driver;
|
||||
pkt.data.font_init.font_handle = font_handle;
|
||||
pkt.data.font_init.video_data = video_data;
|
||||
pkt.data.font_init.font_path = font_path;
|
||||
pkt.data.font_init.font_size = font_size;
|
||||
pkt.data.font_init.api = FONT_DRIVER_RENDER_OPENGL_API;
|
||||
|
||||
thr->send_and_wait(thr, &pkt);
|
||||
|
||||
return pkt.data.font_init.return_value;
|
||||
}
|
||||
|
||||
return font_init_first(font_driver, font_handle, video_data,
|
||||
font_path, font_size, FONT_DRIVER_RENDER_OPENGL_API);
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_OPENGL_API);
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_gl = {
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "../../config.def.h"
|
||||
#include "../../gfx/font_renderer_driver.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
#include "../../gfx/video_thread_wrapper.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
|
||||
#include "../menu_display.h"
|
||||
@ -88,7 +87,7 @@ static const float *menu_display_null_get_tex_coords(void)
|
||||
return &floats[0];
|
||||
}
|
||||
|
||||
static bool menu_display_null_font_init_first(const void **font_driver,
|
||||
static bool menu_display_null_font_init_first(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size)
|
||||
{
|
||||
|
@ -131,15 +131,15 @@ bool menu_display_init(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool menu_display_font_init_first(const void **font_driver,
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
static bool menu_display_font_init_first(void **font_handle,
|
||||
void *video_data, const char *font_path,
|
||||
float font_size)
|
||||
{
|
||||
menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr();
|
||||
if (!menu_disp || !menu_disp->font_init_first)
|
||||
return false;
|
||||
|
||||
return menu_disp->font_init_first(font_driver, font_handle, video_data,
|
||||
return menu_disp->font_init_first(font_handle, video_data,
|
||||
font_path, font_size);
|
||||
}
|
||||
|
||||
@ -239,7 +239,6 @@ bool menu_display_init_main_font(void *data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
bool ret;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
void *video = video_driver_get_ptr(false);
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
@ -250,7 +249,6 @@ bool menu_display_init_main_font(void *data,
|
||||
menu_display_free_main_font();
|
||||
|
||||
ret = menu_display_font_init_first(
|
||||
(const void**)&driver->font_osd_driver,
|
||||
&disp->font.buf, video,
|
||||
font_path, font_size);
|
||||
|
||||
|
@ -107,7 +107,7 @@ typedef struct menu_display_ctx_driver
|
||||
const float *(*get_tex_coords)(void);
|
||||
unsigned (*texture_load)(void *data, enum texture_filter_type type);
|
||||
void (*texture_unload)(uintptr_t *id);
|
||||
bool (*font_init_first)(const void **font_driver,
|
||||
bool (*font_init_first)(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size);
|
||||
enum menu_display_driver_type type;
|
||||
@ -118,10 +118,6 @@ void menu_display_free(void);
|
||||
|
||||
bool menu_display_init(void);
|
||||
|
||||
bool menu_display_font_init_first(const void **font_driver,
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size);
|
||||
|
||||
bool menu_display_font_bind_block(void *data, const void *font_data, void *userdata);
|
||||
|
||||
bool menu_display_font_flush_block(void *data, const void *font_data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user