mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
(gfx_widgets.c) Get rid of more pointer grabbing to
config_get_ptr/dispwidgets_get_ptr/etc
This commit is contained in:
parent
93edb2f2fb
commit
0674de54ee
@ -88,6 +88,7 @@ const static gfx_widget_t* const widgets[] = {
|
||||
|
||||
static float gfx_display_get_widget_dpi_scale(
|
||||
gfx_display_t *p_disp,
|
||||
settings_t *settings,
|
||||
unsigned width, unsigned height, bool fullscreen)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
@ -98,7 +99,6 @@ static float gfx_display_get_widget_dpi_scale(
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
static float adjusted_scale = 1.0f;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool gfx_widget_scale_auto = settings->bools.menu_widget_scale_auto;
|
||||
#if (defined(RARCH_CONSOLE) || defined(RARCH_MOBILE))
|
||||
float menu_widget_scale_factor = settings->floats.menu_widget_scale_factor;
|
||||
@ -161,6 +161,7 @@ static float gfx_display_get_widget_dpi_scale(
|
||||
|
||||
static float gfx_display_get_widget_pixel_scale(
|
||||
gfx_display_t *p_disp,
|
||||
settings_t *settings,
|
||||
unsigned width, unsigned height, bool fullscreen)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
@ -171,7 +172,6 @@ static float gfx_display_get_widget_pixel_scale(
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
static float adjusted_scale = 1.0f;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool gfx_widget_scale_auto = settings->bools.menu_widget_scale_auto;
|
||||
#if (defined(RARCH_CONSOLE) || defined(RARCH_MOBILE))
|
||||
float menu_widget_scale_factor = settings->floats.menu_widget_scale_factor;
|
||||
@ -1017,6 +1017,7 @@ static void gfx_widgets_layout(
|
||||
void gfx_widgets_iterate(
|
||||
void *data,
|
||||
void *data_disp,
|
||||
void *settings_data,
|
||||
unsigned width, unsigned height, bool fullscreen,
|
||||
const char *dir_assets, char *font_path,
|
||||
bool is_threaded)
|
||||
@ -1027,14 +1028,15 @@ void gfx_widgets_iterate(
|
||||
* factor have changed */
|
||||
float scale_factor = 0.0f;
|
||||
gfx_display_t *p_disp = (gfx_display_t*)data_disp;
|
||||
settings_t *settings = (settings_t*)settings_data;
|
||||
#ifdef HAVE_XMB
|
||||
enum menu_driver_id_type type = p_disp->menu_driver_id;
|
||||
if (type == MENU_DRIVER_ID_XMB)
|
||||
scale_factor = gfx_display_get_widget_pixel_scale(p_disp, width, height, fullscreen);
|
||||
scale_factor = gfx_display_get_widget_pixel_scale(p_disp, settings, width, height, fullscreen);
|
||||
else
|
||||
#endif
|
||||
scale_factor = gfx_display_get_widget_dpi_scale(p_disp,
|
||||
width, height, fullscreen);
|
||||
settings, width, height, fullscreen);
|
||||
|
||||
if ((scale_factor != p_dispwidget->last_scale_factor) ||
|
||||
(width != p_dispwidget->last_video_width) ||
|
||||
@ -1924,6 +1926,7 @@ static void gfx_widgets_free(dispgfx_widget_t *p_dispwidget)
|
||||
static void gfx_widgets_context_reset(
|
||||
dispgfx_widget_t *p_dispwidget,
|
||||
gfx_display_t *p_disp,
|
||||
settings_t *settings,
|
||||
bool is_threaded,
|
||||
unsigned width, unsigned height, bool fullscreen,
|
||||
const char *dir_assets, char *font_path)
|
||||
@ -2026,13 +2029,13 @@ static void gfx_widgets_context_reset(
|
||||
#ifdef HAVE_XMB
|
||||
if (p_disp->menu_driver_id == MENU_DRIVER_ID_XMB)
|
||||
p_dispwidget->last_scale_factor = gfx_display_get_widget_pixel_scale(
|
||||
p_disp,
|
||||
p_disp, settings,
|
||||
p_dispwidget->last_video_width,
|
||||
p_dispwidget->last_video_height, fullscreen);
|
||||
else
|
||||
#endif
|
||||
p_dispwidget->last_scale_factor = gfx_display_get_widget_dpi_scale(
|
||||
p_disp,
|
||||
p_disp, settings,
|
||||
p_dispwidget->last_video_width,
|
||||
p_dispwidget->last_video_height,
|
||||
fullscreen);
|
||||
@ -2042,15 +2045,19 @@ static void gfx_widgets_context_reset(
|
||||
video_driver_monitor_reset();
|
||||
}
|
||||
|
||||
bool gfx_widgets_init(uintptr_t widgets_active_ptr,
|
||||
bool gfx_widgets_init(
|
||||
void *data,
|
||||
void *data_disp,
|
||||
void *settings_data,
|
||||
uintptr_t widgets_active_ptr,
|
||||
bool video_is_threaded,
|
||||
unsigned width, unsigned height, bool fullscreen,
|
||||
const char *dir_assets, char *font_path)
|
||||
{
|
||||
unsigned i;
|
||||
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)
|
||||
dispwidget_get_ptr();
|
||||
gfx_display_t *p_disp = disp_get_ptr();
|
||||
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data;
|
||||
gfx_display_t *p_disp = (gfx_display_t*)data_disp;
|
||||
settings_t *settings = (settings_t*)settings_data;
|
||||
p_dispwidget->divider_width_1px = 1;
|
||||
p_dispwidget->gfx_widgets_generic_tag = (uintptr_t)widgets_active_ptr;
|
||||
|
||||
@ -2107,6 +2114,7 @@ bool gfx_widgets_init(uintptr_t widgets_active_ptr,
|
||||
gfx_widgets_context_reset(
|
||||
p_dispwidget,
|
||||
p_disp,
|
||||
settings,
|
||||
video_is_threaded,
|
||||
width, height, fullscreen,
|
||||
dir_assets, font_path);
|
||||
@ -2151,18 +2159,14 @@ static void gfx_widgets_context_destroy(dispgfx_widget_t *p_dispwidget)
|
||||
}
|
||||
|
||||
|
||||
bool gfx_widgets_deinit(bool widgets_persisting)
|
||||
void gfx_widgets_deinit(void *data, bool widgets_persisting)
|
||||
{
|
||||
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr();
|
||||
if (!p_dispwidget->widgets_inited)
|
||||
return false;
|
||||
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data;
|
||||
|
||||
gfx_widgets_context_destroy(p_dispwidget);
|
||||
|
||||
if (!widgets_persisting)
|
||||
gfx_widgets_free(p_dispwidget);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TRANSLATE
|
||||
|
@ -303,12 +303,15 @@ void gfx_widgets_flush_text(
|
||||
typedef struct gfx_widget gfx_widget_t;
|
||||
|
||||
bool gfx_widgets_init(
|
||||
void *data,
|
||||
void *data_disp,
|
||||
void *settings_data,
|
||||
uintptr_t widgets_active_ptr,
|
||||
bool video_is_threaded,
|
||||
unsigned width, unsigned height, bool fullscreen,
|
||||
const char *dir_assets, char *font_path);
|
||||
|
||||
bool gfx_widgets_deinit(bool widgets_persisting);
|
||||
void gfx_widgets_deinit(void *data, bool widgets_persisting);
|
||||
|
||||
void gfx_widgets_msg_queue_push(
|
||||
void *data,
|
||||
@ -326,6 +329,7 @@ void gfx_widget_volume_update_and_show(float new_volume,
|
||||
void gfx_widgets_iterate(
|
||||
void *data,
|
||||
void *data_disp,
|
||||
void *settings_data,
|
||||
unsigned width, unsigned height, bool fullscreen,
|
||||
const char *dir_assets, char *font_path,
|
||||
bool is_threaded);
|
||||
|
14
retroarch.c
14
retroarch.c
@ -32869,6 +32869,9 @@ static void drivers_init(struct rarch_state *p_rarch, int flags)
|
||||
rarch_force_fullscreen;
|
||||
|
||||
p_rarch->widgets_active = gfx_widgets_init(
|
||||
&p_rarch->dispwidget_st,
|
||||
&p_rarch->dispgfx,
|
||||
settings,
|
||||
(uintptr_t)&p_rarch->widgets_active,
|
||||
video_is_threaded,
|
||||
p_rarch->video_driver_width,
|
||||
@ -32954,8 +32957,11 @@ static void driver_uninit(struct rarch_state *p_rarch, int flags)
|
||||
/* This absolutely has to be done before video_driver_free_internal()
|
||||
* is called/completes, otherwise certain menu drivers
|
||||
* (e.g. Vulkan) will segfault */
|
||||
if (gfx_widgets_deinit(p_rarch->widgets_persisting))
|
||||
if (p_rarch->dispwidget_st.widgets_inited)
|
||||
{
|
||||
gfx_widgets_deinit(&p_rarch->dispwidget_st, p_rarch->widgets_persisting);
|
||||
p_rarch->widgets_active = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
@ -33026,8 +33032,11 @@ static void retroarch_deinit_drivers(struct rarch_state *p_rarch, struct retro_c
|
||||
* in case the handle is lost in the threaded
|
||||
* video driver in the meantime
|
||||
* (breaking video_driver_has_widgets) */
|
||||
if (gfx_widgets_deinit(p_rarch->widgets_persisting))
|
||||
if (p_rarch->dispwidget_st.widgets_inited)
|
||||
{
|
||||
gfx_widgets_deinit(&p_rarch->dispwidget_st, p_rarch->widgets_persisting);
|
||||
p_rarch->widgets_active = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Video */
|
||||
@ -37229,6 +37238,7 @@ static enum runloop_state runloop_check_state(
|
||||
gfx_widgets_iterate(
|
||||
&p_rarch->dispwidget_st,
|
||||
&p_rarch->dispgfx,
|
||||
settings,
|
||||
p_rarch->video_driver_width,
|
||||
p_rarch->video_driver_height,
|
||||
video_is_fullscreen,
|
||||
|
Loading…
x
Reference in New Issue
Block a user