mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Cut down on update_title code duplication
This commit is contained in:
parent
d53b397b48
commit
be65a13102
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;i<sizeof(temp);i++)
|
||||
for (i = 0; i < sizeof(tmp); i++)
|
||||
{
|
||||
if (*(temp+i)=='p' || *(temp+i)=='i')
|
||||
j=i;
|
||||
else if (*(temp+i)=='h')
|
||||
*(temp+i)='\0';
|
||||
if (*(tmp + i) == 'p' || *(tmp + i) == 'i')
|
||||
j = i;
|
||||
else if (*(tmp + i) == 'h')
|
||||
*(tmp + i) = '\0';
|
||||
}
|
||||
k = j ? atof(temp + j + 1) : k;
|
||||
k = j ? atof(tmp + j + 1) : k;
|
||||
}
|
||||
filestream_close(fr);
|
||||
}
|
||||
@ -205,7 +204,9 @@ static void gfx_ctx_mali_fbdev_destroy(void *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((mali_flags & GFX_CTX_MALI_FBDEV_FLAG_HW_CTX_TRIGGER) || (bool)(mali_flags & GFX_CTX_MALI_FBDEV_FLAG_WAS_THREADED)!=*video_driver_get_threaded())
|
||||
if ( (mali_flags & GFX_CTX_MALI_FBDEV_FLAG_HW_CTX_TRIGGER)
|
||||
|| (bool)(mali_flags & GFX_CTX_MALI_FBDEV_FLAG_WAS_THREADED)
|
||||
!= *video_driver_get_threaded())
|
||||
{
|
||||
gfx_ctx_mali_fbdev_destroy_really();
|
||||
mali_flags |= GFX_CTX_MALI_FBDEV_FLAG_RESTART_PENDING;
|
||||
|
@ -394,12 +394,12 @@ static void *gfx_ctx_vc_init(void *video_driver)
|
||||
* can be used to stretch video output. */
|
||||
|
||||
/* Calculate source and destination aspect ratios. */
|
||||
float srcAspect = (float)fullscreen_x / (float)fullscreen_y;
|
||||
float dstAspect = (float)vc->fb_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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user