Move widgets_active to retroarch.c

This commit is contained in:
twinaphex 2020-06-08 04:32:54 +02:00
parent d9565b6619
commit 73b5bf438b
3 changed files with 36 additions and 39 deletions

View File

@ -140,7 +140,6 @@ typedef struct menu_widget_msg
typedef struct dispgfx_widget typedef struct dispgfx_widget
{ {
bool widgets_active;
/* There can only be one message animation at a time to /* There can only be one message animation at a time to
* avoid confusing users */ * avoid confusing users */
bool widgets_moving; bool widgets_moving;
@ -332,12 +331,6 @@ void *dispwidget_get_ptr(void)
return &dispwidget_st; return &dispwidget_st;
} }
bool gfx_widgets_active(void)
{
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr();
return p_dispwidget->widgets_active;
}
void gfx_widgets_set_persistence(bool persist) void gfx_widgets_set_persistence(bool persist)
{ {
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr();
@ -1630,7 +1623,8 @@ void gfx_widgets_frame(void *data)
#endif #endif
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr(); dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)dispwidget_get_ptr();
if (!p_dispwidget->widgets_active) /* TODO/FIXME - find something better */
if (!gfx_widgets_ready())
return; return;
/* ...but assigning them costs a tiny amount, /* ...but assigning them costs a tiny amount,
@ -2026,7 +2020,7 @@ void gfx_widgets_frame(void *data)
gfx_display_unset_viewport(video_width, video_height); gfx_display_unset_viewport(video_width, video_height);
} }
bool gfx_widgets_init( bool gfx_widgets_init(uintptr_t widgets_active_ptr,
bool video_is_threaded, bool video_is_threaded,
unsigned width, unsigned height, bool fullscreen, unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path) const char *dir_assets, char *font_path)
@ -2037,8 +2031,8 @@ bool gfx_widgets_init(
p_dispwidget->cheevo_popup_queue_read_index = -1; p_dispwidget->cheevo_popup_queue_read_index = -1;
#endif #endif
p_dispwidget->divider_width_1px = 1; p_dispwidget->divider_width_1px = 1;
p_dispwidget->gfx_widgets_generic_tag = (uintptr_t) p_dispwidget->gfx_widgets_generic_tag = (uintptr_t)widgets_active_ptr;
&p_dispwidget->widgets_active;
if (!gfx_display_init_first_driver(video_is_threaded)) if (!gfx_display_init_first_driver(video_is_threaded))
goto error; goto error;
@ -2081,8 +2075,6 @@ bool gfx_widgets_init(
width, height, fullscreen, width, height, fullscreen,
dir_assets, font_path); dir_assets, font_path);
p_dispwidget->widgets_active = true;
return true; return true;
error: error:
@ -2096,7 +2088,6 @@ bool gfx_widgets_deinit(void)
if (!p_dispwidget->widgets_inited) if (!p_dispwidget->widgets_inited)
return false; return false;
p_dispwidget->widgets_active = false;
gfx_widgets_context_destroy(p_dispwidget); gfx_widgets_context_destroy(p_dispwidget);
if (!p_dispwidget->widgets_persisting) if (!p_dispwidget->widgets_persisting)
@ -2463,7 +2454,6 @@ static void gfx_widgets_free(dispgfx_widget_t *p_dispwidget)
size_t i; size_t i;
p_dispwidget->widgets_inited = false; p_dispwidget->widgets_inited = false;
p_dispwidget->widgets_active = false;
for (i = 0; i < ARRAY_SIZE(widgets); i++) for (i = 0; i < ARRAY_SIZE(widgets); i++)
{ {

View File

@ -159,10 +159,10 @@ void gfx_widgets_flush_text(
typedef struct gfx_widget gfx_widget_t; typedef struct gfx_widget gfx_widget_t;
bool gfx_widgets_active(void);
void gfx_widgets_set_persistence(bool persist); void gfx_widgets_set_persistence(bool persist);
bool gfx_widgets_init( bool gfx_widgets_init(
uintptr_t widgets_active_ptr,
bool video_is_threaded, bool video_is_threaded,
unsigned width, unsigned height, bool fullscreen, unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path); const char *dir_assets, char *font_path);

View File

@ -1825,6 +1825,9 @@ struct rarch_state
enum overlay_visibility *overlay_visibility; enum overlay_visibility *overlay_visibility;
#endif #endif
#ifdef HAVE_GFX_WIDGETS
bool widgets_active;
#endif
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
/* Only used before init_netplay */ /* Only used before init_netplay */
bool netplay_enabled; bool netplay_enabled;
@ -10600,7 +10603,8 @@ static bool is_accessibility_enabled(struct rarch_state *p_rarch)
bool gfx_widgets_ready(void) bool gfx_widgets_ready(void)
{ {
#ifdef HAVE_GFX_WIDGETS #ifdef HAVE_GFX_WIDGETS
return gfx_widgets_active(); struct rarch_state *p_rarch = &rarch_st;
return p_rarch->widgets_active;
#else #else
return false; return false;
#endif #endif
@ -11194,7 +11198,7 @@ bool retroarch_apply_shader(
msg_hash_to_str(MSG_SHADER), msg_hash_to_str(MSG_SHADER),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE)); msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE));
#ifdef HAVE_GFX_WIDGETS #ifdef HAVE_GFX_WIDGETS
if (gfx_widgets_active()) if (p_rarch->widgets_active)
gfx_widget_set_message(msg); gfx_widget_set_message(msg);
else else
#endif #endif
@ -12951,7 +12955,7 @@ static void command_event_set_volume(struct rarch_state *p_rarch, float gain)
new_volume); new_volume);
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
if (gfx_widgets_active()) if (p_rarch->widgets_active)
gfx_widget_volume_update_and_show(new_volume, gfx_widget_volume_update_and_show(new_volume,
p_rarch->audio_driver_mute_enable); p_rarch->audio_driver_mute_enable);
else else
@ -13974,7 +13978,7 @@ static void retroarch_pause_checks(struct rarch_state *p_rarch)
bool is_paused = p_rarch->runloop_paused; bool is_paused = p_rarch->runloop_paused;
bool is_idle = p_rarch->runloop_idle; bool is_idle = p_rarch->runloop_idle;
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
bool widgets_active = gfx_widgets_active(); bool widgets_active = p_rarch->widgets_active;
if (widgets_active) if (widgets_active)
p_rarch->gfx_widgets_paused = is_paused; p_rarch->gfx_widgets_paused = is_paused;
@ -14536,7 +14540,7 @@ bool command_event(enum event_command cmd, void *data)
!p_rarch->audio_driver_mute_enable; !p_rarch->audio_driver_mute_enable;
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
if (gfx_widgets_active()) if (p_rarch->widgets_active)
gfx_widget_volume_update_and_show( gfx_widget_volume_update_and_show(
settings->floats.audio_volume, settings->floats.audio_volume,
p_rarch->audio_driver_mute_enable); p_rarch->audio_driver_mute_enable);
@ -17233,7 +17237,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
const struct retro_message *msg = (const struct retro_message*)data; const struct retro_message *msg = (const struct retro_message*)data;
RARCH_LOG("[Environ]: SET_MESSAGE: %s\n", msg->msg); RARCH_LOG("[Environ]: SET_MESSAGE: %s\n", msg->msg);
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
if (gfx_widgets_active()) if (p_rarch->widgets_active)
gfx_widget_set_libretro_message(dispwidget_get_ptr(), gfx_widget_set_libretro_message(dispwidget_get_ptr(),
msg->msg, msg->msg,
roundf((float)msg->frames / 60.0f * 1000.0f)); roundf((float)msg->frames / 60.0f * 1000.0f));
@ -17324,8 +17328,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
/* Handle 'alternate' non-queued notifications */ /* Handle 'alternate' non-queued notifications */
case RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: case RETRO_MESSAGE_TYPE_NOTIFICATION_ALT:
if (p_rarch->widgets_active)
if (gfx_widgets_active())
gfx_widget_set_libretro_message(dispwidget_get_ptr(), gfx_widget_set_libretro_message(dispwidget_get_ptr(),
msg->msg, msg->duration); msg->msg, msg->duration);
else else
@ -17340,8 +17343,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
* implement a separate 'progress bar' widget to * implement a separate 'progress bar' widget to
* handle these correctly */ * handle these correctly */
case RETRO_MESSAGE_TYPE_PROGRESS: case RETRO_MESSAGE_TYPE_PROGRESS:
if (p_rarch->widgets_active)
if (gfx_widgets_active())
gfx_widget_set_libretro_message(dispwidget_get_ptr(), gfx_widget_set_libretro_message(dispwidget_get_ptr(),
msg->msg, msg->duration); msg->msg, msg->duration);
else else
@ -30425,15 +30427,15 @@ static void video_driver_frame(const void *data, unsigned width,
static float last_fps, frame_time; static float last_fps, frame_time;
retro_time_t new_time; retro_time_t new_time;
video_frame_info_t video_info; video_frame_info_t video_info;
#if defined(HAVE_GFX_WIDGETS)
bool widgets_active;
#endif
struct rarch_state *p_rarch = &rarch_st; struct rarch_state *p_rarch = &rarch_st;
const enum retro_pixel_format const enum retro_pixel_format
video_driver_pix_fmt = p_rarch->video_driver_pix_fmt; video_driver_pix_fmt = p_rarch->video_driver_pix_fmt;
bool runloop_idle = p_rarch->runloop_idle; bool runloop_idle = p_rarch->runloop_idle;
bool video_driver_active = p_rarch->video_driver_active; bool video_driver_active = p_rarch->video_driver_active;
settings_t *settings = p_rarch->configuration_settings; settings_t *settings = p_rarch->configuration_settings;
#if defined(HAVE_GFX_WIDGETS)
bool widgets_active = p_rarch->widgets_active;
#endif
fps_text[0] = '\0'; fps_text[0] = '\0';
video_driver_msg[0] = '\0'; video_driver_msg[0] = '\0';
@ -30442,9 +30444,6 @@ static void video_driver_frame(const void *data, unsigned width,
return; return;
new_time = cpu_features_get_time_usec(); new_time = cpu_features_get_time_usec();
#if defined(HAVE_GFX_WIDGETS)
widgets_active = gfx_widgets_active();
#endif
if (data) if (data)
p_rarch->frame_cache_data = data; p_rarch->frame_cache_data = data;
@ -30657,8 +30656,8 @@ static void video_driver_frame(const void *data, unsigned width,
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
if (widgets_active) if (widgets_active)
{ {
bool msg_found = false;
msg_queue_entry_t msg_entry; msg_queue_entry_t msg_entry;
bool msg_found = false;
RUNLOOP_MSG_QUEUE_LOCK(); RUNLOOP_MSG_QUEUE_LOCK();
msg_found = msg_queue_extract( msg_found = msg_queue_extract(
@ -32416,7 +32415,9 @@ static void drivers_init(struct rarch_state *p_rarch, int flags)
bool video_is_fullscreen = settings->bools.video_fullscreen || bool video_is_fullscreen = settings->bools.video_fullscreen ||
rarch_force_fullscreen; rarch_force_fullscreen;
gfx_widgets_init(video_is_threaded, p_rarch->widgets_active = gfx_widgets_init(
(uintptr_t)&p_rarch->widgets_active,
video_is_threaded,
p_rarch->video_driver_width, p_rarch->video_driver_width,
p_rarch->video_driver_height, p_rarch->video_driver_height,
video_is_fullscreen, video_is_fullscreen,
@ -32494,7 +32495,8 @@ static void driver_uninit(struct rarch_state *p_rarch, int flags)
/* This absolutely has to be done before video_driver_free_internal() /* This absolutely has to be done before video_driver_free_internal()
* is called/completes, otherwise certain menu drivers * is called/completes, otherwise certain menu drivers
* (e.g. Vulkan) will segfault */ * (e.g. Vulkan) will segfault */
gfx_widgets_deinit(); if (gfx_widgets_deinit())
p_rarch->widgets_active = false;
#endif #endif
#ifdef HAVE_MENU #ifdef HAVE_MENU
@ -32560,7 +32562,8 @@ static void retroarch_deinit_drivers(struct rarch_state *p_rarch)
* in case the handle is lost in the threaded * in case the handle is lost in the threaded
* video driver in the meantime * video driver in the meantime
* (breaking video_driver_has_widgets) */ * (breaking video_driver_has_widgets) */
gfx_widgets_deinit(); if (gfx_widgets_deinit())
p_rarch->widgets_active = false;
#endif #endif
/* Video */ /* Video */
@ -34885,8 +34888,9 @@ static void runloop_task_msg_queue_push(
{ {
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
struct rarch_state *p_rarch = &rarch_st; struct rarch_state *p_rarch = &rarch_st;
bool widgets_active = p_rarch->widgets_active;
if (gfx_widgets_active() && task->title && !task->mute) if (widgets_active && task->title && !task->mute)
{ {
RUNLOOP_MSG_QUEUE_LOCK(); RUNLOOP_MSG_QUEUE_LOCK();
ui_companion_driver_msg_queue_push(p_rarch, msg, ui_companion_driver_msg_queue_push(p_rarch, msg,
@ -35873,6 +35877,9 @@ void runloop_msg_queue_push(const char *msg,
enum message_queue_category category) enum message_queue_category category)
{ {
struct rarch_state *p_rarch = &rarch_st; struct rarch_state *p_rarch = &rarch_st;
#if defined(HAVE_GFX_WIDGETS)
bool widgets_active = p_rarch->widgets_active;
#endif
RUNLOOP_MSG_QUEUE_LOCK(); RUNLOOP_MSG_QUEUE_LOCK();
#ifdef HAVE_ACCESSIBILITY #ifdef HAVE_ACCESSIBILITY
@ -35880,7 +35887,7 @@ void runloop_msg_queue_push(const char *msg,
accessibility_speak_priority(p_rarch, (char*) msg, 0); accessibility_speak_priority(p_rarch, (char*) msg, 0);
#endif #endif
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
if (gfx_widgets_active()) if (widgets_active)
{ {
gfx_widgets_msg_queue_push(NULL, msg, gfx_widgets_msg_queue_push(NULL, msg,
roundf((float)duration / 60.0f * 1000.0f), roundf((float)duration / 60.0f * 1000.0f),
@ -36126,7 +36133,7 @@ static enum runloop_state runloop_check_state(
bool display_kb = menu_input_dialog_get_display_kb(); bool display_kb = menu_input_dialog_get_display_kb();
#endif #endif
#if defined(HAVE_GFX_WIDGETS) #if defined(HAVE_GFX_WIDGETS)
bool widgets_active = gfx_widgets_active(); bool widgets_active = p_rarch->widgets_active;
#endif #endif
#if defined(HAVE_TRANSLATE) && defined(HAVE_GFX_WIDGETS) #if defined(HAVE_TRANSLATE) && defined(HAVE_GFX_WIDGETS)