From ce41c5bbca43de45fd194def93cf85090175aa4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Feb 2016 22:07:56 +0100 Subject: [PATCH] Create GFX_CTL_TRANSLATE_ASPECT --- gfx/d3d/d3d.cpp | 8 +++++++- gfx/drivers/gl.c | 8 ++++++-- gfx/drivers/vg.c | 7 ++++++- gfx/video_context_driver.h | 10 ++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index fde7602d9d..8dc6dccf29 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -647,12 +647,18 @@ static void d3d_calculate_rect(void *data, bool force_full, bool allow_rotate) { + gfx_ctx_aspect_t aspect_data; float device_aspect = (float)*width / *height; d3d_video_t *d3d = (d3d_video_t*)data; settings_t *settings = config_get_ptr(); video_driver_get_size(width, height); - gfx_ctx_translate_aspect(&device_aspect, *width, *height); + + aspect_data.aspect = &device_aspect; + aspect_data.width = *width; + aspect_data.height = *height; + + gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); *x = 0; *y = 0; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 1b4247b97e..4bf6d3c3f6 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -848,6 +848,7 @@ static void gl_set_projection(gl_t *gl, struct gfx_ortho *ortho, bool allow_rota static void gl_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate) { + gfx_ctx_aspect_t aspect_data; unsigned width, height; int x = 0, y = 0; float device_aspect = (float)viewport_width / viewport_height; @@ -857,8 +858,11 @@ static void gl_set_viewport(void *data, unsigned viewport_width, video_driver_get_size(&width, &height); - gfx_ctx_translate_aspect(&device_aspect, - viewport_width, viewport_height); + aspect_data.aspect = &device_aspect; + aspect_data.width = viewport_width; + aspect_data.height = viewport_height; + + gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); if (settings->video.scale_integer && !force_full) { diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 02e7892f2f..c1ca938b8f 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_aspect_t aspect_data; unsigned interval; unsigned temp_width = 0, temp_height = 0; VGfloat clearColor[4] = {0, 0, 0, 1}; @@ -142,7 +143,11 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo vg->mScreenAspect = (float)temp_width / temp_height; - gfx_ctx_translate_aspect(&vg->mScreenAspect, temp_width, temp_height); + aspect_data.aspect = &vg->mScreenAspect; + aspect_data.width = temp_width; + aspect_data.height = temp_height; + + gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); vgSetfv(VG_CLEAR_COLOR, 4, clearColor); diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 55f61e10ca..b4e6dfe57a 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -73,7 +73,8 @@ enum gfx_ctx_ctl_state GFX_CTL_FIND_PREV_DRIVER, GFX_CTL_GET_VIDEO_OUTPUT_SIZE, GFX_CTL_SWAP_INTERVAL, - GFX_CTL_PROC_ADDRESS_GET + GFX_CTL_PROC_ADDRESS_GET, + GFX_CTL_TRANSLATE_ASPECT }; typedef void (*gfx_ctx_proc_t)(void); @@ -191,8 +192,8 @@ typedef struct gfx_ctx_metrics typedef struct gfx_ctx_aspect { float *aspect; - unsigned *width; - unsigned *height; + unsigned width; + unsigned height; } gfx_ctx_aspect_t; typedef struct gfx_ctx_image @@ -255,9 +256,6 @@ const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident, bool gfx_ctx_get_metrics(enum display_metric_types type, float *value); -void gfx_ctx_translate_aspect(float *aspect, - unsigned width, unsigned height); - bool gfx_ctx_set_video_mode(unsigned width, unsigned height, bool fullscreen);