Overlay Caching

Adds overlay_cache_ptr to keep a disabled overlay in memory when it's expected to be shown again.

Most input_overlay_deinit calls are replaced with input_overlay_unload, which caches the overlay unless initing/deiniting core or disabling overlays.

Loading a cached overlay is done as a swap, intended for osk_toggle.

Related updates:
- Fewer parameters for the overlay loading task. Use current settings when enabling an overlay
- Add input_overlay_check_mouse_cursor() to preserve show/hide mouse behavior
- Don't apply input_overlay_show_mouse_cursor in windowed mode (controlled by mouse grab only)
- Remove some dead code
This commit is contained in:
nfore 2023-07-08 08:43:25 -05:00 committed by LibretroAdmin
parent a54f481935
commit 8a81d39437
11 changed files with 263 additions and 251 deletions

View file

@ -109,8 +109,8 @@ enum event_command
CMD_EVENT_STATISTICS_TOGGLE,
/* Initializes overlay. */
CMD_EVENT_OVERLAY_INIT,
/* Deinitializes overlay. */
CMD_EVENT_OVERLAY_DEINIT,
/* Frees or caches overlay. */
CMD_EVENT_OVERLAY_UNLOAD,
/* Sets current scale factor for overlay. */
CMD_EVENT_OVERLAY_SET_SCALE_FACTOR,
/* Sets current alpha modulation for overlay. */

View file

@ -1461,7 +1461,7 @@ void video_driver_free_internal(void)
bool is_threaded = VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st);
#endif
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
command_event(CMD_EVENT_OVERLAY_UNLOAD, NULL);
if (!(video_st->flags & VIDEO_FLAG_CACHE_CONTEXT))
video_driver_free_hw_context();
@ -3178,7 +3178,7 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
return false;
#ifdef HAVE_OVERLAY
input_overlay_deinit();
input_overlay_unload();
input_overlay_init();
#endif
@ -3225,6 +3225,10 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
input_st->flags |= INP_FLAG_GRAB_MOUSE_STATE;
}
#ifdef HAVE_OVERLAY
input_overlay_check_mouse_cursor();
#endif
return true;
}

View file

