From b99ae6f4e438b5fb8b4dcb1db61d2ff544565c40 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 20 May 2015 01:39:35 +0200 Subject: [PATCH] Refactor some more code to no longer use global->video_data.width/ global->video_data.height directly --- gfx/d3d/render_chain_xdk.cpp | 14 ++++++++------ gfx/drivers_context/d3d_ctx.cpp | 7 ++++--- gfx/video_driver.c | 16 ++++++++++++++++ gfx/video_driver.h | 4 ++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 91170ad4a6..4de1069065 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -353,18 +353,21 @@ static void xdk_renderchain_set_final_viewport(void *data, } static bool xdk_renderchain_render(void *data, const void *frame, - unsigned width, unsigned height, unsigned pitch, unsigned rotation) + unsigned frame_width, unsigned frame_height, + unsigned pitch, unsigned rotation) { unsigned i; + unsigned width, height; d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); xdk_renderchain_t *chain = (xdk_renderchain_t*)d3d->renderchain_data; uint64_t frame_count = video_driver_get_frame_count(); - renderchain_blit_to_texture(chain, frame, width, height, pitch); - renderchain_set_vertices(d3d, 1, width, height, frame_count); + video_driver_get_size(&width, &height); + + renderchain_blit_to_texture(chain, frame, frame_width, frame_height, pitch); + renderchain_set_vertices(d3d, 1, frame_width, frame_height, frame_count); d3d_set_texture(d3dr, 0, chain->tex); d3d_set_viewport(chain->dev, &d3d->final_viewport); @@ -378,8 +381,7 @@ static bool xdk_renderchain_render(void *data, const void *frame, d3d_set_stream_source(d3dr, i, chain->vertex_buf, 0, sizeof(Vertex)); d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2); - renderchain_set_mvp(d3d, global->video_data.width, - global->video_data.height, d3d->dev_rotation); + renderchain_set_mvp(d3d, width, height, d3d->dev_rotation); return true; } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 612482a69b..83ef594cd1 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -55,7 +55,6 @@ static void d3d_resize(void *data, unsigned new_width, unsigned new_height) { d3d_video_t *d3d = (d3d_video_t*)curD3D; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; - global_t *global = global_get_ptr(); if (!d3dr) return; @@ -65,8 +64,10 @@ static void d3d_resize(void *data, unsigned new_width, unsigned new_height) if (new_width != d3d->video_info.width || new_height != d3d->video_info.height) { RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height); - d3d->video_info.width = global->video_data.width = new_width; - d3d->video_info.height = global->video_data.height = 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); d3d_restore(d3d); } } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7795e0ac59..cfc8d20cd5 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -846,3 +846,19 @@ void video_driver_get_size(unsigned *width, unsigned *height) if (height) *height = global->video_data.height; } + +void video_driver_set_size_width(unsigned width) +{ + global_t *global = global_get_ptr(); + if (!global) + return; + global->video_data.width = width; +} + +void video_driver_set_size_height(unsigned height) +{ + global_t *global = global_get_ptr(); + if (!global) + return; + global->video_data.height = height; +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 32979d4c4f..83a834dfbe 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -342,6 +342,10 @@ 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); + uint64_t video_driver_get_frame_count(void); #ifdef __cplusplus