Cleanup some of the video drivers - add some members to

video_info_t to reduce the need for accessing the settings
struct
This commit is contained in:
twinaphex 2017-01-10 18:16:22 +01:00
parent 0b03e95d95
commit 76ae7ac4a0
10 changed files with 49 additions and 47 deletions

View File

@ -19,26 +19,25 @@
#include <caca.h>
#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);

View File

@ -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;

View File

@ -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;

View File

@ -30,7 +30,6 @@
#include "../font_driver.h"
#include "../video_context_driver.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../runloop.h"

View File

@ -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;

View File

@ -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);

View File

@ -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)
{

View File

@ -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))
{

View File

@ -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);

View File

@ -26,7 +26,6 @@
#include "../../config.h"
#endif
#include "../../configuration.h"
#include "../../driver.h"
#include "../../runloop.h"