@ -2574,9 +2574,15 @@ static void input_overlay_free(input_overlay_t *ol)
input_overlay_free_overlays(ol);
if (ol->iface->enable)
if (ol->iface && ol->iface->enable)
ol->iface->enable(ol->iface_data, false);
if (ol->path)
{
free(ol->path);
ol->path = NULL;
}
free(ol);
}
@ -4319,10 +4325,132 @@ void input_game_focus_free(void)
}
#ifdef HAVE_OVERLAY
void input_overlay_deinit(void)
static bool video_driver_overlay_interface(
const video_overlay_interface_t **iface)
{
video_driver_state_t *video_st = video_state_get_ptr();
if (!video_st->current_video || !video_st->current_video->overlay_interface)
return false;
video_st->current_video->overlay_interface(video_st->data, iface);
return true;
}
static void input_overlay_enable_(bool enable)
{
settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
input_overlay_t *ol = input_st->overlay_ptr;
float opacity = settings->floats.input_overlay_opacity;
bool auto_rotate = settings->bools.input_overlay_auto_rotate;
bool hide_mouse_cursor = !settings->bools.input_overlay_show_mouse_cursor
&& (input_st->flags & INP_FLAG_GRAB_MOUSE_STATE);
if (!ol)
return;
if (enable)
{
/* Set video interface */
ol->iface_data = video_st->data;
if (!video_driver_overlay_interface(&ol->iface) || !ol->iface)
{
RARCH_ERR("Overlay interface is not present in video driver.\n");
ol->flags &= ~INPUT_OVERLAY_ALIVE;
return;
}
/* Load last-active overlay */
input_overlay_load_active(input_st->overlay_visibility, ol, opacity);
/* Adjust to current settings */
command_event(CMD_EVENT_OVERLAY_SET_SCALE_FACTOR, NULL);
if (auto_rotate)
input_overlay_auto_rotate_(
video_st->width, video_st->height, true, ol);
/* Enable */
if (ol->iface->enable)
ol->iface->enable(ol->iface_data, true);
ol->flags |= (INPUT_OVERLAY_ENABLE | INPUT_OVERLAY_BLOCKED);
if ( hide_mouse_cursor
&& video_st->poke
&& video_st->poke->show_mouse)
video_st->poke->show_mouse(video_st->data, false);
}
else
{
/* Disable and clear input state */
ol->flags &= ~INPUT_OVERLAY_ENABLE;
if (ol->iface && ol->iface->enable)
ol->iface->enable(ol->iface_data, false);
ol->iface = NULL;
memset(&ol->overlay_state, 0, sizeof(input_overlay_state_t));
}
}
static void input_overlay_deinit(void)
{
input_overlay_free(input_driver_st.overlay_ptr);
input_driver_st.overlay_ptr = NULL;
input_overlay_free(input_driver_st.overlay_cache_ptr);
input_driver_st.overlay_cache_ptr = NULL;
}
static void input_overlay_move_to_cache(void)
{
input_driver_state_t *input_st = &input_driver_st;
input_overlay_t *ol = input_st->overlay_ptr;
if (!ol)
return;
/* Free existing cache */
input_overlay_free(input_driver_st.overlay_cache_ptr);
/* Disable current overlay */
input_overlay_enable_(false);
/* Move to cache */
input_st->overlay_cache_ptr = ol;
input_st->overlay_ptr = NULL;
}
static void input_overlay_swap_with_cached(void)
{
input_driver_state_t *input_st = &input_driver_st;
input_overlay_t *ol;
/* Disable current overlay */
input_overlay_enable_(false);
/* Swap with cached */
ol = input_st->overlay_cache_ptr;
input_st->overlay_cache_ptr = input_st->overlay_ptr;
input_st->overlay_ptr = ol;
/* Enable and update to current settings */
input_overlay_enable_(true);
}
void input_overlay_unload(void)
{
settings_t *settings = config_get_ptr();
runloop_state_t *runloop_st = runloop_state_get_ptr();
/* Free if overlays disabled or initing/deiniting core */
if ( !settings->bools.input_overlay_enable
|| !(runloop_st->flags & RUNLOOP_FLAG_IS_INITED)
|| (runloop_st->flags & RUNLOOP_FLAG_SHUTDOWN_INITIATED))
input_overlay_deinit();
else
input_overlay_move_to_cache();
}
void input_overlay_set_visibility(int overlay_idx,
@ -4349,14 +4477,37 @@ void input_overlay_set_visibility(int overlay_idx,
ol->iface->set_alpha(ol->iface_data, overlay_idx, 0.0);
}
static bool video_driver_overlay_interface(
const video_overlay_interface_t **iface)
static bool input_overlay_want_hidden(void)
{
settings_t *settings = config_get_ptr();
bool hide = false;
#ifdef HAVE_MENU
if (settings->bools.input_overlay_hide_in_menu)
hide = (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE) != 0;
#endif
if (settings->bools.input_overlay_hide_when_gamepad_connected)
hide = hide || (input_config_get_device_name(0) != NULL);
return hide;
}
void input_overlay_check_mouse_cursor(void)
{
settings_t *settings = config_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
video_driver_state_t *video_st = video_state_get_ptr();
if (!video_st->current_video || !video_st->current_video->overlay_interface)
return false;
video_st->current_video->overlay_interface(video_st->data, iface);
return true;
input_overlay_t *ol = input_st->overlay_ptr;
if ( ol && (ol->flags & INPUT_OVERLAY_ENABLE)
&& video_st->poke
&& video_st->poke->show_mouse)
{
if (settings->bools.input_overlay_show_mouse_cursor)
video_st->poke->show_mouse(video_st->data, true);
else if (input_st->flags & INP_FLAG_GRAB_MOUSE_STATE)
video_st->poke->show_mouse(video_st->data, false);
}
}
/* task_data = overlay_task_data_t* */
@ -4364,186 +4515,105 @@ static void input_overlay_loaded(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
size_t i;
overlay_task_data_t *data = (overlay_task_data_t*)task_data;
input_overlay_t *ol = NULL;
const video_overlay_interface_t *iface = NULL;
settings_t *settings = config_get_ptr();
bool input_overlay_show_mouse_cursor = settings->bools.input_overlay_show_mouse_cursor;
bool inp_overlay_auto_rotate = settings->bools.input_overlay_auto_rotate;
bool input_overlay_enable = settings->bools.input_overlay_enable;
video_driver_state_t *video_st = video_state_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
settings_t *settings = config_get_ptr();
overlay_task_data_t *data = (overlay_task_data_t*)task_data;
input_overlay_t *ol = NULL;
input_driver_state_t *input_st = &input_driver_st;
#ifdef HAVE_MENU
struct menu_state *menu_st = menu_state_get_ptr();
#endif
bool enable_overlay = !input_overlay_want_hidden()
&& settings->bools.input_overlay_enable;
uint16_t overlay_types;
if (err)
return;
if (data->flags & OVERLAY_LOADER_ENABLE)
{
#ifdef HAVE_MENU
struct menu_state *menu_st = menu_state_get_ptr();
ol = (input_overlay_t*)calloc(1, sizeof(*ol));
ol->overlays = data->overlays;
ol->size = data->size;
ol->active = data->active;
ol->path = data->overlay_path;
ol->next_index = (unsigned)((ol->index + 1) % ol->size);
ol->flags |= INPUT_OVERLAY_ALIVE;
overlay_types = data->overlay_types;
/* Update menu entries */
if (menu_st->overlay_types != data->overlay_types)
{
menu_st->overlay_types = data->overlay_types;
menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH;
}
/* We can't display when the menu is up */
if ( (data->flags & OVERLAY_LOADER_HIDE_IN_MENU)
&& (menu_st->flags & MENU_ST_FLAG_ALIVE))
goto abort_load;
#endif
/* If 'hide_when_gamepad_connected' is enabled,
* we can't display when a gamepad is connected */
if ( (data->flags & OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED)
&& (input_config_get_device_name(0) != NULL))
goto abort_load;
}
if ( !(data->flags & OVERLAY_LOADER_ENABLE)
|| !video_driver_overlay_interface(&iface)
|| !iface)
{
RARCH_ERR("Overlay interface is not present in video driver,"
" or not enabled.\n");
goto abort_load;
}
ol = (input_overlay_t*)calloc(1, sizeof(*ol));
ol->overlays = data->overlays;
ol->size = data->size;
ol->active = data->active;
ol->iface = iface;
ol->iface_data = video_st->data;
input_overlay_load_active(input_st->overlay_visibility,
ol, data->overlay_opacity);
/* Enable or disable the overlay. */
if (data->flags & OVERLAY_LOADER_ENABLE)
ol->flags |= INPUT_OVERLAY_ENABLE;
else
ol->flags &= ~INPUT_OVERLAY_ENABLE;
if (ol->iface->enable)
ol->iface->enable(ol->iface_data, (ol->flags & INPUT_OVERLAY_ENABLE));
input_overlay_set_scale_factor(ol, &data->layout_desc,
video_st->width, video_st->height);
ol->next_index = (unsigned)((ol->index + 1) % ol->size);
ol->state = OVERLAY_STATUS_NONE;
ol->flags |= INPUT_OVERLAY_ALIVE;
free(data);
/* Due to the asynchronous nature of overlay loading
* it is possible for overlay_ptr to be non-NULL here
* > Ensure it is free()'d before assigning new pointer */
if (input_st->overlay_ptr)
{
input_overlay_free_overlays(input_st->overlay_ptr);
free(input_st->overlay_ptr);
}
input_overlay_free(input_st->overlay_ptr);
input_st->overlay_ptr = ol;
free(data);
/* Enable or disable the overlay */
input_overlay_enable_(enable_overlay);
if (!input_overlay_show_mouse_cursor)
/* Abort if enable failed */
if (!(ol->flags & INPUT_OVERLAY_ALIVE))
{
if ( video_st->poke
&& video_st->poke->show_mouse)
video_st->poke->show_mouse(video_st->data, false);
input_st->overlay_ptr = NULL;
input_overlay_free(ol);
return;
}
/* Attempt to automatically rotate overlay, if required */
if (inp_overlay_auto_rotate)
input_overlay_auto_rotate_(
video_st->width,
video_st->height,
input_overlay_enable,
input_st->overlay_ptr);
/* Cache or free if hidden */
if (!enable_overlay)
input_overlay_unload();
input_overlay_set_eightway_diagonal_sensitivity();
return;
abort_load:
for (i = 0; i < data->size; i++)
input_overlay_free_overlay(&data->overlays[i]);
free(data->overlays);
free(data);
#ifdef HAVE_MENU
/* Update menu entries */
if (menu_st->overlay_types != overlay_types)
{
menu_st->overlay_types = overlay_types;
menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH;
}
#endif
}
void input_overlay_init(void)
{
settings_t *settings = config_get_ptr();
bool input_overlay_enable = settings->bools.input_overlay_enable;
bool input_overlay_auto_scale = settings->bools.input_overlay_auto_scale;
const char *path_overlay = settings->paths.path_overlay;
float overlay_opacity = settings->floats.input_overlay_opacity;
float overlay_scale_landscape = settings->floats.input_overlay_scale_landscape;
float overlay_aspect_adjust_landscape = settings->floats.input_overlay_aspect_adjust_landscape;
float overlay_x_separation_landscape = settings->floats.input_overlay_x_separation_landscape;
float overlay_y_separation_landscape = settings->floats.input_overlay_y_separation_landscape;
float overlay_x_offset_landscape = settings->floats.input_overlay_x_offset_landscape;
float overlay_y_offset_landscape = settings->floats.input_overlay_y_offset_landscape;
float overlay_scale_portrait = settings->floats.input_overlay_scale_portrait;
float overlay_aspect_adjust_portrait = settings->floats.input_overlay_aspect_adjust_portrait;
float overlay_x_separation_portrait = settings->floats.input_overlay_x_separation_portrait;
float overlay_y_separation_portrait = settings->floats.input_overlay_y_separation_portrait;
float overlay_x_offset_portrait = settings->floats.input_overlay_x_offset_portrait;
float overlay_y_offset_portrait = settings->floats.input_overlay_y_offset_portrait;
float overlay_touch_scale = (float)settings->uints.input_touch_scale;
settings_t *settings = config_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
input_overlay_t *ol = input_st->overlay_ptr;
input_overlay_t *ol_cache = input_st->overlay_cache_ptr;
const char *path_overlay = settings->paths.path_overlay;
bool want_hidden = input_overlay_want_hidden();
bool overlay_shown = ol
&& (ol->flags & INPUT_OVERLAY_ENABLE)
&& string_is_equal(path_overlay, ol->path);
bool overlay_cached = ol_cache
&& (ol_cache->flags & INPUT_OVERLAY_ALIVE)
&& string_is_equal(path_overlay, ol_cache->path);
bool overlay_hidden = !ol && overlay_cached;
bool load_enabled = input_overlay_enable;
#ifdef HAVE_MENU
bool overlay_hide_in_menu = settings->bools.input_overlay_hide_in_menu;
#else
bool overlay_hide_in_menu = false;
#endif
bool overlay_hide_when_gamepad_connected = settings->bools.input_overlay_hide_when_gamepad_connected;
#if defined(GEKKO)
/* Avoid a crash at startup or even when toggling overlay in rgui */
if (frontend_driver_get_free_memory() < (3 * 1024 * 1024))
return;
#endif
/* Cancel if overlays disabled or task already done */
if ( !settings->bools.input_overlay_enable
|| ( want_hidden && overlay_hidden)
|| (!want_hidden && overlay_shown))
return;
/* Restore if cached */
if (!want_hidden && overlay_cached)
{
input_overlay_swap_with_cached();
return;
}
input_overlay_deinit();
/* Cancel load if 'hide_when_gamepad_connected' is
* enabled and a gamepad is currently connected */
if (overlay_hide_when_gamepad_connected)
load_enabled = load_enabled && (input_config_get_device_name(0) == NULL);
if (load_enabled)
{
overlay_layout_desc_t layout_desc;
layout_desc.scale_landscape = overlay_scale_landscape;
layout_desc.aspect_adjust_landscape = overlay_aspect_adjust_landscape;
layout_desc.x_separation_landscape = overlay_x_separation_landscape;
layout_desc.y_separation_landscape = overlay_y_separation_landscape;
layout_desc.x_offset_landscape = overlay_x_offset_landscape;
layout_desc.y_offset_landscape = overlay_y_offset_landscape;
layout_desc.scale_portrait = overlay_scale_portrait;
layout_desc.aspect_adjust_portrait = overlay_aspect_adjust_portrait;
layout_desc.x_separation_portrait = overlay_x_separation_portrait;
layout_desc.y_separation_portrait = overlay_y_separation_portrait;
layout_desc.x_offset_portrait = overlay_x_offset_portrait;
layout_desc.y_offset_portrait = overlay_y_offset_portrait;
layout_desc.touch_scale = overlay_touch_scale;
layout_desc.auto_scale = input_overlay_auto_scale;
task_push_overlay_load_default(input_overlay_loaded,
path_overlay,
overlay_hide_in_menu,
overlay_hide_when_gamepad_connected,
input_overlay_enable,
overlay_opacity,
&layout_desc,
NULL);
}
/* Start task */
task_push_overlay_load_default(
input_overlay_loaded, path_overlay, NULL);
}
#endif

View file

@ -515,6 +515,7 @@ typedef struct
#endif
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_ptr;
input_overlay_t *overlay_cache_ptr;
enum overlay_visibility *overlay_visibility;
float overlay_eightway_dpad_slopes[2];
float overlay_eightway_abxy_slopes[2];
@ -996,9 +997,11 @@ void input_driver_deinit_command(input_driver_state_t *input_st);
#endif
#ifdef HAVE_OVERLAY
void input_overlay_deinit(void);
void input_overlay_unload(void);
void input_overlay_init(void);
void input_overlay_check_mouse_cursor(void);
#endif
#ifdef HAVE_BSV_MOVIE

View file

@ -100,10 +100,7 @@ enum overlay_show_input_type
enum OVERLAY_LOADER_FLAGS
{
OVERLAY_LOADER_ENABLE = (1 << 0),
OVERLAY_LOADER_HIDE_IN_MENU = (1 << 1),
OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED = (1 << 2),
OVERLAY_LOADER_RGBA_SUPPORT = (1 << 3)
OVERLAY_LOADER_RGBA_SUPPORT = (1 << 0)
};
enum INPUT_OVERLAY_FLAGS
@ -291,6 +288,7 @@ struct input_overlay
{
struct overlay *overlays;
const struct overlay *active;
char *path;
void *iface_data;
const video_overlay_interface_t *iface;
input_overlay_state_t overlay_state;
@ -300,8 +298,6 @@ struct input_overlay
unsigned next_index;
enum overlay_status state;
uint8_t flags;
};
@ -344,11 +340,10 @@ typedef struct input_overlay input_overlay_t;
typedef struct
{
char *overlay_path;
struct overlay *overlays;
struct overlay *active;
size_t size;
float overlay_opacity;
overlay_layout_desc_t layout_desc;
uint16_t overlay_types;
uint8_t flags;
} overlay_task_data_t;

View file

@ -6307,7 +6307,7 @@ void retroarch_menu_running(void)
#ifdef HAVE_OVERLAY
if (input_overlay_hide_in_menu)
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
command_event(CMD_EVENT_OVERLAY_UNLOAD, NULL);
#endif
}

