Cut down on more video_driver_get_size calls

This commit is contained in:
twinaphex 2017-01-19 01:33:47 +01:00
parent 57f1c0c3b6
commit 832840f91c
5 changed files with 20 additions and 23 deletions

View File

@ -329,17 +329,15 @@ static void mui_render_keyboard(mui_handle_t *mui,
}
/* Returns the OSK key at a given position */
static int mui_osk_ptr_at_pos(void *data, int x, int y)
static int mui_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height)
{
int ptr_width, ptr_height;
unsigned i, width, height;
unsigned i;
mui_handle_t *mui = (mui_handle_t*)data;
if (!mui)
return -1;
video_driver_get_size(&width, &height);
ptr_width = width / 11;
ptr_height = height / 10;

View File

@ -305,16 +305,22 @@ static void nk_menu_main(nk_menu_handle_t *nk)
static void nk_menu_frame(void *data, video_frame_info_t *video_info)
{
float white_bg[16]= {
unsigned ticker_limit, i;
float coord_black[16], coord_white[16];
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
settings_t *settings = config_get_ptr();
unsigned width = video_info->width;
unsigned height = video_info->height;
bool libretro_running = menu_display_libretro_running();
float white_bg[16] = {
0.98, 0.98, 0.98, 1,
0.98, 0.98, 0.98, 1,
0.98, 0.98, 0.98, 1,
0.98, 0.98, 0.98, 1,
};
float coord_black[16], coord_white[16];
for (int i = 0; i < 16; i++)
for (i = 0; i < 16; i++)
{
coord_black[i] = 0;
coord_white[i] = 1.0f;
@ -323,17 +329,9 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info)
menu_display_set_alpha(coord_black, 0.75);
menu_display_set_alpha(coord_white, 0.75);
unsigned width, height, ticker_limit, i;
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
settings_t *settings = config_get_ptr();
bool libretro_running = menu_display_libretro_running();
if (!nk)
return;
video_driver_get_size(&width, &height);
menu_display_set_viewport(video_info->width, video_info->height);
nk_input_begin(&nk->ctx);

View File

@ -767,18 +767,16 @@ static void xmb_render_keyboard(xmb_handle_t *xmb,
}
/* Returns the OSK key at a given position */
static int xmb_osk_ptr_at_pos(void *data, int x, int y)
static int xmb_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height)
{
unsigned i;
int ptr_width, ptr_height;
unsigned i, width, height;
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return -1;
video_driver_get_size(&width, &height);
ptr_width = width / 11;
ptr_width = width / 11;
ptr_height = height / 10;
if (ptr_width >= ptr_height)

View File

@ -886,14 +886,17 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
break;
case RARCH_MENU_CTL_OSK_PTR_AT_POS:
{
unsigned width = 0;
unsigned height = 0;
menu_ctx_pointer_t *point = (menu_ctx_pointer_t*)data;
if (!menu_driver_ctx || !menu_driver_ctx->osk_ptr_at_pos)
{
point->retcode = 0;
return false;
}
video_driver_get_size(&width, &height);
point->retcode = menu_driver_ctx->osk_ptr_at_pos(menu_userdata,
point->x, point->y);
point->x, point->y, width, height);
}
break;
case RARCH_MENU_CTL_BIND_INIT:

View File

@ -276,7 +276,7 @@ typedef struct menu_ctx_driver
menu_entry_t *entry, unsigned action);
void (*update_thumbnail_path)(void *data, unsigned i);
void (*update_thumbnail_image)(void *data);
int (*osk_ptr_at_pos)(void *data, int x, int y);
int (*osk_ptr_at_pos)(void *data, int x, int y, unsigned width, unsigned height);
void (*update_savestate_thumbnail_path)(void *data, unsigned i);
void (*update_savestate_thumbnail_image)(void *data);
} menu_ctx_driver_t;