From 832840f91c5ecedbfd294b71ddd3ce4ccd0597fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:33:47 +0100 Subject: [PATCH] Cut down on more video_driver_get_size calls --- menu/drivers/materialui.c | 6 ++---- menu/drivers/nuklear.c | 20 +++++++++----------- menu/drivers/xmb.c | 10 ++++------ menu/menu_driver.c | 5 ++++- menu/menu_driver.h | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 53f16bddf6..583997847d 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -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; diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index e70a14aa1f..c18fac5ea5 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -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); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 90b5e261fe..0a46fced2e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -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) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 73f284c8c1..e0e787a697 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -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: diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 3d1b9c6731..8c49e734e5 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -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;