diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index d3319753a3..f4d7631827 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -143,16 +143,18 @@ static INLINE void ctr_set_screen_coords(ctr_video_t * ctr) static void ctr_update_viewport(ctr_video_t* ctr, settings_t *settings, video_frame_info_t *video_info) { - int x = 0; - int y = 0; - float width = ctr->vp.full_width; - float height = ctr->vp.full_height; - float desired_aspect = video_driver_get_aspect_ratio(); + int x = 0; + int y = 0; + float width = ctr->vp.full_width; + float height = ctr->vp.full_height; + float desired_aspect = video_driver_get_aspect_ratio(); + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; if(ctr->rotation & 0x1) desired_aspect = 1.0 / desired_aspect; - if (settings->bools.video_scale_integer) + if (video_scale_integer) { video_viewport_get_scaled_integer(&ctr->vp, ctr->vp.full_width, ctr->vp.full_height, desired_aspect, ctr->keep_aspect); @@ -160,7 +162,7 @@ static void ctr_update_viewport(ctr_video_t* ctr, settings_t *settings, video_fr else if (ctr->keep_aspect) { #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { x = video_info->custom_vp_x; y = video_info->custom_vp_y; @@ -332,6 +334,7 @@ static void* ctr_init(const video_info_t* video, u8 device_model = 0xFF; void* ctrinput = NULL; settings_t *settings = config_get_ptr(); + bool 3ds_lcd_bottom = settings->bools.video_3ds_lcd_bottom; ctr_video_t* ctr = (ctr_video_t*)linearAlloc(sizeof(ctr_video_t)); if (!ctr) @@ -490,16 +493,16 @@ static void* ctr_init(const video_info_t* video, video->is_threaded, FONT_DRIVER_RENDER_CTR); - ctr->msg_rendering_enabled = false; + ctr->msg_rendering_enabled = false; ctr->menu_texture_frame_enable = false; - ctr->menu_texture_enable = false; + ctr->menu_texture_enable = false; /* Set bottom screen enable state, if required */ - if (settings->bools.video_3ds_lcd_bottom != ctr_bottom_screen_enabled) { - ctr_set_bottom_screen_enable(ctr, settings->bools.video_3ds_lcd_bottom); - } + if (3ds_lcd_bottom != ctr_bottom_screen_enabled) + ctr_set_bottom_screen_enable(ctr, 3ds_lcd_bottom); - gspSetEventCallback(GSPGPU_EVENT_VBlank0, (ThreadFunc)ctr_vsync_hook, ctr, false); + gspSetEventCallback(GSPGPU_EVENT_VBlank0, + (ThreadFunc)ctr_vsync_hook, ctr, false); return ctr; } @@ -513,20 +516,20 @@ static bool ctr_frame(void* data, const void* frame, uint64_t frame_count, unsigned pitch, const char* msg, video_frame_info_t *video_info) { - uint32_t diff; + extern bool select_pressed; static uint64_t currentTick,lastTick; touchPosition state_tmp_touch; extern GSPGPU_FramebufferInfo topFramebufferInfo; extern u8* gfxSharedMemory; extern u8 gfxThreadID; + uint32_t diff; uint32_t state_tmp = 0; settings_t *settings = config_get_ptr(); ctr_video_t *ctr = (ctr_video_t*)data; static float fps = 0.0; static int total_frames = 0; static int frames = 0; - - extern bool select_pressed; + unsigned 3ds_disp_mode = settings->uints.video_3ds_display_mode; if (!width || !height || !settings) { @@ -757,7 +760,7 @@ static bool ctr_frame(void* data, const void* frame, GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), ctr->rgb32 ? GPU_RGBA8: GPU_RGB565); - ctr_check_3D_slider(ctr, (ctr_video_mode_enum)settings->uints.video_3ds_display_mode); + ctr_check_3D_slider(ctr, (ctr_video_mode_enum)3ds_disp_mode); /* ARGB --> RGBA */ if (ctr->rgb32) diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index fbd5308d9a..96e94d6ffa 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -1005,7 +1005,8 @@ static void *d3d10_gfx_init(const video_info_t* video, #endif { - int i = 0; + int i = 0; + int gpu_index = settings->ints.d3d10_gpu_index; if (d3d10_gpu_list) string_list_free(d3d10_gpu_list); @@ -1045,18 +1046,18 @@ static void *d3d10_gfx_init(const video_info_t* video, video_driver_set_gpu_api_devices(GFX_CTX_DIRECT3D10_API, d3d10_gpu_list); - if (0 <= settings->ints.d3d10_gpu_index && settings->ints.d3d10_gpu_index <= i && settings->ints.d3d10_gpu_index < D3D10_MAX_GPU_COUNT) + if (0 <= gpu_index && gpu_index <= i && (gpu_index < D3D10_MAX_GPU_COUNT)) { - d3d10_current_adapter = d3d10_adapters[settings->ints.d3d10_gpu_index]; + d3d10_current_adapter = d3d10_adapters[gpu_index]; d3d10->adapter = d3d10_current_adapter; - RARCH_LOG("[D3D10]: Using GPU index %d.\n", settings->ints.d3d10_gpu_index); - video_driver_set_gpu_device_string(d3d10_gpu_list->elems[settings->ints.d3d10_gpu_index].data); + RARCH_LOG("[D3D10]: Using GPU index %d.\n", gpu_index); + video_driver_set_gpu_device_string(d3d10_gpu_list->elems[gpu_index].data); } else { - RARCH_WARN("[D3D10]: Invalid GPU index %d, using first device found.\n", settings->ints.d3d10_gpu_index); + RARCH_WARN("[D3D10]: Invalid GPU index %d, using first device found.\n", gpu_index); d3d10_current_adapter = d3d10_adapters[0]; - d3d10->adapter = d3d10_current_adapter; + d3d10->adapter = d3d10_current_adapter; } } diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index ed269c4ffa..d7819f29cd 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1076,7 +1076,8 @@ static void *d3d11_gfx_init(const video_info_t* video, #endif { - int i = 0; + int i = 0; + int gpu_index = settings->ints.d3d11_gpu_index; if (d3d11_gpu_list) string_list_free(d3d11_gpu_list); @@ -1116,18 +1117,18 @@ static void *d3d11_gfx_init(const video_info_t* video, video_driver_set_gpu_api_devices(GFX_CTX_DIRECT3D11_API, d3d11_gpu_list); - if (0 <= settings->ints.d3d11_gpu_index && settings->ints.d3d11_gpu_index <= i && settings->ints.d3d11_gpu_index < D3D11_MAX_GPU_COUNT) + if (0 <= gpu_index && gpu_index <= i && gpu_index < D3D11_MAX_GPU_COUNT) { - d3d11_current_adapter = d3d11_adapters[settings->ints.d3d11_gpu_index]; + d3d11_current_adapter = d3d11_adapters[gpu_index]; d3d11->adapter = d3d11_current_adapter; - RARCH_LOG("[D3D11]: Using GPU index %d.\n", settings->ints.d3d11_gpu_index); - video_driver_set_gpu_device_string(d3d11_gpu_list->elems[settings->ints.d3d11_gpu_index].data); + RARCH_LOG("[D3D11]: Using GPU index %d.\n", gpu_index); + video_driver_set_gpu_device_string(d3d11_gpu_list->elems[gpu_index].data); } else { - RARCH_WARN("[D3D11]: Invalid GPU index %d, using first device found.\n", settings->ints.d3d11_gpu_index); + RARCH_WARN("[D3D11]: Invalid GPU index %d, using first device found.\n", gpu_index); d3d11_current_adapter = d3d11_adapters[0]; - d3d11->adapter = d3d11_current_adapter; + d3d11->adapter = d3d11_current_adapter; } } @@ -1664,6 +1665,7 @@ static void d3d11_set_menu_texture_frame( { d3d11_video_t* d3d11 = (d3d11_video_t*)data; settings_t* settings = config_get_ptr(); + bool menu_linear_filter = settings->bools.menu_linear_filter; DXGI_FORMAT format = rgb32 ? DXGI_FORMAT_B8G8R8A8_UNORM : (DXGI_FORMAT)DXGI_FORMAT_EX_A4R4G4B4_UNORM; @@ -1680,8 +1682,8 @@ static void d3d11_set_menu_texture_frame( d3d11_update_texture(d3d11->context, width, height, 0, format, frame, &d3d11->menu.texture); d3d11->menu.texture.sampler = d3d11->samplers - [settings->bools.menu_linear_filter - ? RARCH_FILTER_LINEAR + [menu_linear_filter + ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST][RARCH_WRAP_DEFAULT]; } diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 6b0c344168..44075de9f1 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -660,9 +660,10 @@ static void d3d8_make_d3dpp(void *data, if (info->vsync) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + unsigned video_swap_interval = settings->uints.video_swap_interval; - switch (settings->uints.video_swap_interval) + switch (video_swap_interval) { default: case 1: @@ -787,16 +788,18 @@ static void d3d8_calculate_rect(void *data, bool force_full, bool allow_rotate) { - float device_aspect = (float)*width / *height; - d3d8_video_t *d3d = (d3d8_video_t*)data; - settings_t *settings = config_get_ptr(); + float device_aspect = (float)*width / *height; + d3d8_video_t *d3d = (d3d8_video_t*)data; + settings_t *settings = config_get_ptr(); + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; video_driver_get_size(width, height); *x = 0; *y = 0; - if (settings->bools.video_scale_integer && !force_full) + if (video_scale_integer && !force_full) { struct video_viewport vp; @@ -823,7 +826,7 @@ static void d3d8_calculate_rect(void *data, float desired_aspect = video_driver_get_aspect_ratio(); #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { video_viewport_t *custom = video_viewport_get_custom(); @@ -1155,11 +1158,11 @@ static bool d3d8_init_internal(d3d8_video_t *d3d, g_win32_resize_width = info->width; g_win32_resize_height = info->height; - windowed_full = settings->bools.video_windowed_fullscreen; + windowed_full = settings->bools.video_windowed_fullscreen; - full_x = (windowed_full || info->width == 0) ? + full_x = (windowed_full || info->width == 0) ? (mon_rect.right - mon_rect.left) : info->width; - full_y = (windowed_full || info->height == 0) ? + full_y = (windowed_full || info->height == 0) ? (mon_rect.bottom - mon_rect.top) : info->height; RARCH_LOG("[D3D8]: Monitor size: %dx%d.\n", diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index d4062931a2..e1d0abc7c7 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -278,15 +278,16 @@ static bool d3d9_init_chain(d3d9_video_t *d3d, const video_info_t *video_info) { unsigned i; settings_t *settings = config_get_ptr(); + bool video_smooth = settings->bools.video_smooth; for (i = 0; i < d3d->shader.luts; i++) { if (!d3d->renderchain_driver->add_lut( d3d->renderchain_data, d3d->shader.lut[i].id, d3d->shader.lut[i].path, - d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC ? - settings->bools.video_smooth : - (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR))) + d3d->shader.lut[i].filter == RARCH_FILTER_UNSPEC + ? video_smooth + : (d3d->shader.lut[i].filter == RARCH_FILTER_LINEAR))) { RARCH_ERR("[D3D9]: Failed to init LUTs.\n"); return false; @@ -525,8 +526,9 @@ static void d3d9_overlay_render(d3d9_video_t *d3d, if (!force_linear) { - settings_t *settings = config_get_ptr(); - if (!settings->bools.menu_linear_filter) + settings_t *settings = config_get_ptr(); + bool menu_linear_filter = settings->bools.menu_linear_filter; + if (!menu_linear_filter) filter_type = D3DTEXF_POINT; } @@ -664,9 +666,10 @@ void d3d9_make_d3dpp(void *data, if (info->vsync) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + unsigned video_swap_interval = settings->uints.video_swap_interval; - switch (settings->uints.video_swap_interval) + switch (video_swap_interval) { default: case 1: @@ -769,13 +772,14 @@ static void d3d9_calculate_rect(void *data, float device_aspect = (float)*width / *height; d3d9_video_t *d3d = (d3d9_video_t*)data; settings_t *settings = config_get_ptr(); + bool scale_integer = settings->bools.video_scale_integer; video_driver_get_size(width, height); *x = 0; *y = 0; - if (settings->bools.video_scale_integer && !force_full) + if (scale_integer && !force_full) { struct video_viewport vp; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 5391e2fc90..5370cd602b 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -205,10 +205,6 @@ static void exynos_page_flip_handler(int fd, unsigned frame, unsigned sec, { struct exynos_page *page = data; -#if (EXYNOS_GFX_DEBUG_LOG == 1) - RARCH_LOG("[video_exynos]: in exynos_page_flip_handler, page = %p\n", page); -#endif - if (page->base->cur_page) page->base->cur_page->used = false; @@ -594,15 +590,17 @@ static void exynos_close(struct exynos_data *pdata) static int exynos_init(struct exynos_data *pdata, unsigned bpp) { unsigned i; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + unsigned video_fullscreen_x = settings->uints.video_fullscreen_x; + unsigned video_fullscreen_y = settings->uints.video_fullscreen_y; - if (settings->uints.video_fullscreen_x != 0 && - settings->uints.video_fullscreen_y != 0) + if ( video_fullscreen_x != 0 && + video_fullscreen_y != 0) { for (i = 0; i < g_drm_connector->count_modes; i++) { - if (g_drm_connector->modes[i].hdisplay == settings->uints.video_fullscreen_x && - g_drm_connector->modes[i].vdisplay == settings->uints.video_fullscreen_y) + if (g_drm_connector->modes[i].hdisplay == video_fullscreen_x && + g_drm_connector->modes[i].vdisplay == video_fullscreen_y) { g_drm_mode = &g_drm_connector->modes[i]; break; @@ -611,9 +609,10 @@ static int exynos_init(struct exynos_data *pdata, unsigned bpp) if (!g_drm_mode) { - RARCH_ERR("[video_exynos]: requested resolution (%ux%u) not available\n", - settings->uints.video_fullscreen_x, - settings->uints.video_fullscreen_y); + RARCH_ERR( + "[video_exynos]: requested resolution (%ux%u) not available\n", + video_fullscreen_x, + video_fullscreen_y); goto fail; } @@ -1050,17 +1049,23 @@ static int exynos_init_font(struct exynos_video *vid) 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(); + bool video_font_enable = settings->bools.video_font_enable; + const char *font_path = settings->video.font_path; + float video_font_size = settings->floats.video_font_size; + float video_msg_color_r = settings->floats.video_msg_color_r; + float video_msg_color_g = settings->floats.video_msg_color_g; + float video_msg_color_b = settings->floats.video_msg_color_b; - if (!settings->bools.video_font_enable) + if (!video_font_enable) return 0; if (font_renderer_create_default(&vid->font_driver, &vid->font, - *settings->video.font_path ? settings->video.font_path : NULL, - settings->floats.video_font_size)) + *font_path ? font_path : NULL, + video_font_size)) { - const int r = settings->floats.video_msg_color_r * 15; - const int g = settings->floats.video_msg_color_g * 15; - const int b = settings->floats.video_msg_color_b * 15; + const int r = video_msg_color_r * 15; + const int g = video_msg_color_g * 15; + const int b = video_msg_color_b * 15; vid->font_color = ((b < 0 ? 0 : (b > 15 ? 15 : b)) << 0) | ((g < 0 ? 0 : (g > 15 ? 15 : g)) << 4) | @@ -1080,15 +1085,10 @@ static int exynos_init_font(struct exynos_video *vid) return -1; } - src->width = buf_width; + src->width = buf_width; src->height = buf_height; src->stride = buf_width * buf_bpp; -#if (EXYNOS_GFX_DEBUG_LOG == 1) - RARCH_LOG("[video_exynos]: using font rendering image with size %ux%u\n", - buf_width, buf_height); -#endif - return 0; } diff --git a/gfx/drivers/fpga_gfx.c b/gfx/drivers/fpga_gfx.c index 90ec1a5e19..9fa390d32a 100644 --- a/gfx/drivers/fpga_gfx.c +++ b/gfx/drivers/fpga_gfx.c @@ -132,6 +132,7 @@ static void *fpga_gfx_init(const video_info_t *video, unsigned win_width = 0, win_height = 0; unsigned temp_width = 0, temp_height = 0; settings_t *settings = config_get_ptr(); + bool video_font_enable = settings->bools.video_font_enable; fpga_t *fpga = (fpga_t*)calloc(1, sizeof(*fpga)); *input = NULL; @@ -209,7 +210,7 @@ static void *fpga_gfx_init(const video_info_t *video, video_context_driver_input_driver(&inp); - if (settings->bools.video_font_enable) + if (video_font_enable) font_driver_init_osd(NULL, video, false, diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index f466332d6d..1d7e97c56c 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -88,6 +88,7 @@ static void *gdi_gfx_init(const video_info_t *video, unsigned win_width = 0, win_height = 0; unsigned temp_width = 0, temp_height = 0; settings_t *settings = config_get_ptr(); + bool video_font_enable = settings->bools.video_font_enable; gdi_t *gdi = (gdi_t*)calloc(1, sizeof(*gdi)); if (!gdi) @@ -173,7 +174,7 @@ static void *gdi_gfx_init(const video_info_t *video, video_context_driver_input_driver(&inp); - if (settings->bools.video_font_enable) + if (video_font_enable) font_driver_init_osd(gdi, video, false, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9f52ef6a50..c6f0426719 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -786,6 +786,7 @@ static void gl2_create_fbo_texture(gl_t *gl, bool smooth = false; settings_t *settings = config_get_ptr(); bool video_smooth = settings->bools.video_smooth; + bool force_srgb_disable = settings->bools.video_force_srgb_disable; GLuint base_filt = video_smooth ? GL_LINEAR : GL_NEAREST; GLuint base_mip_filt = video_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; @@ -837,7 +838,7 @@ static void gl2_create_fbo_texture(gl_t *gl, RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result may have banding!\n"); } - if (settings->bools.video_force_srgb_disable) + if (force_srgb_disable) srgb_fbo = false; if (srgb_fbo && chain->has_srgb_fbo) @@ -1629,6 +1630,7 @@ static void gl2_renderchain_resolve_extensions(gl_t *gl, const video_info_t *video) { settings_t *settings = config_get_ptr(); + bool force_srgb_disable = settings->bools.video_force_srgb_disable; if (!chain) return; @@ -1638,7 +1640,7 @@ static void gl2_renderchain_resolve_extensions(gl_t *gl, /* GLES3 has unpack_subimage and sRGB in core. */ chain->has_srgb_fbo_gles3 = gl_check_capability(GL_CAPS_SRGB_FBO_ES3); - if (!settings->bools.video_force_srgb_disable) + if (!force_srgb_disable) chain->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); /* Use regular textures if we use HW render. */ @@ -2259,8 +2261,9 @@ static void gl2_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - enum texture_filter_type menu_filter; settings_t *settings = config_get_ptr(); + enum texture_filter_type + menu_filter = settings->bools.menu_linear_filter ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST; unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); gl_t *gl = (gl_t*)data; if (!gl) @@ -2268,8 +2271,6 @@ static void gl2_set_texture_frame(void *data, gl2_context_bind_hw_render(gl, false); - menu_filter = settings->bools.menu_linear_filter ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST; - if (!gl->menu_texture) glGenTextures(1, &gl->menu_texture); @@ -2308,6 +2309,7 @@ static void gl2_render_osd_background( float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); float *verts = (float*)malloc(2 * vertices_total * sizeof(float)); settings_t *settings = config_get_ptr(); + float video_font_size = settings->floats.video_font_size; int msg_width = font_driver_get_message_width(NULL, msg, (unsigned)strlen(msg), 1.0f); @@ -2315,9 +2317,7 @@ static void gl2_render_osd_background( float x = video_info->font_msg_pos_x; float y = video_info->font_msg_pos_y; float width = msg_width / (float)video_info->width; - float height = - settings->floats.video_font_size / (float)video_info->height; - + float height = video_font_size / (float)video_info->height; float x2 = 0.005f; /* extend background around text */ float y2 = 0.005f; @@ -3257,6 +3257,7 @@ static void gl2_set_nonblock_state( static bool gl2_resolve_extensions(gl_t *gl, const char *context_ident, const video_info_t *video) { settings_t *settings = config_get_ptr(); + bool video_hard_sync = settings->bools.video_hard_sync; /* have_es2_compat - GL_RGB565 internal format support. * Even though ES2 support is claimed, the format @@ -3273,7 +3274,7 @@ static bool gl2_resolve_extensions(gl_t *gl, const char *context_ident, const vi gl->support_unpack_row_length = gl_check_capability(GL_CAPS_UNPACK_ROW_LENGTH); gl->have_sync = gl_check_capability(GL_CAPS_SYNC); - if (gl->have_sync && settings->bools.video_hard_sync) + if (gl->have_sync && video_hard_sync) RARCH_LOG("[GL]: Using ARB_sync to reduce latency.\n"); video_driver_unset_rgba(); @@ -4008,12 +4009,13 @@ static void gl2_update_tex_filter_frame(gl_t *gl) enum gfx_wrap_type wrap_type; bool smooth = false; settings_t *settings = config_get_ptr(); + bool video_smooth = settings->bools.video_smooth; gl2_context_bind_hw_render(gl, false); if (!gl->shader->filter_type(gl->shader_data, 1, &smooth)) - smooth = settings->bools.video_smooth; + smooth = video_smooth; mip_level = 1; wrap_type = gl->shader->wrap_type(gl->shader_data, 1); diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 62c14a4344..6475b31105 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -1127,14 +1127,15 @@ static void gl1_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - settings_t *settings = config_get_ptr(); - unsigned pitch = width * 2; - gl1_t *gl1 = (gl1_t*)data; + settings_t *settings = config_get_ptr(); + bool menu_linear_filter = settings->bools.menu_linear_filter; + unsigned pitch = width * 2; + gl1_t *gl1 = (gl1_t*)data; if (!gl1) return; - gl1->menu_smooth = settings->bools.menu_linear_filter; + gl1->menu_smooth = menu_linear_filter; gl1_context_bind_hw_render(gl1, false); diff --git a/gfx/drivers/gl_core.c b/gfx/drivers/gl_core.c index 97d975d445..48e07f9d98 100644 --- a/gfx/drivers/gl_core.c +++ b/gfx/drivers/gl_core.c @@ -1160,6 +1160,7 @@ static void *gl_core_init(const video_info_t *video, gfx_ctx_input_t inp; unsigned full_x, full_y; settings_t *settings = config_get_ptr(); + bool video_gpu_record = settings->bools.video_gpu_record; int interval = 0; unsigned win_width = 0; unsigned win_height = 0; @@ -1329,8 +1330,7 @@ static void *gl_core_init(const video_info_t *video, FONT_DRIVER_RENDER_OPENGL_CORE_API); } - gl->pbo_readback_enable = settings->bools.video_gpu_record - && recording_is_enabled(); + gl->pbo_readback_enable = video_gpu_record && recording_is_enabled(); if (gl->pbo_readback_enable && gl_core_init_pbo_readback(gl)) { @@ -2118,27 +2118,29 @@ static void gl_core_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - GLenum menu_filter; settings_t *settings = config_get_ptr(); + GLenum menu_filter = settings->bools.menu_linear_filter + ? GL_LINEAR : GL_NEAREST; unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); gl_core_t *gl = (gl_core_t*)data; if (!gl) return; gl_core_context_bind_hw_render(gl, false); - menu_filter = settings->bools.menu_linear_filter ? GL_LINEAR : GL_NEAREST; if (gl->menu_texture) glDeleteTextures(1, &gl->menu_texture); glGenTextures(1, &gl->menu_texture); glBindTexture(GL_TEXTURE_2D, gl->menu_texture); - glTexStorage2D(GL_TEXTURE_2D, 1, rgb32 ? GL_RGBA8 : GL_RGBA4, width, height); + glTexStorage2D(GL_TEXTURE_2D, 1, rgb32 + ? GL_RGBA8 : GL_RGBA4, width, height); glPixelStorei(GL_UNPACK_ALIGNMENT, base_size); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, - width, height, GL_RGBA, rgb32 ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_4_4_4_4, frame); + width, height, GL_RGBA, rgb32 + ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_4_4_4_4, frame); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, menu_filter); diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index f651ba23de..8882607c35 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -291,20 +291,23 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, int tmpOrigin; float refresh_rate; bool progressive; - unsigned modetype, viHeightMultiplier, viWidth, tvmode, - max_width, i; - size_t new_fb_pitch = 0; - unsigned new_fb_width = 0; - unsigned new_fb_height = 0; - float y_scale = 0.0f; - uint16_t xfbWidth = 0; - uint16_t xfbHeight = 0; - gx_video_t *gx = (gx_video_t*)data; - settings_t *settings = config_get_ptr(); + unsigned modetype, tvmode, max_width, i; + size_t new_fb_pitch = 0; + unsigned new_fb_width = 0; + unsigned new_fb_height = 0; + float y_scale = 0.0f; + uint16_t xfbWidth = 0; + uint16_t xfbHeight = 0; + gx_video_t *gx = (gx_video_t*)data; + settings_t *settings = config_get_ptr(); + unsigned viHeightMultiplier = 1; + bool vfilter = settings->bools.video_vfilter; + unsigned viWidth = settings->uints.video_viwidth; + unsigned rgui_aspect_ratio = settings->uints.menu_rgui_aspect_ratio; /* stop vsync callback */ VIDEO_SetPostRetraceCallback(NULL); - g_draw_done = false; + g_draw_done = false; /* wait for next even field */ /* this prevents screen artifacts when switching * between interlaced & non-interlaced modes */ @@ -313,8 +316,6 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, VIDEO_SetBlack(true); VIDEO_Flush(); - viHeightMultiplier = 1; - viWidth = settings->uints.video_viwidth; #if defined(HW_RVL) progressive = CONF_GetProgressiveScan() > 0 && VIDEO_HaveComponentCable(); @@ -401,22 +402,26 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, gx_used_system_xOrigin = gx_system_xOrigin; if(gx_used_system_xOrigin > 0) { - while(viWidth + gx_used_system_xOrigin > 720) gx_used_system_xOrigin--; + while (viWidth + gx_used_system_xOrigin > 720) + gx_used_system_xOrigin--; } else if(gx_used_system_xOrigin < 0) { - while(viWidth + gx_used_system_xOrigin > 720) gx_used_system_xOrigin++; + while (viWidth + gx_used_system_xOrigin > 720) + gx_used_system_xOrigin++; } tmpOrigin = (max_width - gx_mode.viWidth) / 2; if(gx_system_xOrigin > 0) { - while(!gx_isValidXOrigin(tmpOrigin)) tmpOrigin--; + while (!gx_isValidXOrigin(tmpOrigin)) + tmpOrigin--; } else if(gx_system_xOrigin < 0) { - while(!gx_isValidXOrigin(tmpOrigin)) tmpOrigin++; + while (!gx_isValidXOrigin(tmpOrigin)) + tmpOrigin++; } gx_mode.viXOrigin = gx_xOrigin = tmpOrigin; @@ -424,20 +429,27 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, (max_height - gx_mode.viHeight) / (2 * viHeightMultiplier); gx_xOriginNeg = 0, gx_xOriginPos = 0; - while(gx_isValidXOrigin(gx_mode.viXOrigin+(gx_xOriginNeg-1))) gx_xOriginNeg--; - while(gx_isValidXOrigin(gx_mode.viXOrigin+(gx_xOriginPos+1))) gx_xOriginPos++; - gx_yOriginNeg = 0, gx_yOriginPos = 0; - while(gx_isValidYOrigin(gx_mode.viYOrigin+(gx_yOriginNeg-1))) gx_yOriginNeg--; - while(gx_isValidYOrigin(gx_mode.viYOrigin+(gx_yOriginPos+1))) gx_yOriginPos++; - gx_mode.xfbMode = modetype == VI_INTERLACE ? VI_XFBMODE_DF : VI_XFBMODE_SF; + while (gx_isValidXOrigin(gx_mode.viXOrigin+(gx_xOriginNeg-1))) + gx_xOriginNeg--; + while (gx_isValidXOrigin(gx_mode.viXOrigin+(gx_xOriginPos+1))) + gx_xOriginPos++; + gx_yOriginNeg = 0, gx_yOriginPos = 0; + while (gx_isValidYOrigin(gx_mode.viYOrigin+(gx_yOriginNeg-1))) + gx_yOriginNeg--; + while (gx_isValidYOrigin(gx_mode.viYOrigin+(gx_yOriginPos+1))) + gx_yOriginPos++; + + gx_mode.xfbMode = (modetype == VI_INTERLACE) + ? VI_XFBMODE_DF + : VI_XFBMODE_SF; gx_mode.field_rendering = GX_FALSE; - gx_mode.aa = GX_FALSE; + gx_mode.aa = GX_FALSE; for (i = 0; i < 12; i++) gx_mode.sample_pattern[i][0] = gx_mode.sample_pattern[i][1] = 6; - if (modetype != VI_NON_INTERLACE && settings->bools.video_vfilter) + if (modetype != VI_NON_INTERLACE && vfilter) { gx_mode.vfilter[0] = 8; gx_mode.vfilter[1] = 8; @@ -475,7 +487,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, * 424 since this is the nearest to the RGUI 'standard' * for 16:9 aspect ratios which is supported by the Wii * - i.e. last two bits of value must be zero, so 426->424) */ - switch (settings->uints.menu_rgui_aspect_ratio) + switch (rgui_aspect_ratio) { case RGUI_ASPECT_RATIO_16_9: case RGUI_ASPECT_RATIO_16_9_CENTRE: @@ -605,15 +617,14 @@ static void setup_video_mode(gx_video_t *gx) gx_set_video_mode(gx, width, height, true); } -static void init_texture(void *data, unsigned width, unsigned height) +static void init_texture(void *data, unsigned width, unsigned height, + unsigned g_filter) { size_t fb_pitch; unsigned fb_width, fb_height; gx_video_t *gx = (gx_video_t*)data; GXTexObj *fb_ptr = (GXTexObj*)&g_tex.obj; GXTexObj *menu_ptr = (GXTexObj*)&menu_tex.obj; - settings_t *settings = config_get_ptr(); - unsigned g_filter = settings->bools.video_smooth ? GX_LINEAR : GX_NEAR; width &= ~3; height &= ~3; @@ -632,10 +643,10 @@ static void init_texture(void *data, unsigned width, unsigned height) GX_InvalidateTexAll(); } -static void init_vtx(void *data, const video_info_t *video) +static void init_vtx(gx_video_t *gx, const video_info_t *video, + bool video_smooth) { Mtx44 m; - gx_video_t *gx = (gx_video_t*)data; uint32_t level = 0; _CPU_ISR_Disable(level); referenceRetraceCount = retraceCount; @@ -696,7 +707,8 @@ static void init_vtx(void *data, const video_info_t *video) gx->scale = video->input_scale; gx->should_resize = true; - init_texture(data, g_tex.width, g_tex.height); + init_texture(data, g_tex.width, g_tex.height, + video_smooth ? GX_LINEAR : GX_NEAR); GX_Flush(); } @@ -763,9 +775,10 @@ static void gx_efb_screenshot(void) static void *gx_init(const video_info_t *video, input_driver_t **input, void **input_data) { - settings_t *settings = config_get_ptr(); void *gxinput = NULL; + settings_t *settings = config_get_ptr(); gx_video_t *gx = (gx_video_t*)calloc(1, sizeof(gx_video_t)); + bool video_smooth = settings->bools.video_smooth; if (!gx) return NULL; @@ -778,7 +791,7 @@ static void *gx_init(const video_info_t *video, g_vsync = video->vsync; setup_video_mode(gx); - init_vtx(gx, video); + init_vtx(gx, video, video_smooth); build_disp_list(); gx->vp.full_width = gx_mode.fbWidth; @@ -920,27 +933,26 @@ static void convert_texture32(const uint32_t *_src, uint32_t *_dst, } } -static void gx_resize(void *data, settings_t *settings) +static void gx_resize(gx_video_t *gx, + bool video_smooth, + unsigned aspect_ratio_idx, + unsigned overscan_corr_top, + unsigned overscan_corr_bottom) { int gamma; unsigned degrees; - unsigned width, height; Mtx44 m1, m2; float top = 1, bottom = -1, left = -1, right = 1; int x = 0, y = 0; - gx_video_t *gx = (gx_video_t*)data; const global_t *global = global_get_ptr(); - - if (!gx || !settings) - return; - - width = gx->vp.full_width; - height = gx->vp.full_height; + unsigned width = gx->vp.full_width; + unsigned height = gx->vp.full_height; #ifdef HW_RVL VIDEO_SetTrapFilter(global->console.softfilter_enable); gamma = global->console.screen.gamma_correction; - if(gamma == 0) gamma = 10; //default 1.0 gamma value + if(gamma == 0) + gamma = 10; /* default 1.0 gamma value */ VIDEO_SetGamma(gamma); #else gamma = global->console.screen.gamma_correction; @@ -957,7 +969,7 @@ static void gx_resize(void *data, settings_t *settings) g_orientation == ORIENTATION_FLIPPED_ROTATED) desired_aspect = 1.0 / desired_aspect; - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { struct video_viewport *custom_vp = video_viewport_get_custom(); @@ -1005,20 +1017,21 @@ static void gx_resize(void *data, settings_t *settings) } /* Overscan correction */ - if ((settings->uints.video_overscan_correction_top > 0) || - (settings->uints.video_overscan_correction_bottom > 0)) + if ((overscan_corr_top > 0) || + (overscan_corr_bottom > 0)) { float current_aspect = (float)width / (float)height; - int new_height = height - (settings->uints.video_overscan_correction_top + - settings->uints.video_overscan_correction_bottom); + int new_height = height - + (overscan_corr_top + + overscan_corr_bottom); int new_width = (int)((new_height * current_aspect) + 0.5f); if ((new_height > 0) && (new_width > 0)) { - x += (int)((float)(width - new_width) * 0.5f); - y += (int)settings->uints.video_overscan_correction_top; - width = (unsigned)new_width; - height = (unsigned)new_height; + x += (int)((float)(width - new_width) * 0.5f); + y += (int)overscan_corr_top; + width = (unsigned)new_width; + height = (unsigned)new_height; } } @@ -1086,7 +1099,8 @@ static void gx_resize(void *data, settings_t *settings) c_guMtxConcat(m1, m2, m1); GX_LoadPosMtxImm(m1, GX_PNMTX0); - init_texture(data, 4, 4); + init_texture(data, 4, 4, + video_smooth ? GX_LINEAR : GX_NEAR); gx_old_width = gx_old_height = 0; gx->should_resize = false; } @@ -1538,6 +1552,8 @@ static bool gx_frame(void *data, const void *frame, gx_video_t *gx = (gx_video_t*)data; u8 clear_efb = GX_FALSE; uint32_t level = 0; + unsigned overscan_corr_top = settings->uints.video_overscan_correction_top; + unsigned overscan_corr_bottom = settings->uints.video_overscan_correction_bottom; fps_text_buf[0] = '\0'; @@ -1547,17 +1563,21 @@ static bool gx_frame(void *data, const void *frame, if (!frame) width = height = 4; /* draw a black square in the background */ - if ((gx->overscan_correction_top != settings->uints.video_overscan_correction_top) || - (gx->overscan_correction_bottom != settings->uints.video_overscan_correction_bottom)) + if ((gx->overscan_correction_top != overscan_corr_top) || + (gx->overscan_correction_bottom != overscan_corr_bottom)) { - gx->overscan_correction_top = settings->uints.video_overscan_correction_top; - gx->overscan_correction_bottom = settings->uints.video_overscan_correction_bottom; - gx->should_resize = true; + gx->overscan_correction_top = overscan_corr_top; + gx->overscan_correction_bottom = overscan_corr_bottom; + gx->should_resize = true; } if(gx->should_resize) { - gx_resize(gx, settings); + gx_resize(gx, + settings->bools.video_smooth, + settings->uints.video_aspect_ratio_idx, + settings->uints.video_overscan_correction_top, + settings->uints.video_overscan_correction_bottom); clear_efb = GX_TRUE; } @@ -1569,7 +1589,8 @@ static bool gx_frame(void *data, const void *frame, if (width != gx_old_width || height != gx_old_height) { - init_texture(data, width, height); + init_texture(data, width, height, + settings->bools.video_smooth ? GX_LINEAR : GX_NEAR); gx_old_width = width; gx_old_height = height; } diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index f65b78db30..8a0ed49797 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -574,6 +574,7 @@ static int omapfb_init(omapfb_data_t *pdata, unsigned bpp) const char *fbname = omapfb_get_fb_device(); int fd = open(fbname, O_RDWR); settings_t *settings = config_get_ptr(); + bool video_vsync = settings->bools.video_vsync; if (fd == -1) { @@ -597,7 +598,7 @@ static int omapfb_init(omapfb_data_t *pdata, unsigned bpp) /* always use triple buffering to reduce chance of tearing */ pdata->bpp = bpp; pdata->num_pages = 3; - pdata->sync = settings->bools.video_vsync; + pdata->sync = video_vsync; return 0; } @@ -822,21 +823,27 @@ static void omap_gfx_free(void *data) static void omap_init_font(omap_video_t *vid, const char *font_path, unsigned font_size) { int r, g, b; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + bool video_font_enable = settings->bools.video_font_enable; + const char *path_font = settings->paths.path_font; + float video_font_size = settings->floats.video_font_size; + float msg_color_r = settings->floats.video_msg_color_r; + float msg_color_g = settings->floats.video_msg_color_g; + float msg_color_b = settings->floats.video_msg_color_b; - if (!settings->bools.video_font_enable) + if (!video_font_enable) return; if (!(font_renderer_create_default(&vid->font_driver, &vid->font, - *settings->paths.path_font ? settings->paths.path_font : NULL, settings->video.font_size))) + *path_font ? path_font : NULL, video_font_size))) { RARCH_LOG("[video_omap]: font init failed\n"); return; } - r = settings->floats.video_msg_color_r * 255; - g = settings->floats.video_msg_color_g * 255; - b = settings->floats.video_msg_color_b * 255; + r = msg_color_r * 255; + g = msg_color_g * 255; + b = msg_color_b * 255; r = (r < 0) ? 0 : (r > 255 ? 255 : r); g = (g < 0) ? 0 : (g > 255 ? 255 : g); @@ -851,8 +858,10 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) { const struct font_atlas *atlas = NULL; settings_t *settings = config_get_ptr(); - int msg_base_x = settings->floats.video_msg_pos_x * vid->width; - int msg_base_y = (1.0 - settings->floats.video_msg_pos_y) * vid->height; + float msg_pos_x = settings->floats.video_msg_pos_x; + float msg_pos_y = settings->floats.video_msg_pos_y; + int msg_base_x = msg_pos_x * vid->width; + int msg_base_y = (1.0 - msg_pos_y) * vid->height; if (!vid->font) return; diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 34311fb60b..2f4c2baa45 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -455,7 +455,8 @@ static void *psp_init(const video_info_t *video, if (input && input_data) { settings_t *settings = config_get_ptr(); - pspinput = input_psp.init(settings->arrays.input_joypad_driver); + pspinput = input_psp.init( + settings->arrays.input_joypad_driver); *input = pspinput ? &input_psp : NULL; *input_data = pspinput; } @@ -524,7 +525,8 @@ static bool psp_frame(void *data, const void *frame, if (frame) { sceKernelDcacheWritebackRange(frame,pitch * height); - sceGuCopyImage(psp->rgb32? GU_PSM_8888 : GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2, + sceGuCopyImage(psp->rgb32? GU_PSM_8888 : GU_PSM_5650, + ((u32)frame & 0xF) >> psp->bpp_log2, 0, width, height, pitch >> psp->bpp_log2, (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture); } @@ -556,24 +558,9 @@ static void psp_set_nonblock_state(void *data, bool toggle, psp->vsync = !toggle; } -static bool psp_alive(void *data) -{ - (void)data; - return true; -} - -static bool psp_focus(void *data) -{ - (void)data; - return true; -} - -static bool psp_suppress_screensaver(void *data, bool enable) -{ - (void)data; - (void)enable; - return false; -} +static bool psp_alive(void *data) { return true; } +static bool psp_focus(void *data) { return true; } +static bool psp_suppress_screensaver(void *data, bool enable) { return false; } static void psp_free(void *data) { @@ -662,14 +649,16 @@ static void psp_set_texture_enable(void *data, bool state, bool full_screen) static void psp_update_viewport(psp1_video_t* psp, video_frame_info_t *video_info) { - int x = 0; - int y = 0; - float device_aspect = ((float)SCEGU_SCR_WIDTH) / SCEGU_SCR_HEIGHT; - float width = SCEGU_SCR_WIDTH; - float height = SCEGU_SCR_HEIGHT; - settings_t *settings = config_get_ptr(); + int x = 0; + int y = 0; + float device_aspect = ((float)SCEGU_SCR_WIDTH) / SCEGU_SCR_HEIGHT; + float width = SCEGU_SCR_WIDTH; + float height = SCEGU_SCR_HEIGHT; + settings_t *settings = config_get_ptr(); + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; - if (settings->bools.video_scale_integer) + if (video_scale_integer) { video_viewport_get_scaled_integer(&psp->vp, SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT, video_driver_get_aspect_ratio(), psp->keep_aspect); @@ -679,7 +668,7 @@ static void psp_update_viewport(psp1_video_t* psp, else if (psp->keep_aspect) { #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { x = video_info->custom_vp_x; y = video_info->custom_vp_y; @@ -723,13 +712,14 @@ static void psp_update_viewport(psp1_video_t* psp, } else { - psp->vp.x = psp->vp.y = 0; - psp->vp.width = width; + psp->vp.x = 0; + psp->vp.y = 0; + psp->vp.width = width; psp->vp.height = height; } - psp->vp.width += psp->vp.width&0x1; - psp->vp.height += psp->vp.height&0x1; + psp->vp.width += psp->vp.width & 0x1; + psp->vp.height += psp->vp.height & 0x1; psp_set_screen_coords(psp->frame_coords, psp->vp.x, psp->vp.y, psp->vp.width, psp->vp.height, psp->rotation); @@ -740,12 +730,12 @@ static void psp_update_viewport(psp1_video_t* psp, static void psp_set_rotation(void *data, unsigned rotation) { - psp1_video_t *psp = (psp1_video_t*)data; + psp1_video_t *psp = (psp1_video_t*)data; if (!psp) return; - psp->rotation = rotation; + psp->rotation = rotation; psp->should_resize = true; } static void psp_set_filtering(void *data, unsigned index, bool smooth) @@ -827,12 +817,9 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle) { void* src_buffer; int i, j, src_bufferwidth, src_pixelformat, src_x, src_y, src_x_max, src_y_max; - uint8_t* dst = buffer; + uint8_t *dst = buffer; psp1_video_t *psp = (psp1_video_t*)data; - (void)data; - (void)buffer; - sceDisplayGetFrameBuf(&src_buffer, &src_bufferwidth, &src_pixelformat, PSP_DISPLAY_SETBUF_NEXTFRAME); src_x = (psp->vp.x > 0)? psp->vp.x : 0; @@ -906,15 +893,7 @@ static bool psp_read_viewport(void *data, uint8_t *buffer, bool is_idle) return false; } -static bool psp_set_shader(void *data, - enum rarch_shader_type type, const char *path) -{ - (void)data; - (void)type; - (void)path; - - return false; -} +static bool psp_set_shader(void *data, enum rarch_shader_type type, const char *path) { return false; } video_driver_t video_psp1 = { psp_init, diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index e7f62ab858..17fd44d972 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -88,26 +88,32 @@ static void sdl_gfx_free(void *data) free(vid); } -static void sdl_init_font(sdl_video_t *vid, const char *font_path, unsigned font_size) +static void sdl_init_font(sdl_video_t *vid, + bool video_font_enable, + const char *path_font, + float video_font_size, + float msg_color_r, + float msg_color_g, + float msg_color_b + ) { int r, g, b; - settings_t *settings = config_get_ptr(); - if (!settings->bools.video_font_enable) + if (!video_font_enable) return; if (!font_renderer_create_default( &vid->font_driver, &vid->font, - *settings->paths.path_font ? settings->paths.path_font : NULL, - settings->floats.video_font_size)) + *path_font ? path_font : NULL, + video_font_size)) { RARCH_LOG("[SDL]: Could not initialize fonts.\n"); return; } - r = settings->floats.video_msg_color_r * 255; - g = settings->floats.video_msg_color_g * 255; - b = settings->floats.video_msg_color_b * 255; + r = msg_color_r * 255; + g = msg_color_g * 255; + b = msg_color_b * 255; r = (r < 0) ? 0 : (r > 255 ? 255 : r); g = (g < 0) ? 0 : (g > 255 ? 255 : g); @@ -118,33 +124,39 @@ static void sdl_init_font(sdl_video_t *vid, const char *font_path, unsigned font vid->font_b = b; } -static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, - const char *msg, unsigned width, unsigned height, - const SDL_PixelFormat *fmt) +static void sdl_render_msg( + sdl_video_t *vid, + SDL_Surface *buffer, + const char *msg, + unsigned width, + unsigned height, + const SDL_PixelFormat *fmt, + float msg_pos_x, + float msg_pos_y + ) { int x, y, msg_base_x, msg_base_y; unsigned rshift, gshift, bshift; const struct font_atlas *atlas = NULL; - settings_t *settings = config_get_ptr(); if (!vid->font) return; - atlas = vid->font_driver->get_atlas(vid->font); + atlas = vid->font_driver->get_atlas(vid->font); - msg_base_x = settings->floats.video_msg_pos_x * width; - msg_base_y = (1.0f - settings->floats.video_msg_pos_y) * height; + msg_base_x = msg_pos_x * width; + msg_base_y = (1.0f - msg_pos_y) * height; - rshift = fmt->Rshift; - gshift = fmt->Gshift; - bshift = fmt->Bshift; + rshift = fmt->Rshift; + gshift = fmt->Gshift; + bshift = fmt->Bshift; for (; *msg; msg++) { int glyph_width, glyph_height; int base_x, base_y, max_width, max_height; - uint32_t *out = NULL; - const uint8_t *src = NULL; + uint32_t *out = NULL; + const uint8_t *src = NULL; const struct font_glyph *glyph = vid->font_driver->get_glyph(vid->font, (uint8_t)*msg); if (!glyph) continue; @@ -152,23 +164,23 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, glyph_width = glyph->width; glyph_height = glyph->height; - base_x = msg_base_x + glyph->draw_offset_x; - base_y = msg_base_y + glyph->draw_offset_y; - src = atlas->buffer + glyph->atlas_offset_x + base_x = msg_base_x + glyph->draw_offset_x; + base_y = msg_base_y + glyph->draw_offset_y; + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) { - src -= base_x; + src -= base_x; glyph_width += base_x; - base_x = 0; + base_x = 0; } if (base_y < 0) { - src -= base_y * (int)atlas->width; + src -= base_y * (int)atlas->width; glyph_height += base_y; - base_y = 0; + base_y = 0; } max_width = width - base_x; @@ -182,22 +194,25 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, if (glyph_height > max_height) glyph_height = max_height; - out = (uint32_t*)buffer->pixels + base_y * (buffer->pitch >> 2) + base_x; + out = (uint32_t*)buffer->pixels + base_y + * (buffer->pitch >> 2) + base_x; for (y = 0; y < glyph_height; y++, src += atlas->width, out += buffer->pitch >> 2) { for (x = 0; x < glyph_width; x++) { - unsigned blend = src[x]; + unsigned blend = src[x]; unsigned out_pix = out[x]; - unsigned r = (out_pix >> rshift) & 0xff; - unsigned g = (out_pix >> gshift) & 0xff; - unsigned b = (out_pix >> bshift) & 0xff; + unsigned r = (out_pix >> rshift) & 0xff; + unsigned g = (out_pix >> gshift) & 0xff; + unsigned b = (out_pix >> bshift) & 0xff; - unsigned out_r = (r * (256 - blend) + vid->font_r * blend) >> 8; - unsigned out_g = (g * (256 - blend) + vid->font_g * blend) >> 8; - unsigned out_b = (b * (256 - blend) + vid->font_b * blend) >> 8; - out[x] = (out_r << rshift) | (out_g << gshift) | (out_b << bshift); + unsigned out_r = (r * (256 - blend) + vid->font_r * blend) >> 8; + unsigned out_g = (g * (256 - blend) + vid->font_g * blend) >> 8; + unsigned out_b = (b * (256 - blend) + vid->font_b * blend) >> 8; + out[x] = (out_r << rshift) | + (out_g << gshift) | + (out_b << bshift); } } @@ -233,8 +248,10 @@ static void *sdl_gfx_init(const video_info_t *video, { unsigned full_x, full_y; const SDL_VideoInfo *video_info = NULL; - sdl_video_t *vid = NULL; - settings_t *settings = config_get_ptr(); + sdl_video_t *vid = NULL; + settings_t *settings = config_get_ptr(); + const char *path_font = settings->paths.path_font; + float video_font_size = settings->floats.video_font_size; #ifdef HAVE_X11 XInitThreads(); @@ -295,7 +312,12 @@ static void *sdl_gfx_init(const video_info_t *video, } } - sdl_init_font(vid, settings->paths.path_font, settings->floats.video_font_size); + sdl_init_font(vid, + settings->bools.video_font_enable + path_font, video_font_size, + settings->floats.video_msg_color_r, + settings->floats.video_msg_color_g, + settings->floats.video_msg_color_b); vid->scaler.scaler_type = video->smooth ? SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; vid->scaler.in_fmt = video->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; @@ -373,7 +395,9 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, if (msg) sdl_render_msg(vid, vid->screen, - msg, vid->screen->w, vid->screen->h, vid->screen->format); + msg, vid->screen->w, vid->screen->h, vid->screen->format, + video_info->font_msg_pos_x, + video_info->font_msg_pos_y); if (SDL_MUSTLOCK(vid->screen)) SDL_UnlockSurface(vid->screen); diff --git a/gfx/drivers/sixel_gfx.c b/gfx/drivers/sixel_gfx.c index 80cc71eeb9..abe10223e9 100644 --- a/gfx/drivers/sixel_gfx.c +++ b/gfx/drivers/sixel_gfx.c @@ -192,6 +192,7 @@ static void *sixel_gfx_init(const video_info_t *video, gfx_ctx_input_t inp; void *ctx_data = NULL; settings_t *settings = config_get_ptr(); + bool video_font_enable = settings->bools.video_font_enable; sixel_t *sixel = (sixel_t*)calloc(1, sizeof(*sixel)); const gfx_ctx_driver_t *ctx_driver = NULL; const char *scale_str = NULL; @@ -238,7 +239,7 @@ static void *sixel_gfx_init(const video_info_t *video, video_context_driver_input_driver(&inp); - if (settings->bools.video_font_enable) + if (video_font_enable) font_driver_init_osd(sixel, video, false, diff --git a/gfx/drivers/switch_nx_gfx.c b/gfx/drivers/switch_nx_gfx.c index e60d6dd7a4..56d9076f10 100644 --- a/gfx/drivers/switch_nx_gfx.c +++ b/gfx/drivers/switch_nx_gfx.c @@ -186,17 +186,16 @@ static void *switch_init(const video_info_t *video, framebufferCreate(&sw->fb, sw->win, 1280, 720, PIXEL_FORMAT_RGBA_8888, 2); framebufferMakeLinear(&sw->fb); - printf("loading switch gfx driver, width: %d, height: %d threaded: %d smooth %d\n", video->width, video->height, video->is_threaded, video->smooth); - sw->vp.x = 0; - sw->vp.y = 0; - sw->vp.width = sw->o_width = video->width; - sw->vp.height = sw->o_height = video->height; + sw->vp.x = 0; + sw->vp.y = 0; + sw->vp.width = sw->o_width = video->width; + sw->vp.height = sw->o_height = video->height; sw->overlay_enabled = false; - sw->overlay = NULL; - sw->in_menu = false; + sw->overlay = NULL; + sw->in_menu = false; - sw->vp.full_width = 1280; - sw->vp.full_height = 720; + sw->vp.full_width = 1280; + sw->vp.full_height = 720; /* Sanity check */ sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); @@ -256,14 +255,6 @@ static void switch_update_viewport(switch_video_t *sw, desired_aspect = video_driver_get_aspect_ratio(); - /* We crash if >1.0f */ - printf("[Video] Aspect: %f\n", desired_aspect); - /*if (desired_aspect > 1.8f) - desired_aspect = 1.7778f; - - if (desired_aspect < 1.2f && desired_aspect != 0.0f) - desired_aspect = 1.0f;*/ - if (settings->bools.video_scale_integer) { video_viewport_get_scaled_integer(&sw->vp, sw->vp.full_width, sw->vp.full_height, desired_aspect, sw->keep_aspect); @@ -355,9 +346,9 @@ static void switch_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) } static bool switch_frame(void *data, const void *frame, - unsigned width, unsigned height, - uint64_t frame_count, unsigned pitch, - const char *msg, video_frame_info_t *video_info) + unsigned width, unsigned height, + uint64_t frame_count, unsigned pitch, + const char *msg, video_frame_info_t *video_info) { switch_video_t *sw = data; uint32_t *out_buffer = NULL; @@ -373,23 +364,24 @@ static bool switch_frame(void *data, const void *frame, return true; } - if (sw->should_resize || width != sw->last_width || height != sw->last_height) + if ( sw->should_resize || + width != sw->last_width || + height != sw->last_height) { - printf("[Video] Requesting new size: width %i height %i\n", width, height); - printf("[Video] fw: %i fh: %i w: %i h: %i x: %i y: %i\n", sw->vp.full_width, sw->vp.full_height, sw->vp.width, sw->vp.height, sw->vp.x, sw->vp.y); switch_update_viewport(sw, video_info); - printf("[Video] fw: %i fh: %i w: %i h: %i x: %i y: %i\n", sw->vp.full_width, sw->vp.full_height, sw->vp.width, sw->vp.height, sw->vp.x, sw->vp.y); /* Sanity check */ - sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); + sw->vp.width = MIN(sw->vp.width, sw->vp.full_width); sw->vp.height = MIN(sw->vp.height, sw->vp.full_height); scaler_ctx_gen_reset(&sw->scaler); - sw->scaler.in_width = width; + sw->scaler.in_width = width; sw->scaler.in_height = height; sw->scaler.in_stride = pitch; - sw->scaler.in_fmt = sw->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565; + sw->scaler.in_fmt = sw->rgb32 + ? SCALER_FMT_ARGB8888 + : SCALER_FMT_RGB565; if (!sw->smooth) { @@ -420,10 +412,7 @@ static bool switch_frame(void *data, const void *frame, sw->scaler.scaler_type = SCALER_TYPE_POINT; if (!scaler_ctx_gen_filter(&sw->scaler)) - { - printf("failed to generate scaler for main image\n"); return false; - } sw->last_width = width; sw->last_height = height; @@ -587,10 +576,7 @@ static void switch_set_texture_frame( sw->menu_texture.pixels = malloc(sz); if (!sw->menu_texture.pixels) - { - printf("failed to allocate buffer for menu texture\n"); return; - } xsf = 1280 / width; ysf = 720 / height; @@ -619,10 +605,7 @@ static void switch_set_texture_frame( sctx->scaler_type = SCALER_TYPE_POINT; if (!scaler_ctx_gen_filter(sctx)) - { - printf("failed to generate scaler for menu texture\n"); return; - } } memcpy(sw->menu_texture.pixels, frame, sz); @@ -650,8 +633,6 @@ static void switch_set_texture_enable(void *data, bool enable, bool full_screen) #ifdef HAVE_OVERLAY static void switch_overlay_enable(void *data, bool state) { - printf("[Video] Enabled Overlay\n"); - switch_video_t *swa = (switch_video_t *)data; if (!swa) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index f1aefbd89b..42983baf06 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -114,6 +114,11 @@ static void *vg_init(const video_info_t *video, unsigned temp_height = 0; void *ctx_data = NULL; settings_t *settings = config_get_ptr(); + const char *path_font = settings->paths.path_font; + float video_font_size = settings->floats.video_font_size; + float video_msg_color_r = settings->floats.video_msg_color_r; + float video_msg_color_g = settings->floats.video_msg_color_g; + float video_msg_color_b = settings->floats.video_msg_color_b; vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t)); const gfx_ctx_driver_t *ctx = video_context_driver_init_first( vg, settings->arrays.video_context_driver, @@ -174,23 +179,24 @@ static void *vg_init(const video_info_t *video, video_driver_get_size(&temp_width, &temp_height); - temp_width = 0; - temp_height = 0; - mode.width = 0; - mode.height = 0; + temp_width = 0; + temp_height = 0; + mode.width = 0; + mode.height = 0; video_context_driver_get_video_size(&mode); - temp_width = mode.width; - temp_height = mode.height; - mode.width = 0; - mode.height = 0; + temp_width = mode.width; + temp_height = mode.height; + mode.width = 0; + mode.height = 0; vg->should_resize = true; if (temp_width != 0 && temp_height != 0) { - RARCH_LOG("[VG]: Verified window resolution %ux%u.\n", temp_width, temp_height); + RARCH_LOG("[VG]: Verified window resolution %ux%u.\n", + temp_width, temp_height); video_driver_set_size(temp_width, temp_height); } @@ -207,8 +213,13 @@ static void *vg_init(const video_info_t *video, vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vg->mTextureWidth = vg->mTextureHeight = video->input_scale * RARCH_SCALE_BASE; - vg->mImage = vgCreateImage(vg->mTexType, vg->mTextureWidth, vg->mTextureHeight, - video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED); + vg->mImage = vgCreateImage( + vg->mTexType, + vg->mTextureWidth, + vg->mTextureHeight, + video->smooth + ? VG_IMAGE_QUALITY_BETTER + : VG_IMAGE_QUALITY_NONANTIALIASED); vg_set_nonblock_state(vg, !video->vsync); inp.input = input; @@ -219,7 +230,8 @@ static void *vg_init(const video_info_t *video, if ( video->font_enable && font_renderer_create_default( &vg->font_driver, &vg->mFontRenderer, - *settings->paths.path_font ? settings->paths.path_font : NULL, settings->floats.video_font_size)) + *path_font ? path_font : NULL, + video_font_size)) { vg->mFont = vgCreateFont(0); @@ -229,19 +241,19 @@ static void *vg_init(const video_info_t *video, VGfloat paintBg[4]; vg->mFontsOn = true; - vg->mFontHeight = settings->floats.video_font_size; + vg->mFontHeight = video_font_size; vg->mPaintFg = vgCreatePaint(); vg->mPaintBg = vgCreatePaint(); - paintFg[0] = settings->floats.video_msg_color_r; - paintFg[1] = settings->floats.video_msg_color_g; - paintFg[2] = settings->floats.video_msg_color_b; - paintFg[3] = 1.0f; + paintFg[0] = video_msg_color_r; + paintFg[1] = video_msg_color_g; + paintFg[2] = video_msg_color_b; + paintFg[3] = 1.0f; - paintBg[0] = settings->floats.video_msg_color_r / 2.0f; - paintBg[1] = settings->floats.video_msg_color_g / 2.0f; - paintBg[2] = settings->floats.video_msg_color_b / 2.0f; - paintBg[3] = 0.5f; + paintBg[0] = video_msg_color_r / 2.0f; + paintBg[1] = video_msg_color_g / 2.0f; + paintBg[2] = video_msg_color_b / 2.0f; + paintBg[3] = 0.5f; vgSetParameteri(vg->mPaintFg, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); vgSetParameterfv(vg->mPaintFg, VG_PAINT_COLOR, 4, paintFg); diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index e66344a748..92df09d4e7 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -360,14 +360,16 @@ static void vita2d_set_projection(vita_video_t *vita, static void vita2d_gfx_update_viewport(vita_video_t* vita, video_frame_info_t *video_info) { - int x = 0; - int y = 0; - float device_aspect = ((float)PSP_FB_WIDTH) / PSP_FB_HEIGHT; - float width = PSP_FB_WIDTH; - float height = PSP_FB_HEIGHT; - settings_t *settings = config_get_ptr(); + int x = 0; + int y = 0; + float device_aspect = ((float)PSP_FB_WIDTH) / PSP_FB_HEIGHT; + float width = PSP_FB_WIDTH; + float height = PSP_FB_HEIGHT; + settings_t *settings = config_get_ptr(); + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; - if (settings->bools.video_scale_integer) + if (video_scale_integer) { video_viewport_get_scaled_integer(&vita->vp, PSP_FB_WIDTH, PSP_FB_HEIGHT, video_driver_get_aspect_ratio(), vita->keep_aspect); @@ -385,7 +387,7 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita, height = PSP_FB_WIDTH; } #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { x = video_info->custom_vp_x; y = video_info->custom_vp_y; @@ -435,15 +437,16 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita, } else { - vita->vp.x = vita->vp.y = 0; - vita->vp.width = width; + vita->vp.x = 0; + vita->vp.y = 0; + vita->vp.width = width; vita->vp.height = height; } - vita->vp.width += vita->vp.width&0x1; - vita->vp.height += vita->vp.height&0x1; + vita->vp.width += vita->vp.width&0x1; + vita->vp.height += vita->vp.height&0x1; - vita->should_resize = false; + vita->should_resize = false; } @@ -451,18 +454,20 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate) { gfx_ctx_aspect_t aspect_data; - int x = 0; - int y = 0; - float device_aspect = (float)viewport_width / viewport_height; - struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; - settings_t *settings = config_get_ptr(); - vita_video_t *vita = (vita_video_t*)data; + int x = 0; + int y = 0; + float device_aspect = (float)viewport_width / viewport_height; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; + settings_t *settings = config_get_ptr(); + vita_video_t *vita = (vita_video_t*)data; + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; - aspect_data.aspect = &device_aspect; - aspect_data.width = viewport_width; - aspect_data.height = viewport_height; + aspect_data.aspect = &device_aspect; + aspect_data.width = viewport_width; + aspect_data.height = viewport_height; - if (settings->bools.video_scale_integer && !force_full) + if (video_scale_integer && !force_full) { video_viewport_get_scaled_integer(&vita->vp, viewport_width, viewport_height, @@ -475,7 +480,7 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, float desired_aspect = video_driver_get_aspect_ratio(); #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { const struct video_viewport *custom = video_viewport_get_custom(); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 5180e6109f..f1b0e5fbc6 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1119,7 +1119,8 @@ static void vulkan_init_readback(vk_t *vk) */ settings_t *settings = config_get_ptr(); bool recording_enabled = recording_is_enabled(); - vk->readback.streamed = settings->bools.video_gpu_record && recording_enabled; + bool video_gpu_record = settings->bools.video_gpu_record; + vk->readback.streamed = video_gpu_record && recording_enabled; if (!vk->readback.streamed) return; @@ -1459,22 +1460,24 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate) { gfx_ctx_aspect_t aspect_data; - int x = 0; - int y = 0; - float device_aspect = (float)viewport_width / viewport_height; - struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; - settings_t *settings = config_get_ptr(); - vk_t *vk = (vk_t*)data; - unsigned width = vk->video_width; - unsigned height = vk->video_height; + int x = 0; + int y = 0; + float device_aspect = (float)viewport_width / viewport_height; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; + settings_t *settings = config_get_ptr(); + bool video_scale_integer = settings->bools.video_scale_integer; + unsigned aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; + vk_t *vk = (vk_t*)data; + unsigned width = vk->video_width; + unsigned height = vk->video_height; - aspect_data.aspect = &device_aspect; - aspect_data.width = viewport_width; - aspect_data.height = viewport_height; + aspect_data.aspect = &device_aspect; + aspect_data.width = viewport_width; + aspect_data.height = viewport_height; video_context_driver_translate_aspect(&aspect_data); - if (settings->bools.video_scale_integer && !force_full) + if (video_scale_integer && !force_full) { video_viewport_get_scaled_integer(&vk->vp, viewport_width, viewport_height, @@ -1487,7 +1490,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, float desired_aspect = video_driver_get_aspect_ratio(); #if defined(HAVE_MENU) - if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { const struct video_viewport *custom = video_viewport_get_custom(); @@ -1918,7 +1921,8 @@ static bool vulkan_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (vk->menu.enable) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + bool menu_linear_filter = settings->bools.menu_linear_filter; menu_driver_frame(video_info); @@ -1935,7 +1939,7 @@ static bool vulkan_frame(void *data, const void *frame, if (optimal->memory != VK_NULL_HANDLE) quad.texture = optimal; - if (settings->bools.menu_linear_filter) + if (menu_linear_filter) { quad.sampler = optimal->mipmap ? vk->samplers.mipmap_linear : vk->samplers.linear; diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index eefaab966d..3d536a92ae 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -135,23 +135,28 @@ static void xv_init_yuv_tables(xv_t *xv) static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) { - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); + bool video_font_enable = settings->bools.video_font_enable; + const char *path_font = settings->paths.path_font; + float video_font_size = settings->floats.video_font_size; + float msg_color_r = settings->floats.video_msg_color_r; + float msg_color_g = settings->floats.video_msg_color_g; + float msg_color_b = settings->floats.video_msg_color_b; - if (!settings->bools.video_font_enable) + if (!video_font_enable) return; if (font_renderer_create_default( &xv->font_driver, - &xv->font, *settings->paths.path_font - ? settings->paths.path_font : NULL, - settings->floats.video_font_size)) + &xv->font, *path_font + ? path_font : NULL, + video_font_size)) { - int r, g, b; - r = settings->floats.video_msg_color_r * 255; + int r = msg_color_r * 255; + int g = msg_color_g * 255; + int b = msg_color_b * 255; r = (r < 0 ? 0 : (r > 255 ? 255 : r)); - g = settings->floats.video_msg_color_g * 255; g = (g < 0 ? 0 : (g > 255 ? 255 : g)); - b = settings->floats.video_msg_color_b * 255; b = (b < 0 ? 0 : (b > 255 ? 255 : b)); xv_calculate_yuv(&xv->font_y, &xv->font_u, &xv->font_v, @@ -370,11 +375,12 @@ static void xv_calc_out_rect(bool keep_aspect, unsigned vp_width, unsigned vp_height) { settings_t *settings = config_get_ptr(); + bool scale_integer = settings->bools.video_scale_integer; vp->full_width = vp_width; vp->full_height = vp_height; - if (settings->bools.video_scale_integer) + if (scale_integer) video_viewport_get_scaled_integer(vp, vp_width, vp_height, video_driver_get_aspect_ratio(), keep_aspect); else if (!keep_aspect) @@ -439,7 +445,7 @@ static void *xv_init(const video_info_t *video, const struct retro_game_geometry *geom = NULL; struct retro_system_av_info *av_info = NULL; settings_t *settings = config_get_ptr(); - + bool video_disable_composition = settings->bools.video_disable_composition; xv_t *xv = (xv_t*)calloc(1, sizeof(*xv)); if (!xv) return NULL; @@ -563,14 +569,17 @@ static void *xv_init(const video_info_t *video, XFree(visualinfo); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); - if (video->fullscreen && settings->bools.video_disable_composition) + if (video->fullscreen && video_disable_composition) { uint32_t value = 1; Atom cardinal = XInternAtom(g_x11_dpy, "CARDINAL", False); - Atom net_wm_bypass_compositor = XInternAtom(g_x11_dpy, "_NET_WM_BYPASS_COMPOSITOR", False); + Atom net_wm_bypass_compositor = XInternAtom(g_x11_dpy, + "_NET_WM_BYPASS_COMPOSITOR", False); RARCH_LOG("[XVideo]: Requesting compositor bypass.\n"); - XChangeProperty(g_x11_dpy, g_x11_win, net_wm_bypass_compositor, cardinal, 32, PropModeReplace, (const unsigned char*)&value, 1); + XChangeProperty(g_x11_dpy, g_x11_win, + net_wm_bypass_compositor, cardinal, 32, + PropModeReplace, (const unsigned char*)&value, 1); } XMapWindow(g_x11_dpy, g_x11_win); @@ -718,16 +727,18 @@ static void xv_render_msg(xv_t *xv, const char *msg, int x, y, msg_base_x, msg_base_y; unsigned i, luma_index[2], pitch; unsigned chroma_u_index, chroma_v_index; - settings_t *settings = config_get_ptr(); const struct font_atlas *atlas = NULL; + settings_t *settings = config_get_ptr(); + float video_msg_pos_x = settings->floats.video_msg_pos_x; + float video_msg_pos_y = settings->floats.video_msg_pos_y; if (!xv->font) return; atlas = xv->font_driver->get_atlas(xv->font); - msg_base_x = settings->floats.video_msg_pos_x * width; - msg_base_y = height * (1.0f - settings->floats.video_msg_pos_y); + msg_base_x = video_msg_pos_x * width; + msg_base_y = height * (1.0f - video_msg_pos_y); luma_index[0] = xv->luma_index[0]; luma_index[1] = xv->luma_index[1]; @@ -876,13 +887,7 @@ static bool xv_suppress_screensaver(void *data, bool enable) return true; } -static bool xv_has_windowed(void *data) -{ - (void)data; - - /* TODO - verify. */ - return true; -} +static bool xv_has_windowed(void *data) { return true; } static void xv_free(void *data) {