From ecd72b5be65edda353dfc9567f42679fcd681dae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 2 Oct 2020 22:23:51 +0200 Subject: [PATCH] (widgets) Get rid of get_ptr function calls --- gfx/widgets/gfx_widget_achievement_popup.c | 32 +++++++++---------- gfx/widgets/gfx_widget_leaderboard_display.c | 15 +++------ .../gfx_widget_load_content_animation.c | 21 +++++------- gfx/widgets/gfx_widget_progress_message.c | 13 +++----- gfx/widgets/gfx_widget_screenshot.c | 21 +++++------- gfx/widgets/gfx_widget_volume.c | 19 ++++------- 6 files changed, 47 insertions(+), 74 deletions(-) diff --git a/gfx/widgets/gfx_widget_achievement_popup.c b/gfx/widgets/gfx_widget_achievement_popup.c index eb6b8766ce..c2073fd9b7 100644 --- a/gfx/widgets/gfx_widget_achievement_popup.c +++ b/gfx/widgets/gfx_widget_achievement_popup.c @@ -51,11 +51,6 @@ typedef struct gfx_widget_achievement_popup_state gfx_widget_achievement_popup_s static gfx_widget_achievement_popup_state_t p_w_achievement_popup_st; -static gfx_widget_achievement_popup_state_t* gfx_widget_achievement_popup_get_ptr(void) -{ - return &p_w_achievement_popup_st; -} - /* Forward declarations */ static void gfx_widget_achievement_popup_start( gfx_widget_achievement_popup_state_t* state); @@ -64,7 +59,7 @@ static void gfx_widget_achievement_popup_free_current( static bool gfx_widget_achievement_popup_init(bool video_is_threaded, bool fullscreen) { - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t* state = &p_w_achievement_popup_st; memset(state, 0, sizeof(*state)); state->queue_read_index = -1; @@ -87,7 +82,7 @@ static void gfx_widget_achievement_popup_free_all(gfx_widget_achievement_popup_s static void gfx_widget_achievement_popup_free(void) { - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; gfx_widget_achievement_popup_free_all(state); @@ -99,7 +94,7 @@ static void gfx_widget_achievement_popup_free(void) static void gfx_widget_achievement_popup_context_destroy(void) { - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; gfx_widget_achievement_popup_free_all(state); } @@ -112,7 +107,7 @@ static void gfx_widget_achievement_popup_frame(void* data, void* userdata) 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, }; - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; gfx_display_t *p_disp = disp_get_ptr(); gfx_display_ctx_driver_t *dispctx = p_disp->dispctx; @@ -268,7 +263,7 @@ static void gfx_widget_achievement_popup_free_current(gfx_widget_achievement_pop static void gfx_widget_achievement_popup_next(void* userdata) { - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; SLOCK_LOCK(state->queue_lock); @@ -287,8 +282,9 @@ static void gfx_widget_achievement_popup_next(void* userdata) static void gfx_widget_achievement_popup_dismiss(void *userdata) { gfx_animation_ctx_entry_t entry; - const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*)dispwidget_get_ptr(); - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*) + dispwidget_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; /* Slide up animation */ entry.cb = gfx_widget_achievement_popup_next; @@ -305,8 +301,9 @@ static void gfx_widget_achievement_popup_dismiss(void *userdata) static void gfx_widget_achievement_popup_fold(void *userdata) { gfx_animation_ctx_entry_t entry; - const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*)dispwidget_get_ptr(); - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*) + dispwidget_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; /* Fold */ entry.cb = gfx_widget_achievement_popup_dismiss; @@ -324,8 +321,9 @@ static void gfx_widget_achievement_popup_unfold(void *userdata) { gfx_timer_ctx_entry_t timer; gfx_animation_ctx_entry_t entry; - const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*)dispwidget_get_ptr(); - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*) + dispwidget_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; /* Unfold */ entry.cb = NULL; @@ -379,7 +377,7 @@ static void gfx_widget_achievement_popup_start( void gfx_widgets_push_achievement(const char *title, const char *badge) { - gfx_widget_achievement_popup_state_t* state = gfx_widget_achievement_popup_get_ptr(); + gfx_widget_achievement_popup_state_t *state = &p_w_achievement_popup_st; int start_notification = 1; /* important - this must be done outside the lock because it has the potential to need to diff --git a/gfx/widgets/gfx_widget_leaderboard_display.c b/gfx/widgets/gfx_widget_leaderboard_display.c index 654c4cd76b..c742b134e6 100644 --- a/gfx/widgets/gfx_widget_leaderboard_display.c +++ b/gfx/widgets/gfx_widget_leaderboard_display.c @@ -51,14 +51,9 @@ typedef struct gfx_widget_leaderboard_display_state gfx_widget_leaderboard_displ static gfx_widget_leaderboard_display_state_t p_w_leaderboard_display_st; -static gfx_widget_leaderboard_display_state_t* gfx_widget_leaderboard_display_get_ptr(void) -{ - return &p_w_leaderboard_display_st; -} - static bool gfx_widget_leaderboard_display_init(bool video_is_threaded, bool fullscreen) { - gfx_widget_leaderboard_display_state_t* state = gfx_widget_leaderboard_display_get_ptr(); + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; memset(state, 0, sizeof(*state)); return true; @@ -71,7 +66,7 @@ static void gfx_widget_leaderboard_display_free_all(gfx_widget_leaderboard_displ static void gfx_widget_leaderboard_display_free(void) { - gfx_widget_leaderboard_display_state_t* state = gfx_widget_leaderboard_display_get_ptr(); + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; gfx_widget_leaderboard_display_free_all(state); @@ -83,14 +78,14 @@ static void gfx_widget_leaderboard_display_free(void) static void gfx_widget_leaderboard_display_context_destroy(void) { - gfx_widget_leaderboard_display_state_t* state = gfx_widget_leaderboard_display_get_ptr(); + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; gfx_widget_leaderboard_display_free_all(state); } static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) { - gfx_widget_leaderboard_display_state_t* state = gfx_widget_leaderboard_display_get_ptr(); + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; /* if there's nothing to display, just bail */ if (state->count == 0) @@ -146,8 +141,8 @@ static void gfx_widget_leaderboard_display_frame(void* data, void* userdata) void gfx_widgets_set_leaderboard_display(unsigned id, const char* value) { - gfx_widget_leaderboard_display_state_t* state = gfx_widget_leaderboard_display_get_ptr(); int i; + gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st; SLOCK_LOCK(state->array_lock); diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 91031a85f7..f30cf651a9 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -158,16 +158,11 @@ static gfx_widget_load_content_animation_state_t p_w_load_content_animation_st = false /* has_icon */ }; -gfx_widget_load_content_animation_state_t *gfx_widget_load_content_animation_get_ptr(void) -{ - return &p_w_load_content_animation_st; -} - /* Utilities */ static void gfx_widget_load_content_animation_reset(void) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; uintptr_t alpha_tag = (uintptr_t)&state->alpha; uintptr_t slide_offset_tag = (uintptr_t)&state->slide_offset; @@ -197,7 +192,7 @@ static void gfx_widget_load_content_animation_reset(void) static void gfx_widget_load_content_animation_load_icon(void) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; /* In all cases, unload any existing icon texture */ if (state->icon_texture) @@ -282,7 +277,7 @@ static void gfx_widget_load_content_animation_fade_in_cb(void *userdata) bool gfx_widget_start_load_content_animation(void) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; const char *content_path = path_get(RARCH_PATH_CONTENT); const char *core_path = path_get(RARCH_PATH_CORE); @@ -525,7 +520,7 @@ static void gfx_widget_load_content_animation_layout( bool is_threaded, const char *dir_assets, char *font_path) { dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; unsigned last_video_width = p_dispwidget->last_video_width; unsigned last_video_height = p_dispwidget->last_video_height; @@ -578,7 +573,7 @@ static void gfx_widget_load_content_animation_iterate(void *user_data, const char *dir_assets, char *font_path, bool is_threaded) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; if (state->status == GFX_WIDGET_LOAD_CONTENT_BEGIN) { @@ -644,7 +639,7 @@ static void gfx_widget_load_content_animation_iterate(void *user_data, static void gfx_widget_load_content_animation_frame(void *data, void *user_data) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; if (state->status != GFX_WIDGET_LOAD_CONTENT_IDLE) { @@ -934,7 +929,7 @@ static void gfx_widget_load_content_animation_context_reset( char* menu_png_path, char* widgets_png_path) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; /* Cache icon directory */ if (string_is_empty(menu_png_path)) @@ -951,7 +946,7 @@ static void gfx_widget_load_content_animation_context_reset( static void gfx_widget_load_content_animation_context_destroy(void) { - gfx_widget_load_content_animation_state_t *state = gfx_widget_load_content_animation_get_ptr(); + gfx_widget_load_content_animation_state_t *state = &p_w_load_content_animation_st; /* Unload any icon texture */ if (state->icon_texture) diff --git a/gfx/widgets/gfx_widget_progress_message.c b/gfx/widgets/gfx_widget_progress_message.c index 8abb33fe60..7f1a7d859d 100644 --- a/gfx/widgets/gfx_widget_progress_message.c +++ b/gfx/widgets/gfx_widget_progress_message.c @@ -92,11 +92,6 @@ static gfx_widget_progress_message_state_t p_w_progress_message_st = { false, /* active */ }; -gfx_widget_progress_message_state_t *gfx_widget_progress_message_get_ptr(void) -{ - return &p_w_progress_message_st; -} - /* Callbacks */ static void gfx_widget_progress_message_fadeout_cb(void *userdata) @@ -133,7 +128,7 @@ void gfx_widget_set_progress_message(void *data, { gfx_timer_ctx_entry_t timer; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_progress_message_state_t *state = gfx_widget_progress_message_get_ptr(); + gfx_widget_progress_message_state_t *state = &p_w_progress_message_st; gfx_widget_font_data_t *font_regular = &p_dispwidget->gfx_widget_fonts.regular; uintptr_t alpha_tag = (uintptr_t)&state->alpha; @@ -184,7 +179,7 @@ static void gfx_widget_progress_message_layout( { float bar_padding; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_progress_message_state_t *state = gfx_widget_progress_message_get_ptr(); + gfx_widget_progress_message_state_t *state = &p_w_progress_message_st; unsigned last_video_width = p_dispwidget->last_video_width; unsigned last_video_height = p_dispwidget->last_video_height; unsigned widget_padding = p_dispwidget->simple_widget_padding; @@ -221,7 +216,7 @@ static void gfx_widget_progress_message_layout( static void gfx_widget_progress_message_frame(void *data, void *user_data) { - gfx_widget_progress_message_state_t *state = gfx_widget_progress_message_get_ptr(); + gfx_widget_progress_message_state_t *state = &p_w_progress_message_st; if (state->active) { @@ -316,7 +311,7 @@ static void gfx_widget_progress_message_frame(void *data, void *user_data) static void gfx_widget_progress_message_free(void) { - gfx_widget_progress_message_state_t *state = gfx_widget_progress_message_get_ptr(); + gfx_widget_progress_message_state_t *state = &p_w_progress_message_st; uintptr_t alpha_tag = (uintptr_t)&state->alpha; /* Kill any existing timer / animation */ diff --git a/gfx/widgets/gfx_widget_screenshot.c b/gfx/widgets/gfx_widget_screenshot.c index 1e0ade60da..4b8ef96ba4 100644 --- a/gfx/widgets/gfx_widget_screenshot.c +++ b/gfx/widgets/gfx_widget_screenshot.c @@ -67,17 +67,12 @@ static gfx_widget_screenshot_state_t p_w_screenshot_st = { false /* loaded */ }; -static gfx_widget_screenshot_state_t* gfx_widget_screenshot_get_ptr(void) -{ - return &p_w_screenshot_st; -} - static void gfx_widget_screenshot_fadeout(void *userdata) { gfx_animation_ctx_entry_t entry; settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; entry.cb = NULL; entry.easing_enum = EASING_OUT_QUAD; @@ -105,7 +100,7 @@ static void gfx_widgets_play_screenshot_flash(void *data) gfx_animation_ctx_entry_t entry; settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; entry.cb = gfx_widget_screenshot_fadeout; entry.easing_enum = EASING_IN_QUAD; @@ -134,7 +129,7 @@ void gfx_widget_screenshot_taken( { settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; if (settings->uints.notification_show_screenshot_flash != NOTIFICATION_SHOW_SCREENSHOT_FLASH_OFF) gfx_widgets_play_screenshot_flash(p_dispwidget); @@ -148,7 +143,7 @@ void gfx_widget_screenshot_taken( static void gfx_widget_screenshot_dispose(void *userdata) { - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; state->loaded = false; video_driver_texture_unload(&state->texture); @@ -160,7 +155,7 @@ static void gfx_widget_screenshot_end(void *userdata) gfx_animation_ctx_entry_t entry; settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)userdata; - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; entry.cb = gfx_widget_screenshot_dispose; entry.easing_enum = EASING_OUT_QUAD; @@ -189,7 +184,7 @@ static void gfx_widget_screenshot_end(void *userdata) static void gfx_widget_screenshot_free(void) { - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; state->alpha = 0.0f; gfx_widget_screenshot_dispose(NULL); @@ -209,7 +204,7 @@ static void gfx_widget_screenshot_frame(void* data, void *user_data) unsigned video_height = video_info->height; dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data; gfx_display_t *p_disp = disp_get_ptr(); - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; gfx_widget_font_data_t* font_regular = &p_dispwidget->gfx_widget_fonts.regular; int padding = (state->height - (font_regular->line_height * 2.0f)) / 2.0f; @@ -293,7 +288,7 @@ static void gfx_widget_screenshot_iterate( { settings_t *settings = config_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data; - gfx_widget_screenshot_state_t* state = gfx_widget_screenshot_get_ptr(); + gfx_widget_screenshot_state_t *state = &p_w_screenshot_st; unsigned padding = p_dispwidget->simple_widget_padding; gfx_widget_font_data_t* font_regular = &p_dispwidget->gfx_widget_fonts.regular; diff --git a/gfx/widgets/gfx_widget_volume.c b/gfx/widgets/gfx_widget_volume.c index 0462a4dabd..22e5e629b5 100644 --- a/gfx/widgets/gfx_widget_volume.c +++ b/gfx/widgets/gfx_widget_volume.c @@ -81,11 +81,6 @@ static gfx_widget_volume_state_t p_w_volume_st = { false }; -gfx_widget_volume_state_t* gfx_widget_volume_get_ptr(void) -{ - return &p_w_volume_st; -} - static void gfx_widget_volume_frame(void* data, void *user_data) { static float pure_white[16] = { @@ -94,7 +89,7 @@ static void gfx_widget_volume_frame(void* data, void *user_data) 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, }; - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); + gfx_widget_volume_state_t *state = &p_w_volume_st; if (state->alpha > 0.0f) { @@ -274,8 +269,8 @@ static void gfx_widget_volume_frame(void* data, void *user_data) static void gfx_widget_volume_timer_end(void *userdata) { - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); gfx_animation_ctx_entry_t entry; + gfx_widget_volume_state_t *state = &p_w_volume_st; entry.cb = NULL; entry.duration = MSG_QUEUE_ANIMATION_DURATION; @@ -294,8 +289,8 @@ static void gfx_widget_volume_timer_end(void *userdata) void gfx_widget_volume_update_and_show(float new_volume, bool mute) { - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); gfx_timer_ctx_entry_t entry; + gfx_widget_volume_state_t *state = &p_w_volume_st; gfx_animation_kill_by_tag(&state->tag); @@ -317,7 +312,7 @@ static void gfx_widget_volume_layout( bool is_threaded, const char *dir_assets, char *font_path) { dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data; - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); + gfx_widget_volume_state_t *state = &p_w_volume_st; unsigned last_video_width = p_dispwidget->last_video_width; gfx_widget_font_data_t *font_regular = &p_dispwidget->gfx_widget_fonts.regular; @@ -339,8 +334,8 @@ static void gfx_widget_volume_context_reset(bool is_threaded, char* menu_png_path, char* widgets_png_path) { - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); size_t i; + gfx_widget_volume_state_t *state = &p_w_volume_st; for (i = 0; i < ICON_LAST; i++) gfx_display_reset_textures_list(ICONS_NAMES[i], menu_png_path, &state->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL); @@ -348,8 +343,8 @@ static void gfx_widget_volume_context_reset(bool is_threaded, static void gfx_widget_volume_context_destroy(void) { - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); size_t i; + gfx_widget_volume_state_t *state = &p_w_volume_st; for (i = 0; i < ICON_LAST; i++) video_driver_texture_unload(&state->textures[i]); @@ -357,7 +352,7 @@ static void gfx_widget_volume_context_destroy(void) static void gfx_widget_volume_free(void) { - gfx_widget_volume_state_t* state = gfx_widget_volume_get_ptr(); + gfx_widget_volume_state_t *state = &p_w_volume_st; /* Kill all running animations */ gfx_animation_kill_by_tag(&state->tag);