Skip to content

Commit

Permalink
Pass video_driver_width and video_driver_height
Browse files Browse the repository at this point in the history
to menu driver render callback function so that
we don't have to call video_driver_get_size anymore
  • Loading branch information
inactive123 committed Aug 13, 2019
1 parent 3585d56 commit 022b22a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
8 changes: 4 additions & 4 deletions menu/drivers/materialui.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,11 @@ static void materialui_compute_entries_box(materialui_handle_t* mui, int width)

/* Called on each frame. We use this callback to implement the touch scroll
with acceleration */
static void materialui_render(void *data, bool is_idle)
static void materialui_render(void *data,
unsigned width, unsigned height,
bool is_idle)
{
unsigned bottom, width, height, header_height;
unsigned bottom, header_height;
size_t i = 0;
materialui_handle_t *mui = (materialui_handle_t*)data;
settings_t *settings = config_get_ptr();
Expand All @@ -657,8 +659,6 @@ static void materialui_render(void *data, bool is_idle)
if (!mui)
return;

video_driver_get_size(&width, &height);

if (mui->need_compute)
{
if (mui->font)
Expand Down
4 changes: 3 additions & 1 deletion menu/drivers/ozone/ozone.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,9 @@ static void ozone_list_free(file_list_t *list, size_t a, size_t b)
ozone_list_clear(list);
}

static void ozone_render(void *data, bool is_idle)
static void ozone_render(void *data,
unsigned width, unsigned height,
bool is_idle)
{
size_t i;
unsigned end = (unsigned)menu_entries_get_size();
Expand Down
4 changes: 3 additions & 1 deletion menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -3065,7 +3065,9 @@ static void rgui_render_osk(rgui_t *rgui, menu_animation_ctx_ticker_t *ticker)
static bool rgui_set_aspect_ratio(rgui_t *rgui, bool delay_update);
#endif

static void rgui_render(void *data, bool is_idle)
static void rgui_render(void *data,
unsigned width, unsigned height,
bool is_idle)
{
menu_animation_ctx_ticker_t ticker;
static const char* const ticker_spacer = RGUI_TICKER_SPACER;
Expand Down
7 changes: 3 additions & 4 deletions menu/drivers/stripes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2655,7 +2655,9 @@ static void stripes_draw_items(
menu_display_blend_end(video_info);
}

static void stripes_render(void *data, bool is_idle)
static void stripes_render(void *data,
unsigned width, unsigned height,
bool is_idle)
{
size_t i;
settings_t *settings = config_get_ptr();
Expand All @@ -2674,9 +2676,6 @@ static void stripes_render(void *data, bool is_idle)
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS)
+ (stripes->cursor_size/2);
unsigned first = 0, last = end;
unsigned height;

video_driver_get_size(NULL, &height);

if (height)
stripes_calculate_visible_range(stripes, height,
Expand Down
11 changes: 3 additions & 8 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,8 @@ static void xmb_draw_items(
static void xmb_context_reset_internal(xmb_handle_t *xmb,
bool is_threaded, bool reinit_textures);

static void xmb_render(void *data, bool is_idle)
static void xmb_render(void *data,
unsigned width, unsigned height, bool is_idle)
{
size_t i;
settings_t *settings = config_get_ptr();
Expand All @@ -3212,14 +3213,11 @@ static void xmb_render(void *data, bool is_idle)
bool mouse_enable = settings->bools.menu_mouse_enable;
bool pointer_enable = settings->bools.menu_pointer_enable;

unsigned width, height;
float scale_factor;

if (!xmb)
if (!xmb)
return;

video_driver_get_size(&width, &height);

scale_factor = (settings->uints.menu_xmb_scale_factor * (float)width) / (1920.0 * 100);

if (scale_factor >= 0.1f && scale_factor != xmb->previous_scale_factor)
Expand All @@ -3230,15 +3228,12 @@ static void xmb_render(void *data, bool is_idle)

if (pointer_enable || mouse_enable)
{
unsigned height;
size_t selection = menu_navigation_get_selection();
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS)
+ (xmb->cursor_size/2);
unsigned first = 0, last = end;

video_driver_get_size(NULL, &height);

if (height)
xmb_calculate_visible_range(xmb, height,
end, (unsigned)selection, &first, &last);
Expand Down
4 changes: 3 additions & 1 deletion menu/drivers/xui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ static void xui_set_list_text(int index, const wchar_t* leftText,
}
}

static void xui_render(void *data, bool is_idle)
static void xui_render(void *data,
unsigned width, unsigned height,
bool is_idle)
{
size_t end, i, selection, fb_pitch;
unsigned fb_width, fb_height;
Expand Down
2 changes: 1 addition & 1 deletion menu/menu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ typedef struct menu_ctx_driver
/* Render a messagebox to the screen. */
void (*render_messagebox)(void *data, const char *msg);
int (*iterate)(void *data, void *userdata, enum menu_action action);
void (*render)(void *data, bool is_idle);
void (*render)(void *data, unsigned width, unsigned height, bool is_idle);
void (*frame)(void *data, video_frame_info_t *video_info);
/* Initializes the menu driver. (setup) */
void* (*init)(void**, bool);
Expand Down
5 changes: 4 additions & 1 deletion retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -23339,7 +23339,10 @@ static enum runloop_state runloop_check_state(void)
{
if (menu_data->driver_ctx->render)
menu_data->driver_ctx->render(
menu_data->userdata, runloop_idle);
menu_data->userdata,
video_driver_width,
video_driver_height,
runloop_idle);
}

if (menu_driver_alive && !runloop_idle)
Expand Down

0 comments on commit 022b22a

Please sign in to comment.