From 13a391c165e3e4a977324e92bbc9ad861c4f3dc6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 24 Feb 2015 21:36:23 +0100 Subject: [PATCH] Implement get_video_output_prev/get_video_output_next --- apple/common/apple_gfx_context.c.inl | 4 ++- gfx/d3d/d3d.cpp | 2 ++ gfx/drivers/exynos_gfx.c | 2 ++ gfx/drivers/gl.c | 19 ++++++++++++++ gfx/drivers/gx_gfx.c | 25 +++++++++++++++--- gfx/drivers/psp1_gfx.c | 2 ++ gfx/drivers/sdl2_gfx.c | 2 ++ gfx/drivers/sdl_gfx.c | 2 ++ gfx/drivers_context/androidegl_ctx.c | 4 ++- gfx/drivers_context/bbqnx_ctx.c | 4 ++- gfx/drivers_context/d3d_ctx.cpp | 4 ++- gfx/drivers_context/drm_egl_ctx.c | 4 ++- gfx/drivers_context/emscriptenegl_ctx.c | 5 +++- gfx/drivers_context/gfx_null_ctx.c | 4 ++- gfx/drivers_context/glx_ctx.c | 4 ++- gfx/drivers_context/mali_fbdev_ctx.c | 4 ++- gfx/drivers_context/ps3_ctx.c | 2 ++ gfx/drivers_context/sdl_gl_ctx.c | 2 ++ gfx/drivers_context/vc_egl_ctx.c | 3 +++ gfx/drivers_context/vivante_fbdev_ctx.c | 4 ++- gfx/drivers_context/wayland_ctx.c | 4 ++- gfx/drivers_context/wgl_ctx.c | 4 ++- gfx/drivers_context/xegl_ctx.c | 4 ++- gfx/video_context_driver.h | 4 +++ gfx/video_driver.h | 2 ++ gfx/video_thread_wrapper.c | 34 +++++++++++++++++++++++++ gfx/video_thread_wrapper.h | 2 ++ 27 files changed, 140 insertions(+), 16 deletions(-) diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index d0c5b9f9b4..3c03b62588 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -401,7 +401,9 @@ const gfx_ctx_driver_t gfx_ctx_apple = { apple_gfx_ctx_swap_interval, apple_gfx_ctx_set_video_mode, apple_gfx_ctx_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, apple_gfx_ctx_update_window_title, apple_gfx_ctx_check_window, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 96fa6da99b..3f305729c6 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1919,6 +1919,8 @@ static void d3d_set_menu_texture_enable(void *data, static const video_poke_interface_t d3d_poke_interface = { NULL, NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ #ifdef HAVE_FBO NULL, #endif diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 45bcdf10d6..f81b33e642 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1615,6 +1615,8 @@ static void exynos_show_mouse(void *data, bool state) static const video_poke_interface_t exynos_poke_interface = { NULL, /* set_filtering */ NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ #ifdef HAVE_FBO NULL, /* get_current_framebuffer */ #endif diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index c86aae1ed9..413fe24a1a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3096,9 +3096,28 @@ static void gl_get_video_output_size(void *data, unsigned *width, unsigned *heig gl->ctx_driver->get_video_output_size(gl, width, height); } +static void gl_get_video_output_prev(void *data) +{ + gl_t *gl = (gl_t*)data; + + if (gl && gl->ctx_driver->get_video_output_prev) + gl->ctx_driver->get_video_output_prev(gl); +} + +static void gl_get_video_output_next(void *data) +{ + gl_t *gl = (gl_t*)data; + + if (gl && gl->ctx_driver->get_video_output_next) + gl->ctx_driver->get_video_output_next(gl); +} + + static const video_poke_interface_t gl_poke_interface = { NULL, gl_get_video_output_size, + gl_get_video_output_prev, + gl_get_video_output_next, #ifdef HAVE_FBO gl_get_current_framebuffer, #endif diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index ed43842cf4..6164d61876 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -216,9 +216,6 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines) viHeightMultiplier = 1; viWidth = g_settings.video.viwidth; #if defined(HW_RVL) -#if 0 -#endif - progressive = CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable(); switch (CONF_GetVideo()) { @@ -1244,9 +1241,31 @@ static void gx_get_video_output_size(void *data, unsigned *width, unsigned *heig *height = menu_gx_resolutions[menu_current_gx_resolution][1]; } +static void gx_video_output_get_prev(void *data) +{ + if (menu_current_gx_resolution > 0) + menu_current_gx_resolution--; +} + +static void gx_video_output_get_next(void *data) +{ + if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) + { +#ifdef HW_RVL + if ((menu_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480) + if (CONF_GetVideo() != CONF_VIDEO_PAL) + return; +#endif + + menu_current_gx_resolution++; + } +} + static const video_poke_interface_t gx_poke_interface = { NULL, gx_get_video_output_size, + gx_get_video_output_prev, + gx_get_video_output_next, NULL, gx_set_aspect_ratio, gx_apply_state_changes, diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 3fd995a03e..165336da51 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -842,6 +842,8 @@ static void psp_viewport_info(void *data, struct video_viewport *vp) static const video_poke_interface_t psp_poke_interface = { psp_set_filtering, NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, NULL, psp_set_aspect_ratio, diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index cfd66c4d4f..7ccfe89ac8 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -719,6 +719,8 @@ void sdl2_grab_mouse_toggle(void *data) static video_poke_interface_t sdl2_video_poke_interface = { sdl2_poke_set_filtering, NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ #ifdef HAVE_FBO NULL, #endif diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index f3205d811f..172c46ee56 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -508,6 +508,8 @@ static void sdl_grab_mouse_toggle(void *data) static const video_poke_interface_t sdl_poke_interface = { sdl_set_filtering, NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ #ifdef HAVE_FBO NULL, NULL, diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 3cf346715e..42af581bb6 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -380,7 +380,9 @@ const gfx_ctx_driver_t gfx_ctx_android = { android_gfx_ctx_set_swap_interval, android_gfx_ctx_set_video_mode, android_gfx_ctx_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, android_gfx_ctx_update_window_title, android_gfx_ctx_check_window, diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 5d10348eff..9046f18b03 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -451,7 +451,9 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = { gfx_ctx_qnx_set_swap_interval, gfx_ctx_qnx_set_video_mode, gfx_ctx_qnx_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_qnx_update_window_title, gfx_ctx_qnx_check_window, diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index df15bcae73..899da8cb05 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -499,7 +499,9 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_swap_interval, NULL, gfx_ctx_d3d_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_d3d_update_title, gfx_ctx_d3d_check_window, diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index 0111bb6679..a059e72e85 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -957,7 +957,9 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = { gfx_ctx_drm_egl_swap_interval, gfx_ctx_drm_egl_set_video_mode, gfx_ctx_drm_egl_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_drm_egl_update_window_title, gfx_ctx_drm_egl_check_window, diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 744237d42c..058027e3f7 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -308,7 +308,10 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { gfx_ctx_emscripten_swap_interval, gfx_ctx_emscripten_set_video_mode, gfx_ctx_emscripten_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ + NULL, gfx_ctx_emscripten_translate_aspect, gfx_ctx_emscripten_update_window_title, gfx_ctx_emscripten_check_window, diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index aca851c1d7..063c349082 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -140,7 +140,9 @@ const gfx_ctx_driver_t gfx_ctx_null = { gfx_ctx_null_swap_interval, gfx_ctx_null_set_video_mode, gfx_ctx_null_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_null_update_window_title, gfx_ctx_null_check_window, diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index 0e544386cb..0fda1f014c 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -733,7 +733,9 @@ const gfx_ctx_driver_t gfx_ctx_glx = { gfx_ctx_glx_swap_interval, gfx_ctx_glx_set_video_mode, gfx_ctx_glx_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_glx_update_window_title, gfx_ctx_glx_check_window, diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 17993aed67..2b219f5f37 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -318,7 +318,9 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { gfx_ctx_mali_fbdev_set_swap_interval, gfx_ctx_mali_fbdev_set_video_mode, gfx_ctx_mali_fbdev_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_mali_fbdev_update_window_title, gfx_ctx_mali_fbdev_check_window, diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index ef3e9c759b..e6df0d1afa 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -378,6 +378,8 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_ps3_set_video_mode, gfx_ctx_ps3_get_video_size, gfx_ctx_ps3_get_video_output_size, + gfx_ctx_ps3_get_video_output_prev, + gfx_ctx_ps3_get_video_output_next, NULL, gfx_ctx_ps3_update_window_title, gfx_ctx_ps3_check_window, diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 072c458afb..3e04ee984a 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -422,6 +422,8 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = sdl_ctx_set_video_mode, sdl_ctx_get_video_size, NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, /* translate_aspect */ sdl_ctx_update_window_title, sdl_ctx_check_window, diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 35dacfd6d0..ae85ed1e74 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -640,6 +640,9 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_vc_swap_interval, gfx_ctx_vc_set_video_mode, gfx_ctx_vc_get_video_size, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_vc_translate_aspect, gfx_ctx_vc_update_window_title, diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index d5d76a286a..00971ada62 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -303,7 +303,9 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { gfx_ctx_vivante_set_swap_interval, gfx_ctx_vivante_set_video_mode, gfx_ctx_vivante_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_vivante_update_window_title, gfx_ctx_vivante_check_window, diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 66cdf63af6..bc240068e7 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -880,7 +880,9 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { gfx_ctx_wl_swap_interval, gfx_ctx_wl_set_video_mode, gfx_ctx_wl_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_wl_update_window_title, gfx_ctx_wl_check_window, diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index cf7477eaf9..6ae82d29bc 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -684,7 +684,9 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_wgl_swap_interval, gfx_ctx_wgl_set_video_mode, gfx_ctx_wgl_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_wgl_update_window_title, gfx_ctx_wgl_check_window, diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 6e2e7c68dc..6c0a44a59b 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -799,7 +799,9 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = { gfx_ctx_xegl_swap_interval, gfx_ctx_xegl_set_video_mode, gfx_ctx_xegl_get_video_size, - NULL, + NULL, /* get_video_output_size */ + NULL, /* get_video_output_prev */ + NULL, /* get_video_output_next */ NULL, gfx_ctx_xegl_update_window_title, gfx_ctx_xegl_check_window, diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index b297be67fe..a4419c7c05 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -72,6 +72,10 @@ typedef struct gfx_ctx_driver void (*get_video_output_size)(void*, unsigned*, unsigned*); + void (*get_video_output_prev)(void*); + + void (*get_video_output_next)(void*); + /* Translates a window size to an aspect ratio. * In most cases this will be just width / height, but * some contexts will better know which actual aspect ratio is used. diff --git a/gfx/video_driver.h b/gfx/video_driver.h index e6491c0763..9855bc988f 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -94,6 +94,8 @@ typedef struct video_poke_interface { void (*set_filtering)(void *data, unsigned index, bool smooth); void (*get_video_output_size)(void *data, unsigned *width, unsigned *height); + void (*get_video_output_prev)(void *data); + void (*get_video_output_next)(void *data); #ifdef HAVE_FBO uintptr_t (*get_current_framebuffer)(void *data); #endif diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index fbdcdef31c..e3991bb05f 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -265,6 +265,18 @@ static void thread_loop(void *data) thread_reply(thr, CMD_POKE_GET_VIDEO_OUTPUT_SIZE); break; + case CMD_POKE_GET_VIDEO_OUTPUT_PREV: + if (thr->poke && thr->poke->get_video_output_prev) + thr->poke->get_video_output_prev(thr->driver_data); + thread_reply(thr, CMD_POKE_GET_VIDEO_OUTPUT_PREV); + break; + + case CMD_POKE_GET_VIDEO_OUTPUT_NEXT: + if (thr->poke && thr->poke->get_video_output_next) + thr->poke->get_video_output_next(thr->driver_data); + thread_reply(thr, CMD_POKE_GET_VIDEO_OUTPUT_NEXT); + break; + case CMD_POKE_SET_ASPECT_RATIO: thr->poke->set_aspect_ratio(thr->driver_data, thr->cmd_data.i); @@ -780,6 +792,26 @@ static void thread_get_video_output_size(void *data, *height = thr->cmd_data.output.width; } +static void thread_get_video_output_prev(void *data) +{ + thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; + thread_send_cmd(thr, CMD_POKE_GET_VIDEO_OUTPUT_PREV); + thread_wait_reply(thr, CMD_POKE_GET_VIDEO_OUTPUT_PREV); +} + +static void thread_get_video_output_next(void *data) +{ + thread_video_t *thr = (thread_video_t*)data; + + if (!thr) + return; + thread_send_cmd(thr, CMD_POKE_GET_VIDEO_OUTPUT_NEXT); + thread_wait_reply(thr, CMD_POKE_GET_VIDEO_OUTPUT_NEXT); +} + static void thread_set_aspect_ratio(void *data, unsigned aspectratio_idx) { thread_video_t *thr = (thread_video_t*)data; @@ -874,6 +906,8 @@ static struct video_shader *thread_get_current_shader(void *data) static const video_poke_interface_t thread_poke = { thread_set_filtering, thread_get_video_output_size, + thread_get_video_output_prev, + thread_get_video_output_next, #ifdef HAVE_FBO NULL, #endif diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 6dabe403dd..d9e021348e 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -43,6 +43,8 @@ enum thread_cmd CMD_POKE_SET_FILTERING, CMD_POKE_GET_VIDEO_OUTPUT_SIZE, + CMD_POKE_GET_VIDEO_OUTPUT_PREV, + CMD_POKE_GET_VIDEO_OUTPUT_NEXT, #ifdef HAVE_FBO CMD_POKE_SET_FBO_STATE, CMD_POKE_GET_FBO_STATE,