mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 18:50:29 +00:00
(RGUI) Start refactoring menu_display code in RGUI
This commit is contained in:
parent
f83e26ea32
commit
057b498bb1
@ -185,11 +185,13 @@ static void blit_line(uint16_t *data,
|
||||
const char *message, uint16_t color)
|
||||
{
|
||||
unsigned i, j;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
while (*message)
|
||||
{
|
||||
uint32_t symbol = string_walk(&message);
|
||||
uint8_t *font_fb;
|
||||
uint32_t symbol = string_walk(&message);
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_FB, &font_fb);
|
||||
|
||||
for (j = 0; j < FONT_HEIGHT; j++)
|
||||
{
|
||||
@ -197,7 +199,7 @@ static void blit_line(uint16_t *data,
|
||||
{
|
||||
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
||||
int offset = (i + j * FONT_WIDTH) >> 3;
|
||||
bool col = (disp->font.framebuf[FONT_OFFSET(symbol) + offset] & rem);
|
||||
bool col = (font_fb[FONT_OFFSET(symbol) + offset] & rem);
|
||||
|
||||
if (!col)
|
||||
continue;
|
||||
@ -215,7 +217,6 @@ 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));
|
||||
bool fb_font_inited = true;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!font)
|
||||
return false;
|
||||
@ -230,7 +231,8 @@ 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));
|
||||
}
|
||||
|
||||
disp->font.framebuf = font;
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_FB, &font);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -238,7 +240,6 @@ 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;
|
||||
@ -249,7 +250,7 @@ static bool rguidisp_init_font(menu_handle_t *menu)
|
||||
if (!font_bin_buf)
|
||||
return false;
|
||||
|
||||
disp->font.framebuf = font_bin_buf;
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_FB, &font_bin_buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -711,11 +712,11 @@ error:
|
||||
|
||||
static void rgui_free(void *data)
|
||||
{
|
||||
uint8_t *font_fb;
|
||||
bool fb_font_inited = false;
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!menu || !disp)
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
if (menu->userdata)
|
||||
@ -723,9 +724,10 @@ static void rgui_free(void *data)
|
||||
menu->userdata = NULL;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_DATA_INIT, &fb_font_inited);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_FB, &font_fb);
|
||||
|
||||
if (fb_font_inited)
|
||||
free((uint8_t*)disp->font.framebuf);
|
||||
free(font_fb);
|
||||
|
||||
fb_font_inited = false;
|
||||
|
||||
|
@ -45,8 +45,6 @@ static menu_framebuf_t *menu_display_fb_get_ptr(void)
|
||||
return &frame_buf_state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void menu_display_fb_free(menu_framebuf_t *frame_buf)
|
||||
{
|
||||
if (!frame_buf)
|
||||
@ -194,6 +192,32 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MENU_DISPLAY_CTL_FONT_BUF:
|
||||
if (!data)
|
||||
return false;
|
||||
data = disp->font.buf;
|
||||
return true;
|
||||
case MENU_DISPLAY_CTL_SET_FONT_BUF:
|
||||
if (!data)
|
||||
return false;
|
||||
disp->font.buf = data;
|
||||
return true;
|
||||
case MENU_DISPLAY_CTL_FONT_FB:
|
||||
{
|
||||
uint8_t **ptr = (uint8_t**)data;
|
||||
if (!ptr)
|
||||
return false;
|
||||
*ptr = (uint8_t*)disp->font.framebuf;
|
||||
}
|
||||
return true;
|
||||
case MENU_DISPLAY_CTL_SET_FONT_FB:
|
||||
{
|
||||
uint8_t **ptr = (uint8_t**)data;
|
||||
if (!ptr)
|
||||
return false;
|
||||
disp->font.framebuf = *ptr;
|
||||
}
|
||||
return true;
|
||||
case MENU_DISPLAY_CTL_LIBRETRO:
|
||||
video_driver_set_texture_enable(true, false);
|
||||
|
||||
|
@ -53,7 +53,11 @@ enum menu_display_ctl_state
|
||||
MENU_DISPLAY_CTL_FONT_SIZE,
|
||||
MENU_DISPLAY_CTL_SET_FONT_SIZE,
|
||||
MENU_DISPLAY_CTL_MSG_FORCE,
|
||||
MENU_DISPLAY_CTL_SET_MSG_FORCE
|
||||
MENU_DISPLAY_CTL_SET_MSG_FORCE,
|
||||
MENU_DISPLAY_CTL_FONT_BUF,
|
||||
MENU_DISPLAY_CTL_SET_FONT_BUF,
|
||||
MENU_DISPLAY_CTL_FONT_FB,
|
||||
MENU_DISPLAY_CTL_SET_FONT_FB
|
||||
};
|
||||
|
||||
typedef struct menu_display
|
||||
|
Loading…
Reference in New Issue
Block a user