Add has_windowed to video driver and graphics context driver

This commit is contained in:
twinaphex 2014-10-08 17:23:02 +02:00
parent c35d25c76e
commit bcd5f8aa5b
32 changed files with 323 additions and 62 deletions

View File

@ -252,6 +252,17 @@ static bool apple_gfx_ctx_has_focus(void *data)
#endif
}
static bool apple_gfx_ctx_has_windowed(void *data)
{
(void)data;
#ifdef IOS
return false;
#else
return true;
#endif
}
static void apple_gfx_ctx_swap_buffers(void *data)
{
if (!(--g_fast_forward_skips < 0))
@ -327,6 +338,7 @@ const gfx_ctx_driver_t gfx_ctx_apple = {
apple_gfx_ctx_check_window,
apple_gfx_ctx_set_resize,
apple_gfx_ctx_has_focus,
apple_gfx_ctx_has_windowed,
apple_gfx_ctx_swap_buffers,
apple_gfx_ctx_input_driver,
apple_gfx_ctx_get_proc_address,

View File

@ -405,6 +405,9 @@ typedef struct video_driver
/* Does the window have focus? */
bool (*focus)(void *data);
/* Does the graphics conext support windowed mode? */
bool (*has_windowed)(void *data);
/* Sets shader. Might not be implemented. Will be moved to
* poke_interface later. */
bool (*set_shader)(void *data, enum rarch_shader_type type,

View File

@ -261,12 +261,19 @@ static bool gfx_ctx_has_focus(void *data)
return true;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
static void android_gfx_ctx_bind_hw_render(void *data, bool enable)
{
(void)data;
g_use_hw_ctx = enable;
if (g_egl_dpy && g_egl_surf)
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, enable ? g_egl_hw_ctx : g_egl_ctx);
eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf,
enable ? g_egl_hw_ctx : g_egl_ctx);
}
const gfx_ctx_driver_t gfx_ctx_android = {
@ -281,6 +288,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -400,6 +400,12 @@ static bool gfx_ctx_qnx_has_focus(void *data)
return true;
}
static bool gfx_ctx_qnx_has_windowed(void *data)
{
(void)data;
return false;
}
static void gfx_qnx_ctx_bind_hw_render(void *data, bool enable)
{
(void)data;
@ -420,6 +426,7 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = {
gfx_ctx_qnx_check_window,
gfx_ctx_qnx_set_resize,
gfx_ctx_qnx_has_focus,
gfx_ctx_qnx_has_windowed,
gfx_ctx_qnx_swap_buffers,
gfx_ctx_qnx_input_driver,
gfx_ctx_qnx_get_proc_address,

View File

@ -293,6 +293,16 @@ static bool gfx_ctx_d3d_has_focus(void *data)
return GetFocus() == d3d->hWnd;
}
static bool gfx_ctx_d3d_has_windowed(void *data)
{
(void)data;
#ifdef _XBOX
return false;
#else
return true;
#endif
}
static bool gfx_ctx_d3d_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
{
(void)data;
@ -451,6 +461,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = {
gfx_ctx_d3d_check_window,
d3d_resize,
gfx_ctx_d3d_has_focus,
gfx_ctx_d3d_has_windowed,
gfx_ctx_d3d_swap_buffers,
gfx_ctx_d3d_input_driver,
NULL,

View File

@ -765,6 +765,12 @@ static bool gfx_ctx_has_focus(void *data)
return g_inited;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
@ -817,6 +823,7 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -88,7 +88,12 @@ static void gfx_ctx_null_input_driver(void *data, const input_driver_t **input,
static bool gfx_ctx_null_has_focus(void *data)
{
(void)data;
return true;
}
static bool gfx_ctx_null_has_windowed(void *data)
{
(void)data;
return true;
}
@ -133,6 +138,7 @@ const gfx_ctx_driver_t gfx_ctx_null = {
gfx_ctx_null_check_window,
gfx_ctx_null_set_resize,
gfx_ctx_null_has_focus,
gfx_ctx_null_has_windowed,
gfx_ctx_null_swap_buffers,
gfx_ctx_null_input_driver,
NULL,

View File

@ -602,6 +602,12 @@ static bool gfx_ctx_has_focus(void *data)
return (win == g_win && g_has_focus) || g_true_full;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return true;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return glXGetProcAddress((const GLubyte*)symbol);
@ -645,6 +651,7 @@ const gfx_ctx_driver_t gfx_ctx_glx = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -256,6 +256,12 @@ static bool gfx_ctx_has_focus(void *data)
return true;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
gfx_ctx_init,
gfx_ctx_destroy,
@ -268,6 +274,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -172,6 +172,12 @@ static bool gfx_ctx_has_focus(void *data)
return true;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
static void gfx_ctx_swap_buffers(void *data)
{
(void)data;
@ -314,6 +320,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
NULL,

View File

@ -333,6 +333,12 @@ static bool sdl_ctx_has_focus(void *data)
#endif
}
static bool sdl_ctx_has_windowed(void *data)
{
(void)data;
return true;
}
static void sdl_ctx_swap_buffers(void *data)
{
(void)data;
@ -374,6 +380,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl =
sdl_ctx_check_window,
sdl_ctx_set_resize,
sdl_ctx_has_focus,
sdl_ctx_has_windowed,
sdl_ctx_swap_buffers,
sdl_ctx_input_driver,
sdl_ctx_get_proc_address,

View File

@ -372,6 +372,12 @@ static bool gfx_ctx_has_focus(void *data)
return g_inited;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
@ -511,6 +517,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -261,6 +261,12 @@ static bool gfx_ctx_has_focus(void *data)
return true;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return false;
}
const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
gfx_ctx_init,
gfx_ctx_destroy,
@ -273,6 +279,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -567,6 +567,12 @@ static bool gfx_ctx_has_focus(void *data)
return true;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return true;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
@ -759,6 +765,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -576,6 +576,13 @@ static bool gfx_ctx_has_focus(void *data)
return GetFocus() == g_hwnd;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
return true;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return (gfx_ctx_proc_t)wglGetProcAddress(symbol);
@ -614,6 +621,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -671,6 +671,14 @@ static bool gfx_ctx_has_focus(void *data)
return (win == g_win && g_has_focus) || g_true_full;
}
static bool gfx_ctx_has_windowed(void *data)
{
(void)data;
/* TODO - verify if this has windowed mode or not. */
return true;
}
static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
{
return eglGetProcAddress(symbol);
@ -729,6 +737,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = {
gfx_ctx_check_window,
gfx_ctx_set_resize,
gfx_ctx_has_focus,
gfx_ctx_has_windowed,
gfx_ctx_swap_buffers,
gfx_ctx_input_driver,
gfx_ctx_get_proc_address,

View File

@ -413,6 +413,14 @@ static bool d3d_focus(void *data)
return false;
}
static bool d3d_has_windowed(void *data)
{
d3d_video_t *d3d = (d3d_video_t*)data;
if (d3d && d3d->ctx_driver && d3d->ctx_driver->has_windowed)
return d3d->ctx_driver->has_windowed(d3d);
return true;
}
static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{
d3d_video_t *d3d = (d3d_video_t*)data;
@ -1874,6 +1882,7 @@ video_driver_t video_d3d = {
d3d_set_nonblock_state,
d3d_alive,
d3d_focus,
d3d_has_windowed,
d3d_set_shader,
d3d_free,
"d3d",

View File

@ -1325,31 +1325,45 @@ fail:
return false;
}
static void exynos_gfx_set_nonblock_state(void *data, bool state) {
static void exynos_gfx_set_nonblock_state(void *data, bool state)
{
struct exynos_video *vid = data;
if (vid && vid->data)
vid->data->sync = !state;
}
static bool exynos_gfx_alive(void *data) {
static bool exynos_gfx_alive(void *data)
{
(void)data;
return true; /* always alive */
}
static bool exynos_gfx_focus(void *data) {
static bool exynos_gfx_focus(void *data)
{
(void)data;
return true; /* drm device always has focus */
}
static bool exynos_gfx_has_windowed(void *data)
{
(void)data;
return false;
}
static void exynos_gfx_set_rotation(void *data, unsigned rotation)
{
struct exynos_video *vid = data;
struct exynos_video *vid = (struct exynos_video*)data;
if (vid)
vid->menu_rotation = rotation;
}
static void exynos_gfx_viewport_info(void *data, struct rarch_viewport *vp)
{
struct exynos_video *vid = data;
struct exynos_video *vid = (struct exynos_video*)data;
if (!vid)
return;
vp->x = vp->y = 0;
@ -1357,12 +1371,16 @@ static void exynos_gfx_viewport_info(void *data, struct rarch_viewport *vp)
vp->height = vp->full_height = vid->height;
}
static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) {
static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
{
struct exynos_video *vid = data;
switch (aspect_ratio_idx) {
switch (aspect_ratio_idx)
{
case ASPECT_RATIO_SQUARE:
gfx_set_square_pixel_viewport(g_extern.system.av_info.geometry.base_width, g_extern.system.av_info.geometry.base_height);
gfx_set_square_pixel_viewport(
g_extern.system.av_info.geometry.base_width,
g_extern.system.av_info.geometry.base_height);
break;
case ASPECT_RATIO_CORE:
@ -1381,12 +1399,14 @@ static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) {
vid->aspect_changed = true;
}
static void exynos_apply_state_changes(void *data) {
static void exynos_apply_state_changes(void *data)
{
(void)data;
}
static void exynos_set_texture_frame(void *data, const void *frame, bool rgb32,
unsigned width, unsigned height, float alpha) {
unsigned width, unsigned height, float alpha)
{
const enum exynos_buffer_type buf_type = defaults[exynos_image_menu].buf_type;
struct exynos_video *vid = data;
@ -1417,21 +1437,25 @@ static void exynos_set_texture_frame(void *data, const void *frame, bool rgb32,
#endif
}
static void exynos_set_texture_enable(void *data, bool state, bool full_screen) {
static void exynos_set_texture_enable(void *data, bool state, bool full_screen)
{
struct exynos_video *vid = data;
if (vid)
vid->menu_active = state;
}
static void exynos_set_osd_msg(void *data, const char *msg, const struct font_params *params) {
struct exynos_video *vid = data;
/* TODO: what does this do? */
static void exynos_set_osd_msg(void *data, const char *msg,
const struct font_params *params)
{
(void)data;
(void)msg;
(void)params;
}
static void exynos_show_mouse(void *data, bool state) {
static void exynos_show_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static const video_poke_interface_t exynos_poke_interface = {
@ -1481,6 +1505,7 @@ video_driver_t video_exynos = {
exynos_gfx_set_nonblock_state,
exynos_gfx_alive,
exynos_gfx_focus,
exynos_gfx_has_windowed,
exynos_gfx_set_shader,
exynos_gfx_free,
"exynos",

View File

@ -89,6 +89,9 @@ typedef struct gfx_ctx_driver
/* Checks if window has input focus. */
bool (*has_focus)(void*);
/* Checks if context driver has windowed support. */
bool (*has_windowed)(void*);
/* Swaps buffers. VBlank sync depends on
* earlier calls to swap_interval. */
void (*swap_buffers)(void*);

View File

@ -2461,6 +2461,15 @@ static bool gl_focus(void *data)
return false;
}
static bool gl_has_windowed(void *data)
{
gl_t *gl = (gl_t*)data;
if (gl && gl->ctx_driver)
gl->ctx_driver->has_windowed(gl);
return true;
}
static void gl_update_tex_filter_frame(gl_t *gl)
{
unsigned i;
@ -3099,6 +3108,7 @@ video_driver_t video_gl = {
gl_set_nonblock_state,
gl_alive,
gl_focus,
gl_has_windowed,
gl_set_shader,

View File

@ -1056,6 +1056,12 @@ static bool gx_focus(void *data)
return true;
}
static bool gx_has_windowed(void *data)
{
(void)data;
return false;
}
static void gx_free(void *data)
{
gx_video_t *gx = (gx_video_t*)driver.video_data;
@ -1333,6 +1339,7 @@ video_driver_t video_gx = {
gx_set_nonblock_state,
gx_alive,
gx_focus,
gx_has_windowed,
gx_set_shader,
gx_free,
"gx",

View File

@ -57,6 +57,12 @@ static bool null_gfx_focus(void *data)
return true;
}
static bool null_gfx_has_windowed(void *data)
{
(void)data;
return true;
}
static void null_gfx_free(void *data)
{
(void)data;
@ -107,6 +113,7 @@ video_driver_t video_null = {
null_gfx_set_nonblock_state,
null_gfx_alive,
null_gfx_focus,
null_gfx_has_windowed,
null_gfx_set_shader,
null_gfx_free,
"null",

View File

@ -879,6 +879,14 @@ static void omap_gfx_viewport_info(void *data, struct rarch_viewport *vp) {
vp->height = vp->full_height = vid->height;
}
static bool omap_gfx_has_windowed(void *data)
{
(void)data;
/* TODO - implement. */
return true;
}
static bool omap_gfx_set_shader(void *data,
enum rarch_shader_type type, const char *path)
{
@ -916,6 +924,7 @@ video_driver_t video_omap = {
omap_gfx_set_nonblock_state,
omap_gfx_alive,
omap_gfx_focus,
omap_gfx_has_windowed,
omap_gfx_set_shader,
omap_gfx_free,
"omap",

View File

@ -591,6 +591,12 @@ static bool psp_focus(void *data)
return true;
}
static bool psp_has_windowed(void *data)
{
(void)data;
return false;
}
static void psp_free(void *data)
{
psp1_video_t *psp = (psp1_video_t*)data;
@ -851,6 +857,7 @@ video_driver_t video_psp1 = {
psp_set_nonblock_state,
psp_alive,
psp_focus,
psp_has_windowed,
psp_set_shader,
psp_free,
"psp1",

View File

@ -534,6 +534,15 @@ static bool sdl2_gfx_focus(void *data)
return (SDL_GetWindowFlags(vid->window) & flags) == flags;
}
static bool sdl2_gfx_has_windowed(void *data)
{
(void)data;
/* TODO - implement */
return true;
}
static void sdl2_gfx_free(void *data)
{
sdl2_video_t *vid = (sdl2_video_t*)data;
@ -721,6 +730,7 @@ video_driver_t video_sdl2 = {
sdl2_gfx_set_nonblock_state,
sdl2_gfx_alive,
sdl2_gfx_focus,
sdl2_gfx_has_windowed,
sdl2_gfx_set_shader,
sdl2_gfx_free,
"sdl2",

View File

@ -387,6 +387,14 @@ static bool sdl_gfx_focus(void *data)
return (SDL_GetAppState() & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) == (SDL_APPINPUTFOCUS | SDL_APPACTIVE);
}
static bool sdl_gfx_has_windowed(void *data)
{
(void)data;
/* TODO - implement. */
return true;
}
static void sdl_gfx_viewport_info(void *data, struct rarch_viewport *vp)
{
sdl_video_t *vid = (sdl_video_t*)data;
@ -522,6 +530,7 @@ video_driver_t video_sdl = {
sdl_gfx_set_nonblock_state,
sdl_gfx_alive,
sdl_gfx_focus,
sdl_gfx_has_windowed,
sdl_gfx_set_shader,
sdl_gfx_free,
"sdl",

View File

@ -413,7 +413,17 @@ static bool vg_alive(void *data)
static bool vg_focus(void *data)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->has_focus(vg);
return false;
}
static bool vg_has_windowed(void *data)
{
vg_t *vg = (vg_t*)data;
if (vg && vg->driver)
return vg->driver->has_windowed(vg);
return true;
}
static bool vg_set_shader(void *data,
@ -460,6 +470,7 @@ video_driver_t video_vg = {
vg_set_nonblock_state,
vg_alive,
vg_focus,
vg_has_windowed,
vg_set_shader,
vg_free,
"vg",

View File

@ -291,6 +291,7 @@ static void thread_loop(void *data)
bool ret = false;
bool alive = false;
bool focus = false;
bool has_windowed = true;
struct rarch_viewport vp = {0};
if (thr->driver && thr->driver->frame)
@ -306,12 +307,16 @@ static void thread_loop(void *data)
if (thr->driver && thr->driver->focus)
focus = ret && thr->driver->focus(thr->driver_data);
if (thr->driver && thr->driver->has_windowed)
has_windowed = ret && thr->driver->has_windowed(thr->driver_data);
if (thr->driver && thr->driver->viewport_info)
thr->driver->viewport_info(thr->driver_data, &vp);
slock_lock(thr->lock);
thr->alive = alive;
thr->focus = focus;
thr->has_windowed = has_windowed;
thr->frame.updated = false;
thr->vp = vp;
scond_signal(thr->cond_cmd);
@ -364,6 +369,15 @@ static bool thread_focus(void *data)
return ret;
}
static bool thread_has_windowed(void *data)
{
thread_video_t *thr = (thread_video_t*)data;
slock_lock(thr->lock);
bool ret = thr->has_windowed;
slock_unlock(thr->lock);
return ret;
}
static bool thread_frame(void *data, const void *frame_,
unsigned width, unsigned height, unsigned pitch, const char *msg)
{
@ -474,6 +488,7 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info,
thr->info = *info;
thr->alive = true;
thr->focus = true;
thr->has_windowed = true;
size_t max_size = info->input_scale * RARCH_SCALE_BASE;
max_size *= max_size;
@ -788,6 +803,7 @@ static const video_driver_t video_thread = {
thread_set_nonblock_state,
thread_alive,
thread_focus,
thread_has_windowed,
thread_set_shader,
thread_free,
"Thread wrapper",

View File

@ -97,6 +97,7 @@ typedef struct thread_video
bool alive;
bool focus;
bool has_windowed;
bool nonblock;
retro_time_t last_time;

View File

@ -257,6 +257,12 @@ static bool xenon360_gfx_focus(void *data)
return true;
}
static bool xenon360_gfx_has_windowed(void *data)
{
(void)data;
return false;
}
static void xenon360_gfx_set_rotation(void *data, unsigned rotation)
{
(void)data;
@ -306,6 +312,7 @@ video_driver_t video_xenon360 = {
xenon360_gfx_set_nonblock_state,
xenon360_gfx_alive,
xenon360_gfx_focus,
xenon360_gfx_has_windowed,
xenon360_gfx_set_shader,
xenon360_gfx_free,
"xenon360",

View File

@ -777,6 +777,14 @@ static bool xv_focus(void *data)
return xv->focus;
}
static bool xv_has_windowed(void *data)
{
(void)data;
/* TODO - verify. */
return true;
}
static void xv_free(void *data)
{
xv_t *xv = (xv_t*)data;
@ -850,6 +858,7 @@ video_driver_t video_xvideo = {
xv_set_nonblock_state,
xv_alive,
xv_focus,
xv_has_windowed,
xv_set_shader,
xv_free,
"xvideo",

View File

@ -1704,6 +1704,7 @@ static void check_disk_next(
{
unsigned num_disks = control->get_num_images();
unsigned current = control->get_image_index();
if (num_disks && num_disks != UINT_MAX)
{
unsigned new_index = current;