mirror of
https://github.com/libretro/RetroArch
synced 2025-02-08 06:40:14 +00:00
Move internal display state to menu_display.c
This commit is contained in:
parent
4cb3fec23d
commit
37e9108820
@ -550,20 +550,22 @@ static void glui_allocate_white_texture(glui_handle_t *glui)
|
||||
|
||||
static void glui_font(menu_handle_t *menu)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *font_path = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
font_path = settings->video.font_enable ? settings->video.font_path : NULL;
|
||||
|
||||
if (!menu_display_init_main_font(menu, font_path, menu->display.font.size))
|
||||
if (!menu_display_init_main_font(menu, font_path, disp->font.size))
|
||||
RARCH_ERR("Failed to load font.");
|
||||
}
|
||||
|
||||
static void glui_layout(menu_handle_t *menu, glui_handle_t *glui)
|
||||
{
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
float scale_factor;
|
||||
unsigned width, height;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
/* Mobiles platforms may have very small display metrics coupled to a high
|
||||
@ -574,10 +576,10 @@ static void glui_layout(menu_handle_t *menu, glui_handle_t *glui)
|
||||
|
||||
glui->line_height = scale_factor / 3;
|
||||
glui->margin = scale_factor / 6;
|
||||
menu->display.header_height = scale_factor / 3;
|
||||
menu->display.font.size = scale_factor / 10;
|
||||
disp->header_height = scale_factor / 3;
|
||||
disp->font.size = scale_factor / 10;
|
||||
/* we assume the average glyph aspect ratio is close to 3:4 */
|
||||
glui->glyph_width = menu->display.font.size * 3/4;
|
||||
glui->glyph_width = disp->font.size * 3/4;
|
||||
|
||||
glui_font(menu);
|
||||
|
||||
@ -675,7 +677,7 @@ static void glui_context_destroy(void)
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
menu_display_free_main_font(menu);
|
||||
menu_display_free_main_font();
|
||||
|
||||
glui_context_bg_destroy(glui);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "../../general.h"
|
||||
#include "../menu.h"
|
||||
#include "../menu_display.h"
|
||||
#include "../menu_hash.h"
|
||||
#include "../menu_video.h"
|
||||
|
||||
@ -212,12 +213,13 @@ static void blit_line(uint16_t *data,
|
||||
static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
|
||||
{
|
||||
unsigned i;
|
||||
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
|
||||
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!font)
|
||||
return false;
|
||||
|
||||
menu->display.font.alloc_framebuf = true;
|
||||
disp->font.alloc_framebuf = true;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
@ -227,7 +229,7 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
|
||||
font_bmp_buf + 54 + 3 * (256 * (255 - 16 * y) + 16 * x));
|
||||
}
|
||||
|
||||
menu->display.font.framebuf = font;
|
||||
disp->font.framebuf = font;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -235,6 +237,7 @@ static bool rguidisp_init_font(menu_handle_t *menu)
|
||||
{
|
||||
const uint8_t *font_bmp_buf = NULL;
|
||||
const uint8_t *font_bin_buf = bitmap_bin;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return false;
|
||||
@ -245,7 +248,7 @@ static bool rguidisp_init_font(menu_handle_t *menu)
|
||||
if (!font_bin_buf)
|
||||
return false;
|
||||
|
||||
menu->display.font.framebuf = font_bin_buf;
|
||||
disp->font.framebuf = font_bin_buf;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -407,12 +410,12 @@ static void rgui_render(void)
|
||||
char title[256], title_buf[256], title_msg[64];
|
||||
char msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH];
|
||||
uint16_t *fb_data = NULL;
|
||||
rgui_t *rgui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint64_t *frame_count = video_driver_get_frame_count();
|
||||
rgui_t *rgui = NULL;
|
||||
|
||||
msg[0] = '\0';
|
||||
title[0] = '\0';
|
||||
@ -641,6 +644,7 @@ static void *rgui_init(void)
|
||||
uint16_t *fb_data = NULL;
|
||||
rgui_t *rgui = NULL;
|
||||
bool ret = false;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
|
||||
if (!menu)
|
||||
@ -665,7 +669,7 @@ static void *rgui_init(void)
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &fb_height);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_DATA, fb_data);
|
||||
|
||||
menu->display.header_height = FONT_HEIGHT_STRIDE * 2;
|
||||
disp->header_height = FONT_HEIGHT_STRIDE * 2;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_PITCH, &fb_pitch);
|
||||
|
||||
@ -701,8 +705,8 @@ error:
|
||||
|
||||
static void rgui_free(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_display_t *disp = menu ? &menu->display : NULL;
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!menu || !disp)
|
||||
return;
|
||||
|
@ -448,6 +448,7 @@ static void xmb_draw_text(menu_handle_t *menu,
|
||||
{
|
||||
uint8_t a8 = 0;
|
||||
struct font_params params = {0};
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (alpha > xmb->alpha)
|
||||
alpha = xmb->alpha;
|
||||
@ -469,7 +470,7 @@ static void xmb_draw_text(menu_handle_t *menu,
|
||||
params.full_screen = true;
|
||||
params.text_align = text_align;
|
||||
|
||||
video_driver_set_osd_msg(str, ¶ms, menu->display.font.buf);
|
||||
video_driver_set_osd_msg(str, ¶ms, disp->font.buf);
|
||||
}
|
||||
|
||||
static void xmb_render_messagebox_internal(const char *message)
|
||||
@ -497,6 +498,7 @@ static void xmb_frame_messagebox(const char *message)
|
||||
gl_t *gl = NULL;
|
||||
xmb_handle_t *xmb = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
@ -520,8 +522,8 @@ static void xmb_frame_messagebox(const char *message)
|
||||
if (list->elems == 0)
|
||||
goto end;
|
||||
|
||||
x = width / 2 - strlen(list->elems[0].data) * menu->display.font.size / 4;
|
||||
y = height / 2 - list->size * menu->display.font.size / 2;
|
||||
x = width / 2 - strlen(list->elems[0].data) * disp->font.size / 4;
|
||||
y = height / 2 - list->size * disp->font.size / 2;
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
@ -532,7 +534,7 @@ static void xmb_frame_messagebox(const char *message)
|
||||
xmb,
|
||||
msg,
|
||||
x,
|
||||
y + i * menu->display.font.size,
|
||||
y + i * disp->font.size,
|
||||
1,
|
||||
1,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1692,17 +1694,15 @@ static void xmb_init_horizontal_list(menu_handle_t *menu, xmb_handle_t *xmb)
|
||||
|
||||
static void xmb_font(menu_handle_t *menu)
|
||||
{
|
||||
char mediapath[PATH_MAX_LENGTH], themepath[PATH_MAX_LENGTH], fontpath[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
char mediapath[PATH_MAX_LENGTH] = {0};
|
||||
char themepath[PATH_MAX_LENGTH] = {0};
|
||||
char fontpath[PATH_MAX_LENGTH] = {0};
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
fill_pathname_join(mediapath, settings->assets_directory, "xmb", sizeof(mediapath));
|
||||
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
|
||||
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
|
||||
|
||||
if (!menu_display_init_main_font(menu, fontpath, menu->display.font.size))
|
||||
if (!menu_display_init_main_font(menu, fontpath, disp->font.size))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
}
|
||||
|
||||
@ -1710,8 +1710,9 @@ static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
|
||||
{
|
||||
size_t selection;
|
||||
float scale_factor;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
unsigned width, height, i, current, end;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
||||
return;
|
||||
@ -1722,18 +1723,18 @@ static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
|
||||
|
||||
xmb->boxart_size = 460.0 * scale_factor;
|
||||
xmb->cursor.size = 48.0;
|
||||
menu->display.font.size = 32.0 * scale_factor;
|
||||
disp->font.size = 32.0 * scale_factor;
|
||||
xmb->icon.spacing.horizontal = 200.0 * scale_factor;
|
||||
xmb->icon.spacing.vertical = 64.0 * scale_factor;
|
||||
xmb->margins.screen.left = 336.0 * scale_factor;
|
||||
xmb->margins.screen.top = (256+32) * scale_factor;
|
||||
xmb->margins.title.left = 60 * scale_factor;
|
||||
xmb->margins.title.top = 60 * scale_factor + menu->display.font.size/3;
|
||||
xmb->margins.title.bottom = 60 * scale_factor - menu->display.font.size/3;
|
||||
xmb->margins.title.top = 60 * scale_factor + disp->font.size/3;
|
||||
xmb->margins.title.bottom = 60 * scale_factor - disp->font.size/3;
|
||||
xmb->margins.label.left = 85.0 * scale_factor;
|
||||
xmb->margins.label.top = menu->display.font.size / 3.0;
|
||||
xmb->margins.label.top = disp->font.size / 3.0;
|
||||
xmb->margins.setting.left = 600.0 * scale_factor;
|
||||
menu->display.header_height = 128.0 * scale_factor;
|
||||
disp->header_height = 128.0 * scale_factor;
|
||||
|
||||
if (width >= 3840)
|
||||
scale_factor = 2.0;
|
||||
@ -2467,7 +2468,7 @@ static void xmb_context_destroy(void)
|
||||
|
||||
xmb_context_destroy_horizontal_list(xmb, menu);
|
||||
|
||||
menu_display_free_main_font(menu);
|
||||
menu_display_free_main_font();
|
||||
}
|
||||
|
||||
static void xmb_toggle(bool menu_on)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_cbs.h"
|
||||
#include "menu_display.h"
|
||||
#include "menu_hash.h"
|
||||
#include "menu_shader.h"
|
||||
|
||||
@ -204,8 +205,7 @@ void menu_free(menu_handle_t *menu)
|
||||
libretro_free_system_info(&global->menu.info);
|
||||
#endif
|
||||
|
||||
menu_display_free(menu);
|
||||
|
||||
menu_display_free();
|
||||
menu_entries_free();
|
||||
|
||||
event_command(EVENT_CMD_HISTORY_DEINIT);
|
||||
@ -275,7 +275,7 @@ void *menu_init(const void *data)
|
||||
|
||||
menu_shader_manager_init(menu);
|
||||
|
||||
if (!menu_display_init(menu))
|
||||
if (!menu_display_init())
|
||||
goto error;
|
||||
|
||||
return menu;
|
||||
|
@ -31,14 +31,13 @@ typedef struct menu_framebuf
|
||||
bool dirty;
|
||||
} menu_framebuf_t;
|
||||
|
||||
static menu_display_t menu_display_state;
|
||||
|
||||
static menu_framebuf_t frame_buf_state;
|
||||
|
||||
menu_display_t *menu_display_get_ptr(void)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
if (!menu)
|
||||
return NULL;
|
||||
return &menu->display;
|
||||
return &menu_display_state;
|
||||
}
|
||||
|
||||
static menu_framebuf_t *menu_display_fb_get_ptr(void)
|
||||
@ -86,10 +85,9 @@ static void menu_display_fb_free(menu_framebuf_t *frame_buf)
|
||||
frame_buf->data = NULL;
|
||||
}
|
||||
|
||||
void menu_display_free(void *data)
|
||||
void menu_display_free(void)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_display_t *disp = menu ? &menu->display : NULL;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
if (!disp)
|
||||
return;
|
||||
|
||||
@ -100,16 +98,17 @@ void menu_display_free(void *data)
|
||||
menu_animation_free();
|
||||
|
||||
menu_display_fb_free(&frame_buf_state);
|
||||
memset(&frame_buf_state, 0, sizeof(menu_framebuf_t));
|
||||
memset(&frame_buf_state, 0, sizeof(menu_framebuf_t));
|
||||
memset(&menu_display_state, 0, sizeof(menu_display_t));
|
||||
}
|
||||
|
||||
bool menu_display_init(void *data)
|
||||
bool menu_display_init(void)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
if (!menu)
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
if (!disp)
|
||||
return false;
|
||||
|
||||
rarch_assert(menu->display.msg_queue = msg_queue_new(8));
|
||||
rarch_assert(disp->msg_queue = msg_queue_new(8));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -165,16 +164,17 @@ bool menu_display_font_flush_block(void *data,
|
||||
const struct font_renderer *font_driver)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
if (!font_driver || !font_driver->flush)
|
||||
return false;
|
||||
|
||||
font_driver->flush(menu->display.font.buf);
|
||||
font_driver->flush(disp->font.buf);
|
||||
|
||||
return menu_display_font_bind_block(menu,
|
||||
font_driver, NULL);
|
||||
}
|
||||
|
||||
void menu_display_free_main_font(void *data)
|
||||
void menu_display_free_main_font(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
@ -190,16 +190,15 @@ bool menu_display_init_main_font(void *data,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
bool ret;
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
void *video = video_driver_get_ptr(NULL);
|
||||
menu_display_t *disp = menu ? &menu->display : NULL;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!disp)
|
||||
return false;
|
||||
|
||||
if (disp->font.buf)
|
||||
menu_display_free_main_font(menu);
|
||||
menu_display_free_main_font();
|
||||
|
||||
ret = menu_display_font_init_first(
|
||||
(const void**)&driver->font_osd_driver,
|
||||
|
@ -70,9 +70,9 @@ menu_display_t *menu_display_get_ptr(void);
|
||||
|
||||
void menu_display_libretro(void);
|
||||
|
||||
void menu_display_free(void *data);
|
||||
void menu_display_free(void);
|
||||
|
||||
bool menu_display_init(void *data);
|
||||
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,
|
||||
@ -87,7 +87,7 @@ bool menu_display_font_flush_block(void *data,
|
||||
bool menu_display_init_main_font(void *data,
|
||||
const char *font_path, float font_size);
|
||||
|
||||
void menu_display_free_main_font(void *data);
|
||||
void menu_display_free_main_font(void);
|
||||
|
||||
|
||||
bool menu_display_ctl(enum menu_display_ctl_state state, void *data);
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <boolean.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include "menu_animation.h"
|
||||
#include "menu_display.h"
|
||||
#include "menu_displaylist.h"
|
||||
#include "menu_entries.h"
|
||||
#include "menu_list.h"
|
||||
@ -92,9 +91,6 @@ typedef struct
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
} menu_state;
|
||||
|
||||
/* Menu display */
|
||||
menu_display_t display;
|
||||
|
||||
/* Menu entries */
|
||||
menu_entries_t *entries;
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_display.h"
|
||||
|
||||
/* This file provides an abstraction of the currently displayed
|
||||
* menu.
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_display.h"
|
||||
#include "menu_hash.h"
|
||||
#include "menu_setting.h"
|
||||
#include "menu_navigation.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include "menu_display.h"
|
||||
#include "menu_video.h"
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
|
Loading…
x
Reference in New Issue
Block a user