1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-05 09:48:42 +00:00

(Data runloop) Split up overlay task code to tasks/task_overlay.c

This commit is contained in:
Twinaphex 2015-05-05 18:16:09 +02:00
parent 8c75fd3530
commit d5e23012f1
5 changed files with 106 additions and 75 deletions

View File

@ -138,6 +138,7 @@ OBJ += frontend/frontend.o \
input/input_remapping.o \
input/input_sensor.o \
input/keyboard_line.o \
tasks/task_overlay.o \
input/input_overlay.o \
patch.o \
libretro-common/queues/fifo_buffer.o \

View File

@ -287,6 +287,7 @@ INPUT
#ifdef HAVE_OVERLAY
#include "../input/input_overlay.c"
#include "../tasks/task_overlay.c"
#endif
#if defined(__CELLOS_LV2__)

View File

@ -39,81 +39,6 @@ static void *rarch_main_data_get_ptr(void)
return g_data_runloop;
}
#ifdef HAVE_OVERLAY
static void rarch_main_data_overlay_image_upload_iterate(bool is_thread, data_runloop_t *runloop)
{
driver_t *driver = driver_get_ptr();
if (rarch_main_is_idle())
return;
if (!driver->overlay)
return;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(runloop->overlay_lock);
#endif
switch (driver->overlay->state)
{
case OVERLAY_STATUS_DEFERRED_LOADING:
input_overlay_load_overlays_iterate(driver->overlay);
break;
default:
break;
}
#ifdef HAVE_THREADS
if (is_thread)
slock_unlock(runloop->overlay_lock);
#endif
}
static void rarch_main_data_overlay_iterate(bool is_thread, data_runloop_t *runloop)
{
driver_t *driver = NULL;
if (rarch_main_is_idle())
return;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(runloop->overlay_lock);
#endif
driver = driver_get_ptr();
if (!driver || !driver->overlay)
goto end;
switch (driver->overlay->state)
{
case OVERLAY_STATUS_DEFERRED_LOAD:
input_overlay_load_overlays(driver->overlay);
break;
case OVERLAY_STATUS_NONE:
case OVERLAY_STATUS_ALIVE:
break;
case OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE:
input_overlay_load_overlays_resolve_iterate(driver->overlay);
break;
case OVERLAY_STATUS_DEFERRED_DONE:
input_overlay_new_done(driver->overlay);
break;
case OVERLAY_STATUS_DEFERRED_ERROR:
input_overlay_free(driver->overlay);
break;
default:
break;
}
end:
#ifdef HAVE_THREADS
if (is_thread)
slock_unlock(runloop->overlay_lock);
#endif
}
#endif
#ifdef HAVE_THREADS
static void data_runloop_thread_deinit(data_runloop_t *runloop)
{

97
tasks/task_overlay.c Normal file
View File

@ -0,0 +1,97 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <retro_miscellaneous.h>
#include "../driver.h"
#include "../runloop.h"
#include "../runloop_data.h"
#include "tasks.h"
void rarch_main_data_overlay_image_upload_iterate(bool is_thread, void *data)
{
data_runloop_t *runloop = (data_runloop_t*)data;
driver_t *driver = driver_get_ptr();
if (rarch_main_is_idle())
return;
if (!driver->overlay || !runloop)
return;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(runloop->overlay_lock);
#endif
switch (driver->overlay->state)
{
case OVERLAY_STATUS_DEFERRED_LOADING:
input_overlay_load_overlays_iterate(driver->overlay);
break;
default:
break;
}
#ifdef HAVE_THREADS
if (is_thread)
slock_unlock(runloop->overlay_lock);
#endif
}
void rarch_main_data_overlay_iterate(bool is_thread, void *data)
{
data_runloop_t *runloop = (data_runloop_t*)data;
driver_t *driver = NULL;
if (rarch_main_is_idle())
return;
#ifdef HAVE_THREADS
if (is_thread)
slock_lock(runloop->overlay_lock);
#endif
driver = driver_get_ptr();
if (!driver || !driver->overlay)
goto end;
switch (driver->overlay->state)
{
case OVERLAY_STATUS_DEFERRED_LOAD:
input_overlay_load_overlays(driver->overlay);
break;
case OVERLAY_STATUS_NONE:
case OVERLAY_STATUS_ALIVE:
break;
case OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE:
input_overlay_load_overlays_resolve_iterate(driver->overlay);
break;
case OVERLAY_STATUS_DEFERRED_DONE:
input_overlay_new_done(driver->overlay);
break;
case OVERLAY_STATUS_DEFERRED_ERROR:
input_overlay_free(driver->overlay);
break;
default:
break;
}
end:
#ifdef HAVE_THREADS
if (is_thread)
slock_unlock(runloop->overlay_lock);
#endif
}

View File

@ -50,6 +50,13 @@ void rarch_main_data_db_iterate(bool is_thread, void *data);
#endif
#endif
#ifdef HAVE_OVERLAY
void rarch_main_data_overlay_image_upload_iterate(bool is_thread,
void *data);
void rarch_main_data_overlay_iterate(bool is_thread, void *data);
#endif
void rarch_main_data_nbio_iterate(bool is_thread,
void *runloop);