View file

@ -8666,48 +8666,18 @@ static void preempt_change_handler(rarch_setting_t *setting)
#ifdef HAVE_OVERLAY
static void overlay_enable_toggle_change_handler(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
bool input_overlay_hide_in_menu = settings ? settings->bools.input_overlay_hide_in_menu : false;
(void)setting;
if (!setting)
return;
if (input_overlay_hide_in_menu)
{
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
return;
}
if (setting->value.target.boolean)
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
else
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
/* Force a re-init to apply updates */
command_event(CMD_EVENT_OVERLAY_UNLOAD, NULL);
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
}
static void overlay_auto_rotate_toggle_change_handler(rarch_setting_t *setting)
static void overlay_show_mouse_cursor_change_handler(rarch_setting_t *setting)
{
settings_t *settings = config_get_ptr();
(void)setting;
if (!setting || !settings)
return;
/* This is very simple...
* The menu is currently active, so if:
* - Overlays are enabled
* - Overlays are not hidden in menus
* ...we just need to de-initialise then
* initialise the current overlay and the
* auto-rotate setting will be applied
* (i.e. There's no need to explicitly
* call the internal 'rotate overlay'
* function - saves having to expose it
* via the API) */
if (settings->bools.input_overlay_enable &&
!settings->bools.input_overlay_hide_in_menu)
{
command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
command_event(CMD_EVENT_OVERLAY_INIT, NULL);
}
input_overlay_check_mouse_cursor();
}
#endif
@ -16213,6 +16183,7 @@ static bool setting_append_list(
general_read_handler,
SD_FLAG_NONE
);
(*list)[list_info->index - 1].change_handler = overlay_show_mouse_cursor_change_handler;
CONFIG_BOOL(
list, list_info,
@ -16229,7 +16200,7 @@ static bool setting_append_list(
general_read_handler,
SD_FLAG_NONE
);
(*list)[list_info->index - 1].change_handler = overlay_auto_rotate_toggle_change_handler;
(*list)[list_info->index - 1].change_handler = overlay_enable_toggle_change_handler;
CONFIG_BOOL(
list, list_info,

View file

@ -2214,9 +2214,9 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_SAVE_FILES:
event_save_files(runloop_st->flags & RUNLOOP_FLAG_USE_SRAM);
break;
case CMD_EVENT_OVERLAY_DEINIT:
case CMD_EVENT_OVERLAY_UNLOAD:
#ifdef HAVE_OVERLAY
input_overlay_deinit();
input_overlay_unload();
#endif
#if defined(HAVE_TRANSLATE) && defined(HAVE_GFX_WIDGETS)
/* Because the overlay is a display widget,
@ -3951,6 +3951,9 @@ bool command_event(enum event_command cmd, void *data)
if (input_driver_ungrab_mouse())
input_st->flags &= ~INP_FLAG_GRAB_MOUSE_STATE;
}
#ifdef HAVE_OVERLAY
input_overlay_check_mouse_cursor();
#endif
video_st->flags &= ~VIDEO_FLAG_IS_SWITCHING_DISPLAY_MODE;
audio_st->flags &= ~AUDIO_FLAG_SUSPENDED;

View file

@ -5502,7 +5502,7 @@ static enum runloop_state_enum runloop_check_state(
if (controller_connected != last_controller_connected)
{
if (controller_connected)
input_overlay_deinit();
input_overlay_unload();
else
input_overlay_init();

View file

@ -47,9 +47,6 @@ struct overlay_loader
unsigned pos;
unsigned pos_increment;
float overlay_opacity;
overlay_layout_desc_t layout_desc;
enum overlay_status state;
enum overlay_image_transfer_status loading_status;
@ -544,16 +541,8 @@ static void task_overlay_resolve_iterate(retro_task_t *task)
}
if (loader->resolve_pos == 0)
{
loader->active = &loader->overlays[0];
#if 0
/* TODO: MOVE TO MAIN THREAD / CALLBACK */
input_overlay_load_active(loader->deferred.opacity);
input_overlay_enable(loader->deferred.enable);
#endif
}
loader->resolve_pos += 1;
}
@ -889,11 +878,11 @@ static void task_overlay_free(retro_task_t *task)
overlay_loader_t *loader = (overlay_loader_t*)task->state;
struct overlay *overlay = &loader->overlays[loader->pos];
if (loader->overlay_path)
free(loader->overlay_path);
if (task_get_cancelled(task))
{
if (loader->overlay_path)
free(loader->overlay_path);
for (i = 0; i < overlay->load_images_size; i++)
{
struct texture_image *ti = &overlay->load_images[i];
@ -945,12 +934,9 @@ static void task_overlay_handler(retro_task_t *task)
data->overlays = loader->overlays;
data->active = loader->active;
data->size = loader->size;
data->overlay_opacity = loader->overlay_opacity;
data->flags = loader->flags;
data->overlay_types = loader->overlay_types;
memcpy(&data->layout_desc, &loader->layout_desc,
sizeof(overlay_layout_desc_t));
data->overlay_path = loader->overlay_path;
task_set_data(task, data);
}
@ -976,11 +962,6 @@ static bool task_overlay_finder(retro_task_t *task, void *user_data)
bool task_push_overlay_load_default(
retro_task_callback_t cb,
const char *overlay_path,
bool overlay_hide_in_menu,
bool overlay_hide_when_gamepad_connected,
bool input_overlay_enable,
float input_overlay_opacity,
overlay_layout_desc_t *layout_desc,
void *user_data)
{
task_finder_data_t find_data;
@ -988,7 +969,7 @@ bool task_push_overlay_load_default(
config_file_t *conf = NULL;
overlay_loader_t *loader = NULL;
if (string_is_empty(overlay_path) || !layout_desc)
if (string_is_empty(overlay_path))
return false;
/* Prevent overlay from being loaded if it already is being loaded */
@ -1027,25 +1008,15 @@ bool task_push_overlay_load_default(
return false;
}
loader->overlay_opacity = input_overlay_opacity;
loader->conf = conf;
loader->state = OVERLAY_STATUS_DEFERRED_LOAD;
loader->pos_increment = (loader->size / 4) ? (loader->size / 4) : 4;
if (overlay_hide_in_menu)
loader->flags |= OVERLAY_LOADER_HIDE_IN_MENU;
if (overlay_hide_when_gamepad_connected)
loader->flags |= OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED;
if (input_overlay_enable)
loader->flags |= OVERLAY_LOADER_ENABLE;
#ifdef RARCH_INTERNAL
if (video_driver_supports_rgba())
loader->flags |= OVERLAY_LOADER_RGBA_SUPPORT;
#endif
memcpy(&loader->layout_desc, layout_desc,
sizeof(overlay_layout_desc_t));
t = task_init();
if (!t)

View file

@ -219,11 +219,6 @@ bool task_push_manual_content_scan(
bool task_push_overlay_load_default(
retro_task_callback_t cb,
const char *overlay_path,
bool overlay_hide_in_menu,
bool overlay_hide_when_gamepad_connected,
bool input_overlay_enable,
float input_overlay_opacity,
overlay_layout_desc_t *layout_desc,
void *user_data);
#endif