Add userdata pointer to frame callback

This commit is contained in:
twinaphex 2015-12-10 15:12:47 +01:00
parent abc2315c78
commit ca9520a522
7 changed files with 32 additions and 55 deletions

View File

@ -567,7 +567,6 @@ static void mui_render_label_value(mui_handle_t *mui,
static void mui_render_menu_list(mui_handle_t *mui,
unsigned width, unsigned height,
menu_handle_t *menu,
uint32_t normal_color,
uint32_t hover_color,
float *pure_white)
@ -664,7 +663,7 @@ static void bgcolor_setalpha(float *bg, float alpha)
bg[15] = alpha;
}
static void mui_frame(void)
static void mui_frame(void *data)
{
unsigned header_height;
bool display_kb;
@ -723,8 +722,7 @@ static void mui_frame(void)
size_t selection;
size_t title_margin;
uint64_t *frame_count;
mui_handle_t *mui = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
mui_handle_t *mui = (mui_handle_t*)data;
settings_t *settings = config_get_ptr();
const uint32_t normal_color = 0x212121ff;
const uint32_t hover_color = 0x212121ff;
@ -738,11 +736,9 @@ static void mui_frame(void)
(void)passivetab_color;
(void)activetab_color;
if (!menu || !menu->userdata)
if (!mui)
return;
mui = (mui_handle_t*)menu->userdata;
msg[0] = '\0';
title[0] = '\0';
title_buf[0] = '\0';
@ -803,7 +799,7 @@ static void mui_frame(void)
menu_display_font_bind_block(&mui->list_block);
mui_render_menu_list(mui, width, height, menu, normal_color, hover_color, &pure_white[0]);
mui_render_menu_list(mui, width, height, normal_color, hover_color, &pure_white[0]);
menu_display_font_flush_block();
@ -815,7 +811,7 @@ static void mui_frame(void)
mui->tabs_height = 0;
/* display tabs if depth equal one, if not hide them */
if (mui_list_get_size(menu, MENU_LIST_PLAIN) == 1)
if (mui_list_get_size(mui, MENU_LIST_PLAIN) == 1)
{
mui_draw_tab_begin(mui, width, height, &white_bg[0], &grey_bg[0]);

View File

@ -124,7 +124,6 @@ static void rmenu_render(void *data)
char title[256] = {0};
char title_buf[256] = {0};
char title_msg[64] = {0};
menu_handle_t *menu = menu_driver_get_ptr();
size_t entries_end = menu_entries_get_end();
video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count);
@ -132,9 +131,6 @@ static void rmenu_render(void *data)
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
if (!menu)
return;
if (!render_normal)
{
render_normal = true;

View File

@ -398,7 +398,7 @@ end:
string_list_free(list);
}
static void rmenu_xui_frame(void)
static void rmenu_xui_frame(void *data)
{
XUIMessage msg;
XUIMessageRender msgRender;
@ -406,13 +406,8 @@ static void rmenu_xui_frame(void)
LPDIRECT3DDEVICE d3dr;
const char *message;
D3DVIEWPORT vp_full = {0};
d3d_video_t *d3d = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
d3d = (d3d_video_t*)video_driver_get_ptr(false);
d3d_video_t *d3d = (d3d_video_t*)
video_driver_get_ptr(false);
if (!d3d)
return;

View File

@ -265,8 +265,7 @@ static size_t xmb_list_get_selection(void *data)
static size_t xmb_list_get_size(void *data, menu_list_type_t type)
{
size_t list_size = 0;
menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
xmb_handle_t *xmb = (xmb_handle_t*)data;
switch (type)
{
@ -594,7 +593,7 @@ static void xmb_selection_pointer_changed(bool allow_animations)
ia = XMB_ITEM_ACTIVE_ALPHA;
iz = XMB_ITEM_ACTIVE_ZOOM;
depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN);
if (settings->menu.boxart_enable && depth == 1)
{
xmb_update_boxart_path(xmb, i);
@ -895,7 +894,7 @@ static xmb_node_t* xmb_get_node(xmb_handle_t *xmb, unsigned i)
static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
{
unsigned j;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
for (j = 0; j <= list_size; j++)
{
@ -963,7 +962,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
static void xmb_list_open_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
{
unsigned j;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
for (j = 0; j <= list_size; j++)
{
@ -987,7 +986,7 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL);
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL);
for (i = 0; i < list_size; i++)
{
@ -1028,7 +1027,7 @@ static void xmb_init_horizontal_list(menu_handle_t *menu, xmb_handle_t *xmb)
static void xmb_toggle_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
for (i = 0; i <= list_size; i++)
{
@ -1055,7 +1054,7 @@ static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb,
{
unsigned i;
int depth; /* keep this integer */
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL);
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL);
xmb->categories.x_pos = xmb->icon.spacing.horizontal *
-(float)xmb->categories.selection_ptr;
@ -1172,7 +1171,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
xmb->depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
xmb->depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN);
if (xmb->depth > xmb->old_depth)
dir = 1;
@ -1613,11 +1612,11 @@ static void xmb_render(void *data)
}
static void xmb_frame_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu, unsigned width, unsigned height,
unsigned width, unsigned height,
float *color)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
for (i = 0; i <= list_size; i++)
{
@ -1646,7 +1645,7 @@ static void xmb_frame_horizontal_list(xmb_handle_t *xmb,
}
}
static void xmb_frame(void)
static void xmb_frame(void *data)
{
size_t selection;
math_matrix_4x4 mymat;
@ -1659,19 +1658,13 @@ static void xmb_frame(void)
float coord_color2[16];
bool display_kb;
bool render_background = false;
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
xmb_handle_t *xmb = (xmb_handle_t*)data;
settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
if (!menu)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
@ -1721,7 +1714,7 @@ static void xmb_frame(void)
height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT,
width, height);
depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN);
xmb_draw_items(xmb,
xmb->selection_buf_old,
@ -1772,7 +1765,7 @@ static void xmb_frame(void)
0,
1, &coord_color2[0]);
xmb_frame_horizontal_list(xmb, menu, width, height, &item_color[0]);
xmb_frame_horizontal_list(xmb, width, height, &item_color[0]);
menu_display_font_flush_block();
@ -2449,7 +2442,7 @@ static void xmb_list_cache(menu_list_type_t type, unsigned action)
xmb_list_deep_copy(menu, menu_stack, xmb->menu_stack_old);
xmb->selection_ptr_old = selection;
list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
switch (type)
{
@ -2562,7 +2555,7 @@ static void xmb_toggle(bool menu_on)
if (!xmb)
return;
xmb->depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
xmb->depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN);
if (!menu_on)
{

View File

@ -111,7 +111,6 @@ typedef struct zarch_handle
{
enum menu_action action;
bool rendering;
menu_handle_t *menu;
math_matrix_4x4 mvp;
unsigned width;
unsigned height;
@ -940,21 +939,18 @@ static int zarch_zui_render_pick_core(zui_t *zui)
return 0;
}
static void zarch_frame(void)
static void zarch_frame(void *data)
{
unsigned i;
float coord_color[16];
float coord_color2[16];
zui_t *zui = NULL;
zui_t *zui = (zui_t*)data;
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
if (!zui)
return;
zui = (zui_t*)menu->userdata;
zui->menu = menu;
video_driver_get_size(&zui->width, &zui->height);
menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL);

View File

@ -632,6 +632,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
static bool menu_driver_load_no_content = false;
static bool menu_driver_alive = false;
static bool menu_driver_data_own = false;
menu_handle_t *menu = menu_driver_get_ptr();
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
switch (state)
@ -647,7 +648,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
if (!menu_driver_alive)
return false;
if (driver->frame)
driver->frame();
driver->frame(menu->userdata);
break;
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
menu_driver_prevent_populate = true;

View File

@ -252,7 +252,7 @@ typedef struct menu_ctx_driver
void (*render_messagebox)(void *data, const char *msg);
int (*iterate)(enum menu_action action);
void (*render)(void *data);
void (*frame)(void);
void (*frame)(void *data);
void* (*init)(void);
void (*free)(void*);
void (*context_reset)(void);