From 5516ff05b57a8eefdfcbf5597e0d505e176a3b25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Feb 2016 02:12:18 +0100 Subject: [PATCH] Create GFX_CTL_SET_VIDEO_MODE --- gfx/drivers/gl.c | 15 +++++++++++++-- gfx/drivers/vg.c | 7 ++++++- gfx/video_context_driver.c | 20 ++++++++++---------- gfx/video_context_driver.h | 13 +++++++++---- gfx/video_driver.c | 8 +++++++- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index a5b56a74df..7972d80494 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -961,7 +961,13 @@ static void gl_set_rotation(void *data, unsigned rotation) static void gl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) { - gfx_ctx_set_video_mode(width, height, fullscreen); + gfx_ctx_mode_t mode; + + mode.width = width; + mode.height = height; + mode.fullscreen = fullscreen; + + gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); } #ifdef HAVE_FBO @@ -2471,6 +2477,7 @@ static void gl_begin_debug(gl_t *gl) static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { + gfx_ctx_mode_t mode; gfx_ctx_input_t inp; unsigned interval; unsigned win_width, win_height, temp_width = 0, temp_height = 0; @@ -2507,7 +2514,11 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo win_height = gl->full_y; } - if (!gfx_ctx_set_video_mode(win_width, win_height, video->fullscreen)) + mode.width = win_width; + mode.height = win_height; + mode.fullscreen = video->fullscreen; + + if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) goto error; /* Clear out potential error flags in case we use cached context. */ diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index d18dea40fb..0a6ed3931b 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -85,6 +85,7 @@ static INLINE bool vg_query_extension(const char *ext) static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data) { + gfx_ctx_mode_t mode; gfx_ctx_input_t inp; gfx_ctx_aspect_t aspect_data; unsigned interval; @@ -124,7 +125,11 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo win_height = temp_height; } - if (!gfx_ctx_set_video_mode(win_width, win_height, video->fullscreen)) + mode.width = win_width; + mode.height = win_height; + mode.fullscreen = video->fullscreen; + + if !(gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) goto error; video_driver_get_size(&temp_width, &temp_height); diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 55c3568726..cab736ee23 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -83,16 +83,6 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = { static const gfx_ctx_driver_t *current_video_context; static void *video_context_data; -bool gfx_ctx_set_video_mode( - unsigned width, unsigned height, - bool fullscreen) -{ - if (!current_video_context || !current_video_context->set_video_mode) - return false; - return current_video_context->set_video_mode( - video_context_data, width, height, fullscreen); -} - void gfx_ctx_get_video_size(unsigned *width, unsigned *height) { if (!current_video_context || !current_video_context->get_video_size) @@ -432,6 +422,16 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) ident->ident = current_video_context->ident; } break; + case GFX_CTL_SET_VIDEO_MODE: + { + gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; + if (!current_video_context || !current_video_context->set_video_mode) + return false; + return current_video_context->set_video_mode( + video_context_data, mode_info->width, + mode_info->height, mode_info->fullscreen); + } + break; case GFX_CTL_NONE: default: break; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index b95371f235..036d4d7e31 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -79,7 +79,8 @@ enum gfx_ctx_ctl_state GFX_CTL_GET_METRICS, GFX_CTL_INPUT_DRIVER, GFX_CTL_SUPPRESS_SCREENSAVER, - GFX_CTL_IDENT_GET + GFX_CTL_IDENT_GET, + GFX_CTL_SET_VIDEO_MODE }; typedef void (*gfx_ctx_proc_t)(void); @@ -188,6 +189,13 @@ typedef struct gfx_ctx_size unsigned *height; } gfx_ctx_size_t; +typedef struct gfx_ctx_mode +{ + unsigned width; + unsigned height; + bool fullscreen; +} gfx_ctx_mode_t; + typedef struct gfx_ctx_metrics { enum display_metric_types type; @@ -264,9 +272,6 @@ extern const gfx_ctx_driver_t gfx_ctx_null; const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx); -bool gfx_ctx_set_video_mode(unsigned width, unsigned height, - bool fullscreen); - void gfx_ctx_get_video_size(unsigned *width, unsigned *height); bool gfx_ctx_set_resize(unsigned width, unsigned height); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 153c45b03e..b0094a6bb1 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -804,6 +804,8 @@ bool video_driver_set_rotation(unsigned rotation) bool video_driver_set_video_mode(unsigned width, unsigned height, bool fullscreen) { + gfx_ctx_mode_t mode; + if (video_driver_poke && video_driver_poke->set_video_mode) { video_driver_poke->set_video_mode(video_driver_data, @@ -811,7 +813,11 @@ bool video_driver_set_video_mode(unsigned width, return true; } - return gfx_ctx_set_video_mode(width, height, fullscreen); + mode.width = width; + mode.height = height; + mode.fullscreen = fullscreen; + + return gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); } bool video_driver_get_video_output_size(unsigned *width, unsigned *height)