(Overlays) Cleanups

This commit is contained in:
twinaphex 2015-07-12 07:12:33 +02:00
parent 599ed62849
commit 2dbc3c4b56
4 changed files with 29 additions and 39 deletions

View File

@ -632,8 +632,9 @@ static void input_overlay_load_active(input_overlay_t *ol,
ol->iface->full_screen(ol->iface_data, ol->active->full_screen);
}
bool input_overlay_load_overlays_resolve_iterate(input_overlay_t *ol)
bool input_overlay_load_overlays_resolve_iterate(void)
{
input_overlay_t *ol = input_overlay_get_ptr();
bool not_done = true;
if (!ol)
@ -685,11 +686,12 @@ static bool input_overlay_load_overlay_image_done(struct overlay *overlay)
return true;
}
bool input_overlay_load_overlays_iterate(input_overlay_t *ol)
bool input_overlay_load_overlays_iterate(void)
{
size_t i = 0;
bool not_done = true;
struct overlay *overlay = NULL;
input_overlay_t *ol = input_overlay_get_ptr();
if (!ol)
return false;
@ -761,7 +763,7 @@ bool input_overlay_load_overlays_iterate(input_overlay_t *ol)
break;
case OVERLAY_IMAGE_TRANSFER_DESC_DONE:
if (ol->pos == 0)
input_overlay_load_overlays_resolve_iterate(ol);
input_overlay_load_overlays_resolve_iterate();
ol->pos += 1;
ol->loading_status = OVERLAY_IMAGE_TRANSFER_NONE;
break;
@ -778,12 +780,13 @@ error:
}
bool input_overlay_load_overlays(input_overlay_t *ol)
bool input_overlay_load_overlays(void)
{
unsigned i;
input_overlay_t *ol = input_overlay_get_ptr();
config_file_t *conf = config_file_new(ol->overlay_path);
if (!conf)
if (!ol || !conf)
return false;
for (i = 0; i < ol->pos_increment; i++, ol->pos++)
@ -933,8 +936,9 @@ error:
}
bool input_overlay_new_done(input_overlay_t *ol)
bool input_overlay_new_done(void)
{
input_overlay_t *ol = input_overlay_get_ptr();
if (!ol)
return false;
@ -1034,7 +1038,7 @@ input_overlay_t *input_overlay_new(const char *path, bool enable,
return ol;
error:
input_overlay_free(ol);
input_overlay_free();
return NULL;
}
@ -1334,8 +1338,9 @@ bool input_overlay_full_screen(input_overlay_t *ol)
*
* Frees overlay handle.
**/
void input_overlay_free(input_overlay_t *ol)
void input_overlay_free(void)
{
input_overlay_t *ol = input_overlay_get_ptr();
if (!ol)
return;
@ -1352,8 +1357,7 @@ void input_overlay_free(input_overlay_t *ol)
void input_overlay_free_ptr(void)
{
if (overlay_ptr)
input_overlay_free(overlay_ptr);
input_overlay_free();
overlay_ptr = NULL;
memset(&overlay_st_ptr, 0, sizeof(overlay_st_ptr));
@ -1416,8 +1420,9 @@ bool input_overlay_is_alive(void)
return ol->alive;
}
enum overlay_status input_overlay_status(input_overlay_t *ol)
enum overlay_status input_overlay_status(void)
{
input_overlay_t *ol = input_overlay_get_ptr();
if (!ol)
return OVERLAY_STATUS_NONE;
return ol->state;

View File

@ -117,23 +117,22 @@ typedef struct input_overlay_state
input_overlay_t *input_overlay_new(const char *path, bool enable,
float alpha_mod, float scale_factor);
bool input_overlay_load_overlays(input_overlay_t *ol);
bool input_overlay_load_overlays(void);
bool input_overlay_load_overlays_image_iterate(input_overlay_t *ol);
bool input_overlay_load_overlays_iterate(input_overlay_t *ol);
bool input_overlay_load_overlays_iterate(void);
bool input_overlay_load_overlays_resolve_iterate(input_overlay_t *ol);
bool input_overlay_load_overlays_resolve_iterate(void);
bool input_overlay_new_done(input_overlay_t *ol);
bool input_overlay_new_done(void);
/**
* input_overlay_free:
* @ol : Overlay handle.
*
* Frees overlay handle.
**/
void input_overlay_free(input_overlay_t *ol);
void input_overlay_free(void);
/**
* input_overlay_enable:
@ -228,7 +227,7 @@ void input_overlay_free_ptr(void);
int input_overlay_new_ptr(void);
enum overlay_status input_overlay_status(input_overlay_t *ol);
enum overlay_status input_overlay_status(void);
/*
* input_poll_overlay:

View File

@ -760,7 +760,6 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
menu_input_t *menu_input = menu_input_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
input_overlay_t *overlay = input_overlay_get_ptr();
*input_mouse = MOUSE_ACTION_NONE;
@ -875,7 +874,6 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
menu_input_t *menu_input = menu_input_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
input_overlay_t *overlay = input_overlay_get_ptr();
if (!menu_input)
return -1;

View File

@ -27,20 +27,15 @@ static slock_t *overlay_lock;
void rarch_main_data_overlay_image_upload_iterate(bool is_thread)
{
input_overlay_t *ol = NULL;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(overlay_lock);
#endif
ol = input_overlay_get_ptr();
if (!ol)
return;
switch (input_overlay_status(ol))
switch (input_overlay_status())
{
case OVERLAY_STATUS_DEFERRED_LOADING:
input_overlay_load_overlays_iterate(ol);
input_overlay_load_overlays_iterate();
break;
default:
break;
@ -54,37 +49,30 @@ void rarch_main_data_overlay_image_upload_iterate(bool is_thread)
void rarch_main_data_overlay_iterate(bool is_thread)
{
input_overlay_t *ol = NULL;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(overlay_lock);
#endif
ol = input_overlay_get_ptr();
if (!ol)
goto end;
switch (input_overlay_status(ol))
switch (input_overlay_status())
{
case OVERLAY_STATUS_DEFERRED_LOAD:
input_overlay_load_overlays(ol);
input_overlay_load_overlays();
break;
case OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE:
input_overlay_load_overlays_resolve_iterate(ol);
input_overlay_load_overlays_resolve_iterate();
break;
case OVERLAY_STATUS_DEFERRED_DONE:
input_overlay_new_done(ol);
input_overlay_new_done();
break;
case OVERLAY_STATUS_DEFERRED_ERROR:
input_overlay_free(ol);
input_overlay_free();
break;
default:
case OVERLAY_STATUS_NONE:
break;
}
end: ;
#ifdef HAVE_THREADS
if (is_thread)
slock_unlock(overlay_lock);