diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 2f8ab1c8f8..74148ac0be 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -2510,23 +2510,6 @@ bool win32_set_video_mode(void *data, return false; return true; } - -void win32_update_title(void) -{ - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - if (window) - { - static char prev_title[128]; - char title[128]; - title[0] = '\0'; - video_driver_get_window_title(title, sizeof(title)); - if (title[0] && !string_is_equal(title, prev_title)) - { - window->set_title(&main_window, title); - strlcpy(prev_title, title, sizeof(prev_title)); - } - } -} #endif bool win32_get_client_rect(RECT* rect) diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 8321d398ed..f044d2c381 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -187,8 +187,6 @@ BOOL IsIconic(HWND hwnd); void win32_setup_pixel_format(HDC hdc, bool supports_gl); -void win32_update_title(void); - RETRO_END_DECLS #endif diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 8926ecd0e1..f722e35f43 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -2537,7 +2537,7 @@ static bool d3d10_gfx_frame( d3d10->flags &= ~D3D10_ST_FLAG_SPRITES_ENABLE; #ifndef __WINRT__ - win32_update_title(); + video_driver_update_title(NULL); #endif DXGIPresent(d3d10->swapChain, d3d10->swap_interval, 0); diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 50820e06a4..f785b74316 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -3305,7 +3305,7 @@ static bool d3d11_gfx_frame( d3d11->flags &= ~D3D11_ST_FLAG_SPRITES_ENABLE; #if defined(_WIN32) && !defined(__WINRT__) - win32_update_title(); + video_driver_update_title(NULL); #endif #ifdef HAVE_DXGI_HDR diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 15b49b1fad..78686d1f04 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -3826,7 +3826,7 @@ static bool d3d12_gfx_frame( d3d12->flags &= ~D3D12_ST_FLAG_SPRITES_ENABLE; #if defined(_WIN32) && !defined(__WINRT__) - win32_update_title(); + video_driver_update_title(NULL); #endif #ifdef HAVE_DXGI_HDR diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 231e394d07..235f03c695 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1850,25 +1850,6 @@ static void d3d8_get_overlay_interface(void *data, } #endif -static void d3d8_update_title(void) -{ -#ifndef _XBOX - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - if (window) - { - char title[128]; - - title[0] = '\0'; - - video_driver_get_window_title(title, sizeof(title)); - - if (title[0]) - window->set_title(&main_window, title); - } -#endif -} - static bool d3d8_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, @@ -1980,7 +1961,7 @@ static bool d3d8_frame(void *data, const void *frame, IDirect3DDevice8_EndScene(d3d->dev); } - d3d8_update_title(); + video_driver_update_title(NULL); IDirect3DDevice8_Present(d3d->dev, NULL, NULL, NULL, NULL); return true; diff --git a/gfx/drivers/d3d9cg.c b/gfx/drivers/d3d9cg.c index 9bb8f62b22..c05991fd5b 100644 --- a/gfx/drivers/d3d9cg.c +++ b/gfx/drivers/d3d9cg.c @@ -2164,7 +2164,7 @@ static bool d3d9_cg_frame(void *data, const void *frame, IDirect3DDevice9_EndScene(d3d->dev); } - win32_update_title(); + video_driver_update_title(NULL); IDirect3DDevice9_Present(d3d->dev, NULL, NULL, NULL, NULL); return true; diff --git a/gfx/drivers/d3d9hlsl.c b/gfx/drivers/d3d9hlsl.c index ea370750dd..1b69fa1ae8 100644 --- a/gfx/drivers/d3d9hlsl.c +++ b/gfx/drivers/d3d9hlsl.c @@ -1754,7 +1754,7 @@ static bool d3d9_hlsl_frame(void *data, const void *frame, IDirect3DDevice9_EndScene(d3d->dev); } - win32_update_title(); + video_driver_update_title(NULL); IDirect3DDevice9_Present(d3d->dev, NULL, NULL, NULL, NULL); return true; diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index ef550521a3..d44fcd37df 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -344,19 +344,6 @@ font_renderer_t gdi_font = { * VIDEO DRIVER */ -static void gfx_ctx_gdi_update_title(void) -{ - char title[128]; - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - title[0] = '\0'; - - video_driver_get_window_title(title, sizeof(title)); - - if (window && title[0]) - window->set_title(&main_window, title); -} - static void gfx_ctx_gdi_get_video_size( unsigned *width, unsigned *height) { @@ -779,7 +766,7 @@ static bool gdi_frame(void *data, const void *frame, InvalidateRect(hwnd, NULL, false); - gfx_ctx_gdi_update_title(); + video_driver_update_title(NULL); return true; } diff --git a/gfx/drivers_context/android_vk_ctx.c b/gfx/drivers_context/android_vk_ctx.c index c6563f954f..3b40bd2216 100644 --- a/gfx/drivers_context/android_vk_ctx.c +++ b/gfx/drivers_context/android_vk_ctx.c @@ -68,7 +68,7 @@ static void *android_gfx_ctx_vk_init(void *video_driver) android_ctx_data_vk_t *and = (android_ctx_data_vk_t*)calloc(1, sizeof(*and)); if (!android_app || !and) - return false; + return NULL; if (!vulkan_context_init(&and->vk, VULKAN_WSI_ANDROID)) { diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 3e0f592acc..840f9d0978 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -544,7 +544,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { cocoa_get_metrics, NULL, /* translate_aspect */ #ifdef OSX - cocoa_update_title, + video_driver_update_title, #else NULL, /* update_title */ #endif diff --git a/gfx/drivers_context/cocoa_vk_ctx.m b/gfx/drivers_context/cocoa_vk_ctx.m index d93fbe214b..597bbefa21 100755 --- a/gfx/drivers_context/cocoa_vk_ctx.m +++ b/gfx/drivers_context/cocoa_vk_ctx.m @@ -58,13 +58,11 @@ CocoaView *cocoaview_get(void); static uint32_t cocoa_vk_gfx_ctx_get_flags(void *data) { -#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) uint32_t flags = 0; +#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS) BIT32_SET(flags, GFX_CTX_FLAGS_SHADERS_SLANG); - return flags; -#else - return 0; #endif + return flags; } static void cocoa_vk_gfx_ctx_set_flags(void *data, uint32_t flags) { } @@ -364,7 +362,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoavk = { cocoa_get_metrics, NULL, /* translate_aspect */ #ifdef OSX - cocoa_update_title, + video_driver_update_title, #else NULL, /* update_title */ #endif diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index dfe710d413..b5dc48ebb2 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -113,7 +113,7 @@ typedef struct hdmi_timings static enum gfx_ctx_api drm_api = GFX_CTX_NONE; static drmModeModeInfo gfx_ctx_crt_switch_mode; -static bool switch_mode = false; +static bool switch_mode = false; static float mode_vrefresh(drmModeModeInfo *mode) { @@ -385,7 +385,7 @@ static bool gfx_ctx_drm_load_mode(drmModeModeInfoPtr modeInfo) settings_t *settings = config_get_ptr(); char *crt_switch_timings = settings->arrays.crt_switch_timings; - if(modeInfo && !string_is_empty(crt_switch_timings)) + if (modeInfo && !string_is_empty(crt_switch_timings)) { hdmi_timings_t timings; int ret = sscanf(crt_switch_timings, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", @@ -570,8 +570,7 @@ static void gfx_ctx_drm_swap_buffers(void *data) unsigned max_swapchain_images = settings->uints.video_max_swapchain_images; /* Recreate the surface */ - //* - if(switch_mode) + if (switch_mode) { RARCH_DBG("[KMS]: modeswitch detected, doing GBM and EGL stuff\n"); if (drm->gbm_surface) @@ -593,9 +592,7 @@ static void gfx_ctx_drm_swap_buffers(void *data) GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); if (!drm->gbm_surface) - { RARCH_ERR("[KMS/EGL]: Couldn't create GBM surface.\n"); - } /* Creates an EGL surface and make it current */ egl_create_surface(&drm->egl, (EGLNativeWindowType)drm->gbm_surface); @@ -617,8 +614,8 @@ static void gfx_ctx_drm_swap_buffers(void *data) drm->waiting_for_flip = gfx_ctx_drm_queue_flip(drm); /* Triple-buffered page flips */ - if (max_swapchain_images >= 3 && - gbm_surface_has_free_buffers(drm->gbm_surface)) + if ( max_swapchain_images >= 3 + && gbm_surface_has_free_buffers(drm->gbm_surface)) return; gfx_ctx_drm_wait_flip(drm, true); @@ -837,28 +834,28 @@ static bool gfx_ctx_drm_set_video_mode(void *data, /* Find desired video mode, and use that. * If not fullscreen, we get desired windowed size, * which is not appropriate. */ - if(gfx_ctx_drm_get_mode_from_video_state(&gfx_ctx_crt_switch_mode)) + if (gfx_ctx_drm_get_mode_from_video_state(&gfx_ctx_crt_switch_mode)) { RARCH_DBG("[KMS]: New mode detected: %dx%d\n", gfx_ctx_crt_switch_mode.hdisplay, gfx_ctx_crt_switch_mode.vdisplay); - g_drm_mode = &gfx_ctx_crt_switch_mode; + g_drm_mode = &gfx_ctx_crt_switch_mode; drm->fb_width = gfx_ctx_crt_switch_mode.hdisplay; drm->fb_height = gfx_ctx_crt_switch_mode.vdisplay; - switch_mode = true; + switch_mode = true; /* Let's exit, since modeswitching will happen while swapping buffers */ return true; } if ((width == 0 && height == 0) || !fullscreen) { - g_drm_mode = &g_drm_connector->modes[0]; RARCH_WARN("[KMS]: Falling back to mode 0 (default)\n"); + g_drm_mode = &g_drm_connector->modes[0]; } else { /* check if custom HDMI timings were asked */ if (gfx_ctx_crt_switch_mode.vdisplay > 0) { - g_drm_mode = &gfx_ctx_crt_switch_mode; RARCH_LOG("[DRM]: custom mode requested: %s\n", gfx_ctx_crt_switch_mode.name); + g_drm_mode = &gfx_ctx_crt_switch_mode; } else { diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 9c11c3be00..2ea166017b 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -59,13 +59,11 @@ static void gfx_ctx_khr_display_get_video_size(void *data, static float gfx_ctx_khr_display_get_refresh_rate(void *data) { - float refresh_rate = 0.0f; + float refresh_rate = 0.0f; khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; if (khr) - { refresh_rate = khr->refresh_rate_x1000 / 1000.0f; - } return refresh_rate; } diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 679bf2af9a..c030ef970b 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -75,7 +75,6 @@ static int gfx_ctx_mali_fbdev_get_vinfo(void *data) { struct fb_var_screeninfo vinfo; int fd = open("/dev/fb0", O_RDWR); - mali_ctx_data_t *mali = (mali_ctx_data_t*)data; if (!mali || ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) @@ -106,25 +105,25 @@ static int gfx_ctx_mali_fbdev_get_vinfo(void *data) } else { + char tmp[32]; /* Workaround to retrieve current refresh rate if no info is available from IOCTL. If this fails as well, 60Hz is assumed... */ - int j=0; - float k=60.0; - char temp[32]; + int j = 0; + float k = 60.0f; RFILE *fr = filestream_open("/sys/class/display/mode", RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (fr) { - if (filestream_gets(fr, temp, sizeof(temp))) + if (filestream_gets(fr, tmp, sizeof(tmp))) { int i; - for (i=0;ifb_width / (float)vc->fb_height; + float src_aspect = (float)fullscreen_x / (float)fullscreen_y; + float dst_aspect = (float)vc->fb_width / (float)vc->fb_height; /* If source and destination aspect ratios are not equal correct source width. */ - if (srcAspect != dstAspect) - vc->native_window.width = (unsigned)(fullscreen_y * dstAspect); + if (src_aspect != dst_aspect) + vc->native_window.width = (unsigned)(fullscreen_y * dst_aspect); else vc->native_window.width = fullscreen_x; vc->native_window.height = fullscreen_y; diff --git a/gfx/drivers_context/w_vk_ctx.c b/gfx/drivers_context/w_vk_ctx.c index 0bda03cde3..8f2d40bf06 100644 --- a/gfx/drivers_context/w_vk_ctx.c +++ b/gfx/drivers_context/w_vk_ctx.c @@ -136,22 +136,6 @@ static bool gfx_ctx_w_vk_set_resize(void *data, return false; } -static void gfx_ctx_w_vk_update_title(void *data) -{ - char title[128]; - title[0] = '\0'; - - video_driver_get_window_title(title, sizeof(title)); - - if (title[0]) - { - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - if (window) - window->set_title(&main_window, title); - } -} - static void gfx_ctx_w_vk_destroy(void *data) { HWND window = win32_get_window(); @@ -312,7 +296,7 @@ const gfx_ctx_driver_t gfx_ctx_w_vk = { gfx_ctx_w_vk_get_video_output_next, win32_get_metrics, NULL, - gfx_ctx_w_vk_update_title, + video_driver_update_title, gfx_ctx_w_vk_check_window, gfx_ctx_w_vk_set_resize, win32_has_focus, diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 288ef51ab6..5856c5851f 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -473,23 +473,6 @@ static void gfx_ctx_wgl_swap_buffers(void *data) static bool gfx_ctx_wgl_set_resize(void *data, unsigned width, unsigned height) { return false; } -static void gfx_ctx_wgl_update_title(void *data) -{ - char title[128]; - - title[0] = '\0'; - - video_driver_get_window_title(title, sizeof(title)); - - if (title[0]) - { - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - if (window) - window->set_title(&main_window, title); - } -} - static void gfx_ctx_wgl_destroy(void *data) { HWND window = win32_get_window(); @@ -794,7 +777,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_wgl_get_video_output_next, win32_get_metrics, NULL, - gfx_ctx_wgl_update_title, + video_driver_update_title, win32_check_window, gfx_ctx_wgl_set_resize, win32_has_focus, diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 422d223c79..c97c6e315c 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -554,7 +554,6 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) break; #endif case GFX_CTX_OPENGL_API: - break; case GFX_CTX_NONE: default: break; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4e19a83f61..9185671ad3 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -4063,3 +4063,22 @@ void video_frame_delay_auto(video_driver_state_t *video_st, video_frame_delay_au ); #endif } + +void video_driver_update_title(void *data) +{ +#ifndef _XBOX + const ui_window_t *window = ui_companion_driver_get_window_ptr(); + if (window) + { + static char prev_title[128]; + char title[128]; + title[0] = '\0'; + video_driver_get_window_title(title, sizeof(title)); + if (title[0] && !string_is_equal(title, prev_title)) + { + window->set_title(&main_window, title); + strlcpy(prev_title, title, sizeof(prev_title)); + } + } +#endif +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index ae10273f23..45937c3e69 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -1271,6 +1271,8 @@ bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled) void video_driver_frame(const void *data, unsigned width, unsigned height, size_t pitch); +void video_driver_update_title(void *data); + extern const video_driver_t *video_drivers[]; extern video_driver_t video_gl3; diff --git a/ui/drivers/cocoa/cocoa_common.h b/ui/drivers/cocoa/cocoa_common.h index 9794f90f11..db99657fbd 100644 --- a/ui/drivers/cocoa/cocoa_common.h +++ b/ui/drivers/cocoa/cocoa_common.h @@ -133,7 +133,6 @@ void *cocoa_screen_get_chosen(void); float cocoa_screen_get_native_scale(void); #else float cocoa_screen_get_backing_scale_factor(void); -void cocoa_update_title(void *data); #endif bool cocoa_get_metrics( diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index fe7c6675f7..b699331790 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -741,23 +741,6 @@ CocoaView *cocoaview_get(void) } #ifdef OSX -void cocoa_update_title(void *data) -{ - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - if (window) - { - char title[128]; - - title[0] = '\0'; - - video_driver_get_window_title(title, sizeof(title)); - - if (title[0]) - window->set_title((void*)video_driver_display_userdata_get(), title); - } -} - bool cocoa_get_metrics( void *data, enum display_metric_types type, float *value)