diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 729cc35186..299923c9b4 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -20,7 +20,6 @@ #include #include -#include #include "video_thread_wrapper.h" #include "font_driver.h" @@ -32,200 +31,6 @@ #include "../runloop.h" #include "../verbosity.h" -enum thread_cmd -{ - CMD_VIDEO_NONE = 0, - CMD_INIT, - CMD_SET_SHADER, - CMD_FREE, - CMD_ALIVE, /* Blocking alive check. Used when paused. */ - CMD_SET_VIEWPORT, - CMD_SET_ROTATION, - CMD_READ_VIEWPORT, - - CMD_OVERLAY_ENABLE, - CMD_OVERLAY_LOAD, - CMD_OVERLAY_TEX_GEOM, - CMD_OVERLAY_VERTEX_GEOM, - CMD_OVERLAY_FULL_SCREEN, - - CMD_POKE_SET_VIDEO_MODE, - CMD_POKE_SET_FILTERING, - CMD_POKE_GET_VIDEO_OUTPUT_SIZE, - CMD_POKE_GET_VIDEO_OUTPUT_PREV, - CMD_POKE_GET_VIDEO_OUTPUT_NEXT, - - CMD_POKE_SET_FBO_STATE, - CMD_POKE_GET_FBO_STATE, - - CMD_POKE_SET_ASPECT_RATIO, - CMD_POKE_SET_OSD_MSG, - CMD_FONT_INIT, - CMD_CUSTOM_COMMAND, - - CMD_DUMMY = INT_MAX -}; - -struct thread_packet -{ - enum thread_cmd type; - union - { - bool b; - int i; - float f; - const char *str; - void *v; - - struct - { - enum rarch_shader_type type; - const char *path; - } set_shader; - - struct - { - unsigned width; - unsigned height; - bool force_full; - bool allow_rotate; - } set_viewport; - - struct - { - unsigned index; - float x, y, w, h; - } rect; - - struct - { - const struct texture_image *data; - unsigned num; - } image; - - struct - { - unsigned width; - unsigned height; - } output; - - struct - { - unsigned width; - unsigned height; - bool fullscreen; - } new_mode; - - struct - { - unsigned index; - bool smooth; - } filtering; - - struct - { - char msg[255]; - struct font_params params; - } osd_message; - - struct - { - custom_command_method_t method; - void* data; - int return_value; - } custom_command; - - struct - { - custom_font_command_method_t method; - const void **font_driver; - void **font_handle; - void *video_data; - const char *font_path; - float font_size; - bool return_value; - bool is_threaded; - enum font_driver_render_api api; - } font_init; - } data; -}; - -struct thread_video -{ - slock_t *lock; - scond_t *cond_cmd; - scond_t *cond_thread; - sthread_t *thread; - - video_info_t info; - const video_driver_t *driver; - -#ifdef HAVE_OVERLAY - const video_overlay_interface_t *overlay; -#endif - const video_poke_interface_t *poke; - - void *driver_data; - const input_driver_t **input; - void **input_data; - -#if defined(HAVE_MENU) - struct - { - void *frame; - size_t frame_cap; - unsigned width; - unsigned height; - float alpha; - bool frame_updated; - bool rgb32; - bool enable; - bool full_screen; - } texture; -#endif - bool apply_state_changes; - - bool alive; - bool focus; - bool suppress_screensaver; - bool has_windowed; - bool nonblock; - bool is_idle; - - retro_time_t last_time; - unsigned hit_count; - unsigned miss_count; - - float *alpha_mod; - unsigned alpha_mods; - bool alpha_update; - slock_t *alpha_lock; - - void (*send_and_wait)(struct thread_video *, thread_packet_t*); - enum thread_cmd send_cmd; - enum thread_cmd reply_cmd; - thread_packet_t cmd_data; - - struct video_viewport vp; - struct video_viewport read_vp; /* Last viewport reported to caller. */ - - struct - { - slock_t *lock; - uint8_t *buffer; - unsigned width; - unsigned height; - unsigned pitch; - bool updated; - bool within_thread; - uint64_t count; - char msg[255]; - } frame; - - video_driver_t video_thread; - -}; - static void *video_thread_init_never_call(const video_info_t *video, const input_driver_t **input, void **input_data) { diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 31c2010cff..705efd3be8 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -21,12 +21,47 @@ #include #include +#include #include "video_driver.h" #include "font_driver.h" RETRO_BEGIN_DECLS +enum thread_cmd +{ + CMD_VIDEO_NONE = 0, + CMD_INIT, + CMD_SET_SHADER, + CMD_FREE, + CMD_ALIVE, /* Blocking alive check. Used when paused. */ + CMD_SET_VIEWPORT, + CMD_SET_ROTATION, + CMD_READ_VIEWPORT, + + CMD_OVERLAY_ENABLE, + CMD_OVERLAY_LOAD, + CMD_OVERLAY_TEX_GEOM, + CMD_OVERLAY_VERTEX_GEOM, + CMD_OVERLAY_FULL_SCREEN, + + CMD_POKE_SET_VIDEO_MODE, + CMD_POKE_SET_FILTERING, + CMD_POKE_GET_VIDEO_OUTPUT_SIZE, + CMD_POKE_GET_VIDEO_OUTPUT_PREV, + CMD_POKE_GET_VIDEO_OUTPUT_NEXT, + + CMD_POKE_SET_FBO_STATE, + CMD_POKE_GET_FBO_STATE, + + CMD_POKE_SET_ASPECT_RATIO, + CMD_POKE_SET_OSD_MSG, + CMD_FONT_INIT, + CMD_CUSTOM_COMMAND, + + CMD_DUMMY = INT_MAX +}; + typedef int (*custom_command_method_t)(void*); typedef bool (*custom_font_command_method_t)(const void **font_driver, @@ -38,6 +73,165 @@ typedef struct thread_packet thread_packet_t; typedef struct thread_video thread_video_t; +struct thread_packet +{ + enum thread_cmd type; + union + { + bool b; + int i; + float f; + const char *str; + void *v; + + struct + { + enum rarch_shader_type type; + const char *path; + } set_shader; + + struct + { + unsigned width; + unsigned height; + bool force_full; + bool allow_rotate; + } set_viewport; + + struct + { + unsigned index; + float x, y, w, h; + } rect; + + struct + { + const struct texture_image *data; + unsigned num; + } image; + + struct + { + unsigned width; + unsigned height; + } output; + + struct + { + unsigned width; + unsigned height; + bool fullscreen; + } new_mode; + + struct + { + unsigned index; + bool smooth; + } filtering; + + struct + { + char msg[255]; + struct font_params params; + } osd_message; + + struct + { + custom_command_method_t method; + void* data; + int return_value; + } custom_command; + + struct + { + custom_font_command_method_t method; + const void **font_driver; + void **font_handle; + void *video_data; + const char *font_path; + float font_size; + bool return_value; + bool is_threaded; + enum font_driver_render_api api; + } font_init; + } data; +}; + +struct thread_video +{ + slock_t *lock; + scond_t *cond_cmd; + scond_t *cond_thread; + sthread_t *thread; + + video_info_t info; + const video_driver_t *driver; + +#ifdef HAVE_OVERLAY + const video_overlay_interface_t *overlay; +#endif + const video_poke_interface_t *poke; + + void *driver_data; + const input_driver_t **input; + void **input_data; + +#if defined(HAVE_MENU) + struct + { + void *frame; + size_t frame_cap; + unsigned width; + unsigned height; + float alpha; + bool frame_updated; + bool rgb32; + bool enable; + bool full_screen; + } texture; +#endif + bool apply_state_changes; + + bool alive; + bool focus; + bool suppress_screensaver; + bool has_windowed; + bool nonblock; + bool is_idle; + + retro_time_t last_time; + unsigned hit_count; + unsigned miss_count; + + float *alpha_mod; + unsigned alpha_mods; + bool alpha_update; + slock_t *alpha_lock; + + void (*send_and_wait)(struct thread_video *, thread_packet_t*); + enum thread_cmd send_cmd; + enum thread_cmd reply_cmd; + thread_packet_t cmd_data; + + struct video_viewport vp; + struct video_viewport read_vp; /* Last viewport reported to caller. */ + + struct + { + slock_t *lock; + uint8_t *buffer; + unsigned width; + unsigned height; + unsigned pitch; + bool updated; + bool within_thread; + uint64_t count; + char msg[255]; + } frame; + + video_driver_t video_thread; +}; + /** * video_init_thread: * @out_driver : Output video driver