mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
(Font) Less casting
This commit is contained in:
parent
e806e7e7a8
commit
ced83c41e6
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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) { }
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user