From 86504392b9afdcc24e82b66e41456a324dfb0a23 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Nov 2015 12:54:15 +0100 Subject: [PATCH] Create video_driver_set_size --- gfx/d3d/d3d.cpp | 14 +++++--------- gfx/drivers/gl.c | 10 ++-------- gfx/drivers/vg.c | 13 +++---------- gfx/drivers_context/d3d_ctx.cpp | 3 +-- gfx/video_driver.c | 13 +++++-------- gfx/video_driver.h | 4 +--- 6 files changed, 17 insertions(+), 40 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 2988d32250..c5e3f20da2 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -177,9 +177,7 @@ void d3d_make_d3dpp(void *data, unsigned height = 0; gfx_ctx_get_video_size(d3d, &width, &height); - - video_driver_set_size_width(width); - video_driver_set_size_height(height); + video_driver_set_size(&width, &height); #endif video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); } @@ -464,10 +462,7 @@ static bool d3d_alive(void *data) } if (temp_width != 0 && temp_height != 0) - { - video_driver_set_size_width(temp_width); - video_driver_set_size_height(temp_height); - } + video_driver_set_size(&temp_width, &temp_height); return ret; } @@ -602,8 +597,9 @@ static bool d3d_construct(d3d_video_t *d3d, #else gfx_ctx_get_video_size(d3d, &full_x, &full_y); #endif - video_driver_set_size_width(info->fullscreen ? full_x : info->width); - video_driver_set_size_height(info->fullscreen ? full_y : info->height); + video_driver_set_size( + info->fullscreen ? &full_x : &info->width, + info->fullscreen ? &full_y : &info->height); #ifndef _XBOX #ifdef HAVE_WINDOW diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f19dc43f12..e0169e2ecd 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2481,10 +2481,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gfx_ctx_get_video_size(gl, &temp_width, &temp_height); if (temp_width != 0 && temp_height != 0) - { - video_driver_set_size_width(temp_width); - video_driver_set_size_height(temp_height); - } + video_driver_set_size(&temp_width, &temp_height); video_driver_get_size(&temp_width, &temp_height); @@ -2660,10 +2657,7 @@ static bool gl_alive(void *data) } if (temp_width != 0 && temp_height != 0) - { - video_driver_set_size_width(temp_width); - video_driver_set_size_height(temp_height); - } + video_driver_set_size(&temp_width, &temp_height); return ret; } diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 2e689a59cc..f78e1ad848 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -104,10 +104,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo RARCH_LOG("Detecting screen resolution %ux%u.\n", temp_width, temp_height); if (temp_width != 0 && temp_height != 0) - { - video_driver_set_size_width(temp_width); - video_driver_set_size_width(temp_height); - } + video_driver_set_size(&temp_width, &temp_height); gfx_ctx_swap_interval(vg, video->vsync ? 1 : 0); @@ -139,8 +136,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo if (temp_width != 0 && temp_height != 0) { RARCH_LOG("Verified window resolution %ux%u.\n", temp_width, temp_height); - video_driver_set_size_width(temp_width); - video_driver_set_size_height(temp_height); + video_driver_set_size(&temp_width, &temp_height); } video_driver_get_size(&temp_width, &temp_height); @@ -376,10 +372,7 @@ static bool vg_alive(void *data) &vg->should_resize, &temp_width, &temp_height); if (temp_width != 0 && temp_height != 0) - { - video_driver_set_size_width(temp_width); - video_driver_set_size_height(temp_height); - } + video_driver_set_size(&temp_width, &temp_height); return !quit; } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index bbdc76e693..126c50fe2f 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -65,8 +65,7 @@ static void d3d_resize(void *data, unsigned new_width, unsigned new_height) RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height); d3d->video_info.width = new_width; d3d->video_info.height = new_height; - video_driver_set_size_width(new_width); - video_driver_set_size_height(new_height); + video_driver_set_size(&new_width, &new_height); d3d_restore(d3d); } } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index a76ae247b7..f6c50c5528 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -864,17 +864,14 @@ void video_driver_get_size(unsigned *width, unsigned *height) *height = video_state.video_height; } -void video_driver_set_size_width(unsigned width) +void video_driver_set_size(unsigned *width, unsigned *height) { - video_state.video_width = width; + if (width) + video_state.video_width = *width; + if (height) + video_state.video_height = *height; } -void video_driver_set_size_height(unsigned height) -{ - video_state.video_height = height; -} - - /** * video_monitor_set_refresh_rate: * @hz : New refresh rate for monitor. diff --git a/gfx/video_driver.h b/gfx/video_driver.h index e8d394551e..d3ec46e1e2 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -402,9 +402,7 @@ bool video_driver_set_viewport(unsigned width, unsigned height, void video_driver_get_size(unsigned *width, unsigned *height); -void video_driver_set_size_width(unsigned width); - -void video_driver_set_size_height(unsigned width); +void video_driver_set_size(unsigned *width, unsigned *height); float video_driver_get_aspect_ratio(void);