Get rid of more pointer grabbing

This commit is contained in:
twinaphex 2021-03-25 19:22:12 +01:00
parent d5e3103cf9
commit 8064af8f15
4 changed files with 24 additions and 10 deletions

View File

@ -360,7 +360,10 @@ float gfx_display_get_dpi_scale_internal(
return scale;
}
float gfx_display_get_dpi_scale(unsigned width, unsigned height)
float gfx_display_get_dpi_scale(
gfx_display_t *p_disp,
void *settings_data,
unsigned width, unsigned height)
{
static unsigned last_width = 0;
static unsigned last_height = 0;
@ -370,9 +373,8 @@ float gfx_display_get_dpi_scale(unsigned width, unsigned height)
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();
settings_t *settings = (settings_t*)settings_data;
float menu_scale_factor = settings->floats.menu_scale_factor;
gfx_display_t *p_disp = disp_get_ptr();
/* Scale is based on display metrics - these are a fixed
* hardware property. To minimise performance overheads

View File

@ -328,7 +328,10 @@ float gfx_display_get_adjusted_scale(
float gfx_display_get_dpi_scale_internal(unsigned width, unsigned height);
float gfx_display_get_dpi_scale(unsigned width, unsigned height);
float gfx_display_get_dpi_scale(
gfx_display_t *p_disp,
void *settings_data,
unsigned width, unsigned height);
void gfx_display_init_white_texture(uintptr_t white_texture);

View File

@ -3453,7 +3453,7 @@ static void materialui_render(void *data,
/* Check whether screen dimensions, menu scale
* factor or layout optimisation settings have changed */
scale_factor = gfx_display_get_dpi_scale(width, height);
scale_factor = gfx_display_get_dpi_scale(p_disp, settings, width, height);
if ((scale_factor != mui->last_scale_factor) ||
(width != mui->last_width) ||
@ -7635,13 +7635,16 @@ static void materialui_menu_animation_update_time(
float *ticker_pixel_increment,
unsigned video_width, unsigned video_height)
{
gfx_display_t *p_disp = disp_get_ptr();
settings_t *settings = config_get_ptr();
/* MaterialUI uses DPI scaling
* > Smooth ticker scaling multiplier is
* gfx_display_get_dpi_scale() multiplied by
* a small correction factor to achieve a
* default scroll speed equal to that of the
* non-smooth ticker */
*(ticker_pixel_increment) *= gfx_display_get_dpi_scale(video_width, video_height) * 0.8f;
*(ticker_pixel_increment) *= gfx_display_get_dpi_scale(p_disp, settings,
video_width, video_height) * 0.8f;
}
static void *materialui_init(void **userdata, bool video_is_threaded)
@ -7651,6 +7654,7 @@ static void *materialui_init(void **userdata, bool video_is_threaded)
gfx_animation_t *p_anim = anim_get_ptr();
materialui_handle_t *mui = NULL;
static const char* const ticker_spacer = MUI_TICKER_SPACER;
gfx_display_t *p_disp = disp_get_ptr();
menu_handle_t *menu = (menu_handle_t*)
calloc(1, sizeof(*menu));
@ -7683,7 +7687,7 @@ static void *materialui_init(void **userdata, bool video_is_threaded)
mui->last_width = width;
mui->last_height = height;
mui->last_scale_factor = gfx_display_get_dpi_scale(
width, height);
p_disp, settings, width, height);
mui->dip_base_unit_size = mui->last_scale_factor
* MUI_DIP_BASE_UNIT_SIZE;

View File

@ -668,13 +668,16 @@ static void ozone_menu_animation_update_time(
float *ticker_pixel_increment,
unsigned video_width, unsigned video_height)
{
gfx_display_t *p_disp = disp_get_ptr();
settings_t *settings = config_get_ptr();
/* Ozone uses DPI scaling
* > Smooth ticker scaling multiplier is
* gfx_display_get_dpi_scale() multiplied by
* a small correction factor to achieve a
* default scroll speed equal to that of the
* non-smooth ticker */
*(ticker_pixel_increment) *= gfx_display_get_dpi_scale(video_width, video_height) * 0.5f;
*(ticker_pixel_increment) *= gfx_display_get_dpi_scale(p_disp,
settings, video_width, video_height) * 0.5f;
}
static void *ozone_init(void **userdata, bool video_is_threaded)
@ -685,6 +688,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone_handle_t *ozone = NULL;
settings_t *settings = config_get_ptr();
gfx_animation_t *p_anim = anim_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
const char *directory_assets = settings->paths.directory_assets;
@ -705,7 +709,8 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->last_width = width;
ozone->last_height = height;
ozone->last_scale_factor = gfx_display_get_dpi_scale(width, height);
ozone->last_scale_factor = gfx_display_get_dpi_scale(p_disp,
settings, width, height);
file_list_initialize(&ozone->selection_buf_old);
@ -1735,7 +1740,7 @@ static void ozone_render(void *data,
/* Check whether screen dimensions or menu scale
* factor have changed */
scale_factor = gfx_display_get_dpi_scale(width, height);
scale_factor = gfx_display_get_dpi_scale(p_disp, settings, width, height);
if ((scale_factor != ozone->last_scale_factor) ||
(width != ozone->last_width) ||