mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 10:20:51 +00:00
commit
4e3ba81757
@ -433,13 +433,7 @@ static void* ctr_init(const video_info_t* video,
|
||||
driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate);
|
||||
aptHook(&ctr->lcd_aptHook, ctr_lcd_aptHook, ctr);
|
||||
|
||||
if (!font_driver_init_first(NULL, NULL, ctr, *settings->path.font
|
||||
? settings->path.font : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_CTR))
|
||||
{
|
||||
RARCH_ERR("Font: Failed to initialize font renderer.\n");
|
||||
return false;
|
||||
}
|
||||
font_driver_init_osd(ctr, false, FONT_DRIVER_RENDER_CTR);
|
||||
|
||||
ctr->msg_rendering_enabled = false;
|
||||
ctr->menu_texture_frame_enable = false;
|
||||
|
@ -815,13 +815,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
strlcpy(settings->path.font, "game:\\media\\Arial_12.xpr",
|
||||
sizeof(settings->path.font));
|
||||
#endif
|
||||
if (!font_driver_init_first(NULL, NULL,
|
||||
d3d, settings->path.font, 0, false,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API))
|
||||
{
|
||||
RARCH_ERR("[D3D]: Failed to initialize font renderer.\n");
|
||||
return false;
|
||||
}
|
||||
font_driver_init_osd(d3d, false, FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1412,8 +1412,7 @@ static void gl_free(void *data)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (font_driver_has_render_msg())
|
||||
font_driver_free(NULL);
|
||||
font_driver_free_osd();
|
||||
video_shader_driver_deinit();
|
||||
|
||||
#ifndef NO_GL_FF_VERTEX
|
||||
@ -2083,12 +2082,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
video_context_driver_input_driver(&inp);
|
||||
|
||||
if (settings->video.font_enable)
|
||||
{
|
||||
if (!font_driver_init_first(NULL, NULL, gl, *settings->path.font
|
||||
? settings->path.font : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_OPENGL_API))
|
||||
RARCH_ERR("[GL]: Failed to initialize font renderer.\n");
|
||||
}
|
||||
font_driver_init_osd(gl, false, FONT_DRIVER_RENDER_OPENGL_API);
|
||||
|
||||
#ifdef HAVE_GL_ASYNC_READBACK
|
||||
gl_init_pbo_readback(gl);
|
||||
|
@ -102,13 +102,8 @@ static void *vita2d_gfx_init(const video_info_t *video,
|
||||
#ifdef HAVE_OVERLAY
|
||||
vita->overlay_enable = false;
|
||||
#endif
|
||||
if (!font_driver_init_first(NULL, NULL, vita, *settings->path.font
|
||||
? settings->path.font : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_VITA2D))
|
||||
{
|
||||
RARCH_ERR("Font: Failed to initialize font renderer.\n");
|
||||
return false;
|
||||
}
|
||||
font_driver_init_osd(vita, false, FONT_DRIVER_RENDER_VITA2D);
|
||||
|
||||
return vita;
|
||||
}
|
||||
|
||||
|
@ -1113,12 +1113,7 @@ static void *vulkan_init(const video_info_t *video,
|
||||
video_context_driver_input_driver(&inp);
|
||||
|
||||
if (settings->video.font_enable)
|
||||
{
|
||||
if (!font_driver_init_first(NULL, NULL, vk, *settings->path.font
|
||||
? settings->path.font : NULL, settings->video.font_size, false,
|
||||
FONT_DRIVER_RENDER_VULKAN_API))
|
||||
RARCH_ERR("[Vulkan]: Failed to initialize font renderer.\n");
|
||||
}
|
||||
font_driver_init_osd(vk, false, FONT_DRIVER_RENDER_VULKAN_API);
|
||||
|
||||
vulkan_init_readback(vk);
|
||||
return vk;
|
||||
|
@ -681,7 +681,7 @@ static bool gfx_ctx_x_set_video_mode(void *data,
|
||||
#ifdef HAVE_VULKAN
|
||||
{
|
||||
bool quit, resize;
|
||||
unsigned width, height;
|
||||
unsigned width = 0, height = 0;
|
||||
x11_check_window(x, &quit, &resize, &width, &height, 0);
|
||||
|
||||
/* Use XCB surface since it's the most supported WSI.
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static const font_renderer_driver_t *font_backends[] = {
|
||||
#ifdef HAVE_FREETYPE
|
||||
&freetype_font_renderer,
|
||||
@ -38,9 +40,7 @@ static const font_renderer_driver_t *font_backends[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct font_renderer *font_osd_driver;
|
||||
|
||||
static void *font_osd_data;
|
||||
static void *g_osd_font;
|
||||
|
||||
int font_renderer_create_default(const void **data, void **handle,
|
||||
const char *font_path, unsigned font_size)
|
||||
@ -276,77 +276,109 @@ static bool font_init_first(
|
||||
|
||||
bool font_driver_has_render_msg(void)
|
||||
{
|
||||
if (!font_osd_driver || !font_osd_driver->render_msg)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void font_driver_render_msg(void *font_data,
|
||||
const char *msg, const struct font_params *params)
|
||||
{
|
||||
|
||||
if (font_osd_driver && font_osd_driver->render_msg)
|
||||
font_osd_driver->render_msg(font_data
|
||||
? font_data : font_osd_data, msg, params);
|
||||
font_data_t *font = (font_data_t*)(font_data ? font_data : g_osd_font);
|
||||
if (font && font->renderer->render_msg)
|
||||
font->renderer->render_msg(font->renderer_data, msg, params);
|
||||
}
|
||||
|
||||
void font_driver_bind_block(void *font_data, void *block)
|
||||
{
|
||||
void *new_font_data = font_data
|
||||
? font_data : font_osd_data;
|
||||
font_data_t *font = (font_data_t*)(font_data ? font_data : g_osd_font);
|
||||
|
||||
if (font_osd_driver && font_osd_driver->bind_block)
|
||||
font_osd_driver->bind_block(new_font_data, block);
|
||||
if (font->renderer && font->renderer->bind_block)
|
||||
font->renderer->bind_block(font->renderer_data, block);
|
||||
}
|
||||
|
||||
void font_driver_flush(void *data)
|
||||
void font_driver_flush(void *font_data)
|
||||
{
|
||||
if (font_osd_driver && font_osd_driver->flush)
|
||||
font_osd_driver->flush(data);
|
||||
font_data_t *font = (font_data_t*)(font_data ? font_data : g_osd_font);
|
||||
if (font->renderer && font->renderer->flush)
|
||||
font->renderer->flush(font->renderer_data);
|
||||
}
|
||||
|
||||
int font_driver_get_message_width(void *data,
|
||||
int font_driver_get_message_width(void *font_data,
|
||||
const char *msg, unsigned len, float scale)
|
||||
{
|
||||
|
||||
if (!font_osd_driver || !font_osd_driver->get_message_width)
|
||||
font_data_t *font = (font_data_t*)(font_data ? font_data : g_osd_font);
|
||||
if (!font->renderer || !font->renderer->get_message_width)
|
||||
return -1;
|
||||
return font_osd_driver->get_message_width(data, msg, len, scale);
|
||||
return font->renderer->get_message_width(font->renderer_data, msg, len, scale);
|
||||
}
|
||||
|
||||
void font_driver_free(void *data)
|
||||
void font_driver_free(void *font_data)
|
||||
{
|
||||
if (font_osd_driver && font_osd_driver->free)
|
||||
font_osd_driver->free(data ? data : font_osd_data);
|
||||
font_data_t *font = (font_data_t*)font_data;
|
||||
|
||||
if (data)
|
||||
return;
|
||||
if (font)
|
||||
{
|
||||
if (font->renderer && font->renderer->free)
|
||||
font->renderer->free(font->renderer_data);
|
||||
|
||||
font_osd_data = NULL;
|
||||
font_osd_driver = NULL;
|
||||
font->renderer = NULL;
|
||||
font->renderer_data = NULL;
|
||||
|
||||
free(font);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
font_data_t *font_driver_init_first(
|
||||
void *video_data, const char *font_path, float font_size,
|
||||
bool threading_hint, enum font_driver_render_api api)
|
||||
{
|
||||
const void **new_font_driver = font_driver ? font_driver
|
||||
: (const void**)&font_osd_driver;
|
||||
void **new_font_handle = font_handle ? font_handle
|
||||
: (void**)&font_osd_data;
|
||||
const void *font_driver;
|
||||
void *font_handle;
|
||||
bool ok = false;
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (threading_hint
|
||||
&& settings->video.threaded
|
||||
&& !video_driver_is_hw_context())
|
||||
return video_thread_font_init(new_font_driver, new_font_handle,
|
||||
data, font_path, font_size, api, font_init_first);
|
||||
ok = video_thread_font_init(&font_driver, &font_handle,
|
||||
video_data, font_path, font_size, api, font_init_first);
|
||||
else
|
||||
#endif
|
||||
ok = font_init_first(&font_driver, &font_handle,
|
||||
video_data, font_path, font_size, api);
|
||||
|
||||
return font_init_first(new_font_driver, new_font_handle,
|
||||
data, font_path, font_size, api);
|
||||
if (ok)
|
||||
{
|
||||
font_data_t *font = (font_data_t*)calloc(1, sizeof(*font));
|
||||
font->renderer = (const font_renderer_t*)font_driver;
|
||||
font->renderer_data = font_handle;
|
||||
font->size = font_size;
|
||||
return font;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void font_driver_init_osd(void *video_data, bool threading_hint, enum font_driver_render_api api)
|
||||
{
|
||||
if (!g_osd_font)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
g_osd_font = font_driver_init_first(video_data,
|
||||
*settings->path.font ? settings->path.font : NULL,
|
||||
settings->video.font_size, threading_hint, api);
|
||||
|
||||
if (!g_osd_font)
|
||||
RARCH_ERR("[font]: Failed to initialize OSD font.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void font_driver_free_osd(void)
|
||||
{
|
||||
if (g_osd_font)
|
||||
font_driver_free(g_osd_font);
|
||||
|
||||
g_osd_font = NULL;
|
||||
}
|
||||
|
@ -126,25 +126,34 @@ typedef struct font_renderer_driver
|
||||
int (*get_line_height)(void* data);
|
||||
} font_renderer_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const font_renderer_t *renderer;
|
||||
void *renderer_data;
|
||||
float size;
|
||||
} font_data_t;
|
||||
|
||||
/* font_path can be NULL for default font. */
|
||||
int font_renderer_create_default(const void **driver,
|
||||
void **handle, const char *font_path, unsigned font_size);
|
||||
|
||||
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_render_msg(void *font_data, const char *msg, const struct font_params *params);
|
||||
|
||||
void font_driver_bind_block(void *font_data, void *block);
|
||||
|
||||
int font_driver_get_message_width(void *data, const char *msg, unsigned len, float scale);
|
||||
int font_driver_get_message_width(void *font_data, const char *msg, unsigned len, float scale);
|
||||
|
||||
void font_driver_flush(void *data);
|
||||
void font_driver_flush(void *font_data);
|
||||
|
||||
void font_driver_free(void *data);
|
||||
void font_driver_free(void *font_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);
|
||||
font_data_t *font_driver_init_first(void *video_data, const char *font_path,
|
||||
float font_size, bool threading_hint, enum font_driver_render_api api);
|
||||
|
||||
void font_driver_init_osd(void *video_data, bool threading_hint, enum font_driver_render_api api);
|
||||
void font_driver_free_osd(void);
|
||||
|
||||
extern font_renderer_t gl_raster_font;
|
||||
extern font_renderer_t libdbg_font;
|
||||
|
@ -118,6 +118,7 @@ typedef struct mui_handle
|
||||
size_t selection_ptr;
|
||||
} categories;
|
||||
|
||||
font_data_t *font;
|
||||
video_font_raster_block_t list_block;
|
||||
float scroll_y;
|
||||
} mui_handle_t;
|
||||
@ -250,16 +251,13 @@ static void mui_draw_tab(mui_handle_t *mui,
|
||||
&tab_color[0]);
|
||||
}
|
||||
|
||||
static void mui_draw_text(float x, float y, unsigned width, unsigned height,
|
||||
static void mui_draw_text(font_data_t *font, float x, float y, unsigned width, unsigned height,
|
||||
const char *msg, uint32_t color, enum text_alignment text_align)
|
||||
{
|
||||
int font_size;
|
||||
struct font_params params;
|
||||
|
||||
font_size = menu_display_get_font_size();
|
||||
|
||||
params.x = x / width;
|
||||
params.y = 1.0f - (y + font_size / 3) / height;
|
||||
params.y = 1.0f - (y + font->size / 3) / height;
|
||||
params.scale = 1.0f;
|
||||
params.drop_mod = 0.0f;
|
||||
params.drop_x = 0.0f;
|
||||
@ -268,7 +266,7 @@ static void mui_draw_text(float x, float y, unsigned width, unsigned height,
|
||||
params.full_screen = true;
|
||||
params.text_align = text_align;
|
||||
|
||||
menu_display_draw_text(msg, width, height, ¶ms);
|
||||
menu_display_draw_text(font, msg, width, height, ¶ms);
|
||||
}
|
||||
|
||||
static void mui_render_quad(mui_handle_t *mui,
|
||||
@ -402,13 +400,11 @@ static void mui_render_messagebox(mui_handle_t *mui,
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
line_height = menu_display_get_font_size() * 1.2;
|
||||
line_height = mui->font->size * 1.2;
|
||||
|
||||
x = width / 2;
|
||||
y = height / 2 - (list->size-1) * line_height / 2;
|
||||
|
||||
fb_buf = menu_display_get_font_buffer();
|
||||
|
||||
/* find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
@ -417,7 +413,7 @@ static void mui_render_messagebox(mui_handle_t *mui,
|
||||
if (len > longest)
|
||||
{
|
||||
longest = len;
|
||||
longest_width = font_driver_get_message_width(fb_buf, msg, len, 1);
|
||||
longest_width = font_driver_get_message_width(mui->font, msg, len, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,7 +433,7 @@ static void mui_render_messagebox(mui_handle_t *mui,
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
if (msg)
|
||||
mui_draw_text(x - longest_width/2.0, y + i * line_height,
|
||||
mui_draw_text(mui->font, x - longest_width/2.0, y + i * line_height,
|
||||
width, height,
|
||||
msg, font_color, TEXT_ALIGN_LEFT);
|
||||
}
|
||||
@ -564,7 +560,7 @@ static void mui_render_label_value(mui_handle_t *mui,
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker);
|
||||
|
||||
mui_draw_text(mui->margin, y + mui->line_height / 2,
|
||||
mui_draw_text(mui->font, mui->margin, y + mui->line_height / 2,
|
||||
width, height, label_str, color, TEXT_ALIGN_LEFT);
|
||||
|
||||
if (string_is_equal(value, "disabled") || string_is_equal(value, "off"))
|
||||
@ -623,7 +619,7 @@ static void mui_render_label_value(mui_handle_t *mui,
|
||||
}
|
||||
|
||||
if (do_draw_text)
|
||||
mui_draw_text(width - mui->margin,
|
||||
mui_draw_text(mui->font, width - mui->margin,
|
||||
y + mui->line_height / 2,
|
||||
width, height, value_str, color, TEXT_ALIGN_RIGHT);
|
||||
|
||||
@ -1114,7 +1110,7 @@ static void mui_frame(void *data)
|
||||
&highlighted_entry_color[0]
|
||||
);
|
||||
|
||||
menu_display_font_bind_block(&mui->list_block);
|
||||
menu_display_font_bind_block(mui->font, &mui->list_block);
|
||||
|
||||
mui_render_menu_list(
|
||||
mui,
|
||||
@ -1125,7 +1121,7 @@ static void mui_frame(void *data)
|
||||
&active_tab_marker_color[0]
|
||||
);
|
||||
|
||||
menu_display_font_flush_block();
|
||||
menu_display_font_flush_block(mui->font);
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_SET_ACTIVE, NULL);
|
||||
|
||||
/* header */
|
||||
@ -1216,7 +1212,7 @@ static void mui_frame(void *data)
|
||||
strlcpy(title_buf, title_buf_msg_tmp, sizeof(title_buf));
|
||||
}
|
||||
|
||||
mui_draw_text(title_margin, header_height / 2, width, height,
|
||||
mui_draw_text(mui->font, title_margin, header_height / 2, width, height,
|
||||
title_buf, font_header_color, TEXT_ALIGN_LEFT);
|
||||
|
||||
mui_draw_scrollbar(mui, width, height, &grey_bg[0]);
|
||||
@ -1279,19 +1275,17 @@ static void mui_layout(mui_handle_t *mui)
|
||||
mui->icon_size = scale_factor / 3;
|
||||
|
||||
menu_display_set_header_height(new_header_height);
|
||||
menu_display_set_font_size(new_font_size);
|
||||
|
||||
/* we assume the average glyph aspect ratio is close to 3:4 */
|
||||
mui->glyph_width = new_font_size * 3/4;
|
||||
|
||||
menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT);
|
||||
mui->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT,
|
||||
new_font_size);
|
||||
|
||||
fb_buf = menu_display_get_font_buffer();
|
||||
|
||||
if (fb_buf) /* calculate a more realistic ticker_limit */
|
||||
if (mui->font) /* calculate a more realistic ticker_limit */
|
||||
{
|
||||
unsigned m_width =
|
||||
font_driver_get_message_width(fb_buf, "a", 1, 1);
|
||||
font_driver_get_message_width(mui->font, "a", 1, 1);
|
||||
|
||||
if (m_width)
|
||||
mui->glyph_width = m_width;
|
||||
@ -1317,9 +1311,6 @@ static void *mui_init(void **userdata)
|
||||
|
||||
*userdata = mui;
|
||||
|
||||
mui_layout(mui);
|
||||
menu_display_allocate_white_texture();
|
||||
|
||||
mui->cursor.size = 64.0;
|
||||
|
||||
return menu;
|
||||
@ -1361,7 +1352,7 @@ static void mui_context_destroy(void *data)
|
||||
for (i = 0; i < MUI_TEXTURE_LAST; i++)
|
||||
video_driver_texture_unload(&mui->textures.list[i]);
|
||||
|
||||
menu_display_font_main_deinit();
|
||||
menu_display_font_free(mui->font);
|
||||
|
||||
mui_context_bg_destroy(mui);
|
||||
}
|
||||
|
@ -277,6 +277,8 @@ typedef struct xmb_handle
|
||||
xmb_node_t history_tab_node;
|
||||
xmb_node_t add_tab_node;
|
||||
|
||||
font_data_t *font;
|
||||
float font_size;
|
||||
video_font_raster_block_t raster_block;
|
||||
|
||||
unsigned tabs[8];
|
||||
@ -666,7 +668,7 @@ static void xmb_draw_text(xmb_handle_t *xmb,
|
||||
params.drop_alpha = 0.35f;
|
||||
}
|
||||
|
||||
menu_display_draw_text(str, width, height, ¶ms);
|
||||
menu_display_draw_text(xmb->font, str, width, height, ¶ms);
|
||||
}
|
||||
|
||||
static void xmb_messagebox(void *data, const char *message)
|
||||
@ -682,7 +684,7 @@ static void xmb_messagebox(void *data, const char *message)
|
||||
static void xmb_render_messagebox_internal(
|
||||
xmb_handle_t *xmb, const char *message)
|
||||
{
|
||||
int x, y, font_size, longest = 0, longest_width = 0;
|
||||
int x, y, longest = 0, longest_width = 0;
|
||||
unsigned i;
|
||||
unsigned width, height;
|
||||
struct string_list *list = NULL;
|
||||
@ -700,12 +702,8 @@ static void xmb_render_messagebox_internal(
|
||||
if (list->elems == 0)
|
||||
goto end;
|
||||
|
||||
font_size = menu_display_get_font_size();
|
||||
|
||||
x = width / 2;
|
||||
y = height / 2 - (list->size-1) * font_size / 2;
|
||||
|
||||
fb_buf = menu_display_get_font_buffer();
|
||||
y = height / 2 - (list->size-1) * xmb->font->size / 2;
|
||||
|
||||
/* find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
@ -715,7 +713,7 @@ static void xmb_render_messagebox_internal(
|
||||
if (len > longest)
|
||||
{
|
||||
longest = len;
|
||||
longest_width = font_driver_get_message_width(fb_buf, msg, len, 1);
|
||||
longest_width = font_driver_get_message_width(xmb->font, msg, len, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -727,7 +725,7 @@ static void xmb_render_messagebox_internal(
|
||||
xmb_draw_text(
|
||||
xmb, msg,
|
||||
x - longest_width/2.0,
|
||||
y + i * font_size,
|
||||
y + i * xmb->font->size,
|
||||
1,
|
||||
1,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -2212,7 +2210,7 @@ static void xmb_frame(void *data)
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
menu_display_font_bind_block(&xmb->raster_block);
|
||||
menu_display_font_bind_block(xmb->font, &xmb->raster_block);
|
||||
|
||||
xmb->raster_block.carr.coords.vertices = 0;
|
||||
|
||||
@ -2409,7 +2407,7 @@ static void xmb_frame(void *data)
|
||||
width,
|
||||
height);
|
||||
|
||||
menu_display_font_flush_block();
|
||||
menu_display_font_flush_block(xmb->font);
|
||||
|
||||
if (menu_input_dialog_get_display_kb())
|
||||
{
|
||||
@ -2492,8 +2490,8 @@ static void xmb_layout_ps3(xmb_handle_t *xmb, int width)
|
||||
xmb->margins.label.top = new_font_size / 3.0;
|
||||
xmb->margins.setting.left = 600.0 * scale_factor;
|
||||
xmb->icon.size = 128.0 * scale_factor;
|
||||
xmb->font_size = new_font_size;
|
||||
|
||||
menu_display_set_font_size(new_font_size);
|
||||
menu_display_set_header_height(new_header_height);
|
||||
}
|
||||
|
||||
@ -2543,8 +2541,8 @@ static void xmb_layout_psp(xmb_handle_t *xmb, int width)
|
||||
xmb->margins.label.top = new_font_size / 3.0;
|
||||
xmb->margins.setting.left = 600.0 * scale_factor;
|
||||
xmb->icon.size = 128.0 * scale_factor;
|
||||
xmb->font_size = new_font_size;
|
||||
|
||||
menu_display_set_font_size(new_font_size);
|
||||
menu_display_set_header_height(new_header_height);
|
||||
}
|
||||
|
||||
@ -2732,7 +2730,8 @@ static void *xmb_init(void **userdata)
|
||||
menu_display_allocate_white_texture();
|
||||
|
||||
xmb_init_horizontal_list(xmb);
|
||||
menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT);
|
||||
/* FIXME: remove this? */
|
||||
xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, xmb->font_size);
|
||||
xmb_init_ribbon(xmb);
|
||||
|
||||
return menu;
|
||||
@ -2996,7 +2995,7 @@ static void xmb_context_reset(void *data)
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
|
||||
xmb_layout(xmb);
|
||||
menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT);
|
||||
xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, xmb->font_size);
|
||||
xmb_context_reset_textures(xmb, iconpath);
|
||||
xmb_context_reset_background(iconpath);
|
||||
xmb_context_reset_horizontal_list(xmb);
|
||||
@ -3289,7 +3288,7 @@ static void xmb_context_destroy(void *data)
|
||||
xmb_context_destroy_horizontal_list(xmb);
|
||||
xmb_context_bg_destroy(xmb);
|
||||
|
||||
menu_display_font_main_deinit();
|
||||
menu_display_font_free(xmb->font);
|
||||
}
|
||||
|
||||
static void xmb_toggle(void *userdata, bool menu_on)
|
||||
|
@ -175,8 +175,10 @@ static bool menu_display_ctr_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_CTR);
|
||||
return *handle;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_ctr = {
|
||||
|
@ -253,8 +253,10 @@ static bool menu_display_d3d_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
return *handle;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_d3d = {
|
||||
|
@ -217,8 +217,11 @@ static bool menu_display_gl_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_OPENGL_API);
|
||||
|
||||
return *handle;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_gl = {
|
||||
|
@ -229,8 +229,10 @@ static bool menu_display_vita2d_font_init_first(
|
||||
void **font_handle, void *video_data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_VITA2D);
|
||||
return *handle;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_vita2d = {
|
||||
|
@ -255,8 +255,11 @@ static bool menu_display_vk_font_init_first(
|
||||
void **font_handle, void *video_data, const char *font_path,
|
||||
float font_size)
|
||||
{
|
||||
return font_driver_init_first(NULL, font_handle, video_data,
|
||||
font_data_t **handle = (font_data_t**)font_handle;
|
||||
*handle = font_driver_init_first(video_data,
|
||||
font_path, font_size, true, FONT_DRIVER_RENDER_VULKAN_API);
|
||||
|
||||
return *handle;
|
||||
}
|
||||
|
||||
menu_display_ctx_driver_t menu_display_ctx_vulkan = {
|
||||
|
@ -163,13 +163,11 @@ static video_coord_array_t menu_disp_ca;
|
||||
static unsigned menu_display_framebuf_width = 0;
|
||||
static unsigned menu_display_framebuf_height = 0;
|
||||
static size_t menu_display_framebuf_pitch = 0;
|
||||
static int menu_display_font_size = 0;
|
||||
static unsigned menu_display_header_height = 0;
|
||||
static bool menu_display_msg_force = false;
|
||||
static bool menu_display_font_alloc_framebuf = false;
|
||||
static bool menu_display_framebuf_dirty = false;
|
||||
static const uint8_t *menu_display_font_framebuf = NULL;
|
||||
static void *menu_display_font_buf = NULL;
|
||||
static msg_queue_t *menu_display_msg_queue = NULL;
|
||||
static menu_display_ctx_driver_t *menu_disp = NULL;
|
||||
|
||||
@ -187,64 +185,47 @@ void menu_display_blend_end(void)
|
||||
menu_disp->blend_end();
|
||||
}
|
||||
|
||||
void menu_display_font_main_deinit(void)
|
||||
void menu_display_font_free(font_data_t *font)
|
||||
{
|
||||
if (menu_display_font_buf)
|
||||
font_driver_free(menu_display_font_buf);
|
||||
menu_display_font_buf = NULL;
|
||||
menu_display_font_size = 0;
|
||||
font_driver_free(font);
|
||||
}
|
||||
|
||||
bool menu_display_font(enum application_special_type type)
|
||||
font_data_t *menu_display_font(enum application_special_type type, float font_size)
|
||||
{
|
||||
menu_display_ctx_font_t font_info;
|
||||
char fontpath[PATH_MAX_LENGTH] = {0};
|
||||
int font_size = menu_display_get_font_size();
|
||||
|
||||
fill_pathname_application_special(fontpath, sizeof(fontpath), type);
|
||||
|
||||
font_info.path = fontpath;
|
||||
font_info.size = font_size;
|
||||
|
||||
if (!menu_display_font_main_init(&font_info))
|
||||
{
|
||||
RARCH_WARN("Failed to load font.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return menu_display_font_main_init(&font_info);
|
||||
}
|
||||
|
||||
bool menu_display_font_main_init(menu_display_ctx_font_t *font)
|
||||
font_data_t *menu_display_font_main_init(menu_display_ctx_font_t *font)
|
||||
{
|
||||
menu_display_font_main_deinit();
|
||||
font_data_t *font_data = NULL;
|
||||
|
||||
if (!font || !menu_disp)
|
||||
return false;
|
||||
|
||||
if (!menu_disp->font_init_first)
|
||||
return false;
|
||||
|
||||
if (!menu_disp->font_init_first(&menu_display_font_buf,
|
||||
if (menu_disp->font_init_first((void**)&font_data,
|
||||
video_driver_get_ptr(false),
|
||||
font->path, font->size))
|
||||
return false;
|
||||
|
||||
menu_display_font_size = font->size;
|
||||
return true;
|
||||
return font_data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void menu_display_font_bind_block(void *block)
|
||||
void menu_display_font_bind_block(font_data_t *font, void *block)
|
||||
{
|
||||
font_driver_bind_block(menu_display_font_buf, block);
|
||||
font_driver_bind_block(font, block);
|
||||
}
|
||||
|
||||
bool menu_display_font_flush_block(void)
|
||||
bool menu_display_font_flush_block(font_data_t *font)
|
||||
{
|
||||
if (!menu_display_font_buf)
|
||||
return false;
|
||||
|
||||
font_driver_flush(menu_display_font_buf);
|
||||
font_driver_bind_block(menu_display_font_buf, NULL);
|
||||
font_driver_flush(font);
|
||||
font_driver_bind_block(font, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -286,16 +267,6 @@ video_coord_array_t *menu_display_get_coords_array(void)
|
||||
return &menu_disp_ca;
|
||||
}
|
||||
|
||||
void *menu_display_get_font_buffer(void)
|
||||
{
|
||||
return menu_display_font_buf;
|
||||
}
|
||||
|
||||
void menu_display_set_font_buffer(void *buffer)
|
||||
{
|
||||
menu_display_font_buf = buffer;
|
||||
}
|
||||
|
||||
const uint8_t *menu_display_get_font_framebuffer(void)
|
||||
{
|
||||
return menu_display_font_framebuf;
|
||||
@ -366,16 +337,6 @@ unsigned menu_display_get_header_height(void)
|
||||
return menu_display_header_height;
|
||||
}
|
||||
|
||||
unsigned menu_display_get_font_size(void)
|
||||
{
|
||||
return menu_display_font_size;
|
||||
}
|
||||
|
||||
void menu_display_set_font_size(unsigned size)
|
||||
{
|
||||
menu_display_font_size = size;
|
||||
}
|
||||
|
||||
size_t menu_display_get_framebuffer_pitch(void)
|
||||
{
|
||||
return menu_display_framebuf_pitch;
|
||||
@ -827,11 +788,10 @@ void menu_display_snow(int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
void menu_display_draw_text(const char *msg,
|
||||
void menu_display_draw_text(const font_data_t *font, const char *msg,
|
||||
int width, int height, struct font_params *params)
|
||||
{
|
||||
void *fb_buf = menu_display_get_font_buffer();
|
||||
video_driver_set_osd_msg(msg, params, fb_buf);
|
||||
video_driver_set_osd_msg(msg, params, (void*)font);
|
||||
}
|
||||
|
||||
void menu_display_set_alpha(float *color, float alpha_value)
|
||||
|
@ -181,10 +181,10 @@ void menu_display_toggle_set_reason(enum menu_toggle_reason reason);
|
||||
void menu_display_blend_begin(void);
|
||||
void menu_display_blend_end(void);
|
||||
|
||||
void menu_display_font_main_deinit(void);
|
||||
bool menu_display_font_main_init(menu_display_ctx_font_t *font);
|
||||
void menu_display_font_bind_block(void *block);
|
||||
bool menu_display_font_flush_block(void);
|
||||
void menu_display_font_free(font_data_t *font);
|
||||
font_data_t *menu_display_font_main_init(menu_display_ctx_font_t *font);
|
||||
void menu_display_font_bind_block(font_data_t *font, void *block);
|
||||
bool menu_display_font_flush_block(font_data_t *font);
|
||||
|
||||
void menu_display_framebuffer_deinit(void);
|
||||
|
||||
@ -193,8 +193,6 @@ bool menu_display_init(void);
|
||||
|
||||
void menu_display_coords_array_reset(void);
|
||||
video_coord_array_t *menu_display_get_coords_array(void);
|
||||
void *menu_display_get_font_buffer(void);
|
||||
void menu_display_set_font_buffer(void *buffer);
|
||||
const uint8_t *menu_display_get_font_framebuffer(void);
|
||||
void menu_display_set_font_framebuffer(const uint8_t *buffer);
|
||||
bool menu_display_libretro_running(void);
|
||||
@ -206,8 +204,6 @@ void menu_display_set_height(unsigned height);
|
||||
unsigned menu_display_get_height(void);
|
||||
void menu_display_set_header_height(unsigned height);
|
||||
unsigned menu_display_get_header_height(void);
|
||||
unsigned menu_display_get_font_size(void);
|
||||
void menu_display_set_font_size(unsigned size);
|
||||
size_t menu_display_get_framebuffer_pitch(void);
|
||||
void menu_display_set_framebuffer_pitch(size_t pitch);
|
||||
|
||||
@ -254,14 +250,14 @@ void menu_display_draw_cursor(
|
||||
float *color, float cursor_size, uintptr_t texture,
|
||||
float x, float y, unsigned width, unsigned height);
|
||||
|
||||
void menu_display_draw_text(const char *msg, int width, int height,
|
||||
void menu_display_draw_text(const font_data_t *font, const char *msg, int width, int height,
|
||||
struct font_params *params);
|
||||
|
||||
bool menu_display_shader_pipeline_active(void);
|
||||
|
||||
void menu_display_set_alpha(float *color, float alpha_value);
|
||||
|
||||
bool menu_display_font(enum application_special_type type);
|
||||
font_data_t *menu_display_font(enum application_special_type type, float font_size);
|
||||
|
||||
void menu_display_reset_textures_list(const char *texture_path, const char *iconpath,
|
||||
uintptr_t *item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user