From 76ae7ac4a0ad220b112ff6204e21ca1d3397ada5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Jan 2017 18:16:22 +0100 Subject: [PATCH] Cleanup some of the video drivers - add some members to video_info_t to reduce the need for accessing the settings struct --- gfx/drivers/caca_gfx.c | 64 +++++++++++++++++++++----------------- gfx/drivers/ctr_gfx.c | 1 - gfx/drivers/dispmanx_gfx.c | 3 +- gfx/drivers/drm_gfx.c | 1 - gfx/drivers/exynos_gfx.c | 4 +-- gfx/drivers/sdl2_gfx.c | 4 +-- gfx/drivers/sdl_gfx.c | 11 ++++--- gfx/drivers/vg.c | 2 +- gfx/drivers/vulkan.c | 5 ++- gfx/drivers/xenon360_gfx.c | 1 - 10 files changed, 49 insertions(+), 47 deletions(-) diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index ad31d37b5d..c56ca64b52 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -19,26 +19,25 @@ #include #include "../../driver.h" -#include "../../configuration.h" #include "../../verbosity.h" #include "../../menu/menu_driver.h" #include "../common/caca_common.h" -static caca_canvas_t *caca_cv = NULL; -static caca_dither_t *caca_dither = NULL; -static caca_display_t *caca_display = NULL; +static caca_canvas_t *caca_cv = NULL; +static caca_dither_t *caca_dither = NULL; +static caca_display_t *caca_display = NULL; static unsigned char *caca_menu_frame = NULL; -static unsigned caca_menu_width = 0; -static unsigned caca_menu_height = 0; -static unsigned caca_menu_pitch = 0; -static unsigned caca_video_width = 0; -static unsigned caca_video_height = 0; -static unsigned caca_video_pitch = 0; -static bool caca_rgb32 = 0; +static unsigned caca_menu_width = 0; +static unsigned caca_menu_height = 0; +static unsigned caca_menu_pitch = 0; +static unsigned caca_video_width = 0; +static unsigned caca_video_height = 0; +static unsigned caca_video_pitch = 0; +static bool caca_rgb32 = 0; static void caca_gfx_free(void *data); -static void caca_gfx_create() +static void caca_gfx_create(void) { caca_display = caca_create_display(NULL); caca_cv = caca_get_canvas(caca_display); @@ -62,19 +61,18 @@ static void caca_gfx_create() static void *caca_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); - caca_t *caca = (caca_t*)calloc(1, sizeof(*caca)); + caca_t *caca = (caca_t*)calloc(1, sizeof(*caca)); - caca->caca_cv = &caca_cv; - caca->caca_dither = &caca_dither; - caca->caca_display = &caca_display; + caca->caca_cv = &caca_cv; + caca->caca_dither = &caca_dither; + caca->caca_display = &caca_display; - *input = NULL; - *input_data = NULL; + *input = NULL; + *input_data = NULL; - caca_video_width = video->width; - caca_video_height = video->height; - caca_rgb32 = video->rgb32; + caca_video_width = video->width; + caca_video_height = video->height; + caca_rgb32 = video->rgb32; if (video->rgb32) caca_video_pitch = video->width * 4; @@ -88,7 +86,7 @@ static void *caca_gfx_init(const video_info_t *video, /* TODO: handle errors */ } - if (settings->video.font_enable) + if (video->font_enable) font_driver_init_osd(NULL, false, FONT_DRIVER_RENDER_CACA); return caca; @@ -115,7 +113,9 @@ static bool caca_gfx_frame(void *data, const void *frame, if (!frame || !frame_width || !frame_height) return true; - if (caca_video_width != frame_width || caca_video_height != frame_height || caca_video_pitch != pitch) + if ( caca_video_width != frame_width || + caca_video_height != frame_height || + caca_video_pitch != pitch) { if (frame_width > 4 && frame_height > 4) { @@ -136,7 +136,10 @@ static bool caca_gfx_frame(void *data, const void *frame, width = caca_get_canvas_width(caca_cv); height = caca_get_canvas_height(caca_cv); - if (frame_to_copy == frame && frame_width == 4 && frame_height == 4 && (frame_width < width && frame_height < height)) + if ( frame_to_copy == frame && + frame_width == 4 && + frame_height == 4 && + (frame_width < width && frame_height < height)) draw = false; caca_clear_canvas(caca_cv); @@ -151,9 +154,9 @@ static bool caca_gfx_frame(void *data, const void *frame, if (draw) { caca_dither_bitmap(caca_cv, 0, 0, - width, - height, - caca_dither, frame_to_copy); + width, + height, + caca_dither, frame_to_copy); buffer = caca_export_canvas_to_memory(caca_cv, "caca", &len); @@ -271,7 +274,10 @@ static void caca_set_texture_frame(void *data, caca_menu_frame = NULL; } - if (!caca_menu_frame || caca_menu_width != width || caca_menu_height != height || caca_menu_pitch != pitch) + if ( !caca_menu_frame || + caca_menu_width != width || + caca_menu_height != height || + caca_menu_pitch != pitch) if (pitch && height) caca_menu_frame = (unsigned char*)malloc(pitch * height); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index ec1db8364e..6c8ff9c6ab 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -291,7 +291,6 @@ static void* ctr_init(const video_info_t* video, float refresh_rate; void* ctrinput = NULL; ctr_video_t* ctr = (ctr_video_t*)linearAlloc(sizeof(ctr_video_t)); - settings_t *settings = config_get_ptr(); if (!ctr) return NULL; diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 9ae0f11e0b..b8132933e2 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -422,8 +422,7 @@ static void *dispmanx_gfx_init(const video_info_t *video, *input = NULL; /* Enable/disable dispmanx bilinear filtering. */ - settings_t *settings = config_get_ptr(); - dispmanx_set_scaling(settings->video.smooth); + dispmanx_set_scaling(video->smooth); dispmanx_blank_console(_dispvars); return _dispvars; diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 6382682b96..9e21463134 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -30,7 +30,6 @@ #include "../font_driver.h" #include "../video_context_driver.h" -#include "../../configuration.h" #include "../../retroarch.h" #include "../../runloop.h" diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index ddf6ed0c72..68f5132eba 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -37,9 +37,9 @@ #include "../common/drm_common.h" #include "../font_driver.h" +#include "../../configuration.h" #include "../../retroarch.h" #include "../../runloop.h" -#include "../../runloop.h" /* TODO: Honor these properties: vsync, menu rotation, menu alpha, aspect ratio change */ @@ -1045,7 +1045,7 @@ static int exynos_init_font(struct exynos_video *vid) const unsigned buf_height = defaults[EXYNOS_IMAGE_FONT].height; const unsigned buf_width = align_common(pdata->aspect * (float)buf_height, 16); const unsigned buf_bpp = defaults[EXYNOS_IMAGE_FONT].bpp; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); if (!settings->video.font_enable) return 0; diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 83f2de83ec..6d216d8986 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -388,8 +388,8 @@ static void *sdl2_gfx_init(const video_info_t *video, { int i; unsigned flags; + sdl2_video_t *vid = NULL; settings_t *settings = config_get_ptr(); - sdl2_video_t *vid; #ifdef HAVE_X11 XInitThreads(); @@ -446,7 +446,7 @@ static void *sdl2_gfx_init(const video_info_t *video, } vid->video = *video; - vid->video.smooth = settings->video.smooth; + vid->video.smooth = video->smooth; vid->should_resize = true; sdl_tex_zero(&vid->frame); diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index dc7d62e3ea..c6ed86e58f 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -291,14 +291,15 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu sdl_init_font(vid, settings->path.font, settings->video.font_size); - vid->scaler.scaler_type = video->smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; - vid->scaler.in_fmt = video->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; - vid->scaler.out_fmt = SCALER_FMT_ARGB8888; + vid->scaler.scaler_type = video->smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; + vid->scaler.in_fmt = video->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; + vid->scaler.out_fmt = SCALER_FMT_ARGB8888; - vid->menu.scaler = vid->scaler; + vid->menu.scaler = vid->scaler; vid->menu.scaler.scaler_type = SCALER_TYPE_BILINEAR; - vid->menu.frame = SDL_ConvertSurface(vid->screen, vid->screen->format, vid->screen->flags | SDL_SRCALPHA); + vid->menu.frame = SDL_ConvertSurface( + vid->screen, vid->screen->format, vid->screen->flags | SDL_SRCALPHA); if (!vid->menu.frame) { diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index aa4c3d15d2..91451518d1 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -191,7 +191,7 @@ static void *vg_init(const video_info_t *video, video_context_driver_input_driver(&inp); - if ( settings->video.font_enable + if ( video->font_enable && font_renderer_create_default((const void**)&vg->font_driver, &vg->mFontRenderer, *settings->path.font ? settings->path.font : NULL, settings->video.font_size)) { diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 4937ac8068..4f5cfd04c4 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1029,7 +1029,6 @@ static void *vulkan_init(const video_info_t *video, unsigned temp_width = 0; unsigned temp_height = 0; const gfx_ctx_driver_t *ctx_driver = NULL; - settings_t *settings = config_get_ptr(); vk_t *vk = (vk_t*)calloc(1, sizeof(*vk)); if (!vk) return NULL; @@ -1052,7 +1051,7 @@ static void *vulkan_init(const video_info_t *video, mode.height = 0; RARCH_LOG("Detecting screen resolution %ux%u.\n", full_x, full_y); - interval = video->vsync ? settings->video.swap_interval : 0; + interval = video->vsync ? video->swap_interval : 0; video_context_driver_swap_interval(&interval); win_width = video->width; @@ -1113,7 +1112,7 @@ static void *vulkan_init(const video_info_t *video, inp.input_data = input_data; video_context_driver_input_driver(&inp); - if (settings->video.font_enable) + if (video->font_enable) font_driver_init_osd(vk, false, FONT_DRIVER_RENDER_VULKAN_API); vulkan_init_readback(vk); diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 8ad04d3ae6..eeb99f5c1b 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -26,7 +26,6 @@ #include "../../config.h" #endif -#include "../../configuration.h" #include "../../driver.h" #include "../../runloop.h"