mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Refactor overlay init/free
This commit is contained in:
parent
53ae4cd72c
commit
7d4b6b23c5
21
driver.c
21
driver.c
@ -1197,18 +1197,8 @@ void init_video_input(void)
|
||||
}
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
{
|
||||
input_overlay_free(driver.overlay);
|
||||
driver.overlay = NULL;
|
||||
}
|
||||
|
||||
if (*g_settings.input.overlay)
|
||||
{
|
||||
driver.overlay = input_overlay_new(g_settings.input.overlay);
|
||||
if (!driver.overlay)
|
||||
RARCH_ERR("Failed to load overlay.\n");
|
||||
}
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_INIT);
|
||||
#endif
|
||||
|
||||
g_extern.measure_data.frame_time_samples_count = 0;
|
||||
@ -1217,12 +1207,7 @@ void init_video_input(void)
|
||||
void uninit_video_input(void)
|
||||
{
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
{
|
||||
input_overlay_free(driver.overlay);
|
||||
driver.overlay = NULL;
|
||||
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
|
||||
}
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
#endif
|
||||
|
||||
if (!driver.input_data_own && driver.input_data != driver.video_data && driver.input && driver.input->free)
|
||||
|
@ -3704,9 +3704,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
|
||||
menu_common_setting_push_current_menu(driver.menu->menu_stack, g_extern.overlay_dir, setting, driver.menu->selection_ptr, action);
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
if (driver.overlay)
|
||||
input_overlay_free(driver.overlay);
|
||||
driver.overlay = NULL;
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
*g_settings.input.overlay = '\0';
|
||||
break;
|
||||
default:
|
||||
|
@ -104,6 +104,8 @@ enum basic_event
|
||||
RARCH_CMD_AUTOSAVE,
|
||||
RARCH_CMD_AUDIO_STOP,
|
||||
RARCH_CMD_AUDIO_START,
|
||||
RARCH_CMD_OVERLAY_INIT,
|
||||
RARCH_CMD_OVERLAY_FREE,
|
||||
};
|
||||
|
||||
enum menu_enums
|
||||
|
18
retroarch.c
18
retroarch.c
@ -3211,6 +3211,24 @@ void rarch_main_command(unsigned action)
|
||||
g_extern.audio_active = false;
|
||||
}
|
||||
break;
|
||||
case RARCH_CMD_OVERLAY_INIT:
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (*g_settings.input.overlay && g_settings.input.overlay[0] != '\0')
|
||||
{
|
||||
driver.overlay = input_overlay_new(g_settings.input.overlay);
|
||||
if (!driver.overlay)
|
||||
RARCH_ERR("Failed to load overlay.\n");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_OVERLAY_FREE:
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
input_overlay_free(driver.overlay);
|
||||
driver.overlay = NULL;
|
||||
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -977,9 +977,11 @@ static void general_read_handler(const void *data)
|
||||
|
||||
static void general_write_handler(const void *data)
|
||||
{
|
||||
bool has_set_reinit = false;
|
||||
bool has_set_rewind = false;
|
||||
bool has_set_autosave = false;
|
||||
bool has_set_reinit = false;
|
||||
bool has_set_rewind = false;
|
||||
bool has_set_autosave = false;
|
||||
bool has_set_overlay_init = false;
|
||||
bool has_set_overlay_free = false;
|
||||
const rarch_setting_t *setting = (const rarch_setting_t*)data;
|
||||
|
||||
if (!setting)
|
||||
@ -1144,11 +1146,8 @@ static void general_write_handler(const void *data)
|
||||
{
|
||||
strlcpy(g_settings.input.overlay, setting->value.string, sizeof(g_settings.input.overlay));
|
||||
|
||||
if (driver.overlay)
|
||||
input_overlay_free(driver.overlay);
|
||||
|
||||
if (g_settings.input.overlay && g_settings.input.overlay[0] != '\0')
|
||||
driver.overlay = input_overlay_new(g_settings.input.overlay);
|
||||
has_set_overlay_free = false;
|
||||
has_set_overlay_init = true;
|
||||
}
|
||||
else if (!strcmp(setting->name, "input_overlay_scale"))
|
||||
{
|
||||
@ -1338,6 +1337,10 @@ static void general_write_handler(const void *data)
|
||||
rarch_main_command(RARCH_CMD_REWIND);
|
||||
if (has_set_autosave)
|
||||
rarch_main_command(RARCH_CMD_AUTOSAVE);
|
||||
if (has_set_overlay_free)
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
if (has_set_overlay_init)
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_INIT);
|
||||
}
|
||||
|
||||
#define NEXT (list[index++])
|
||||
|
Loading…
Reference in New Issue
Block a user