diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 9cf41c3cdc..f52b8bf3a7 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -1461,11 +1461,11 @@ static bool d3d_frame(void *data, const void *frame, } #endif - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); - video_context_driver_swap_buffers(video_info); + video_info_>cb_swap_buffers( + video_info->context_data, video_info); return true; } diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 2fbd97ec19..c65b9f752c 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -272,9 +272,8 @@ static bool gdi_gfx_frame(void *data, const void *frame, InvalidateRect(hwnd, NULL, false); - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); return true; } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9a9c3b3361..651dfe74e3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1272,9 +1272,8 @@ static bool gl_frame(void *data, const void *frame, gl_render_overlay(gl, video_info); #endif - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); #ifdef HAVE_FBO /* Reset state which could easily mess up libretro core. */ @@ -1323,11 +1322,11 @@ static bool gl_frame(void *data, const void *frame, && !video_info->runloop_is_slowmotion && !video_info->runloop_is_paused) { - video_context_driver_swap_buffers(video_info); + video_info->cb_swap_buffers(video_info->context_data, video_info); glClear(GL_COLOR_BUFFER_BIT); } - video_context_driver_swap_buffers(video_info); + video_info->cb_swap_buffers(video_info->context_data, video_info); #ifdef HAVE_GL_SYNC if (video_info->hard_sync && gl->have_sync) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index cecba6ce01..64d2451e48 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -422,11 +422,10 @@ static bool vg_frame(void *data, const void *frame, vg_draw_message(vg, msg); #endif - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); - - video_context_driver_swap_buffers(video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); + video_info->cb_swap_buffers( + video_info->context_data, video_info); return true; } diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 6113dc75d1..1d828e0d9c 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -244,9 +244,8 @@ static bool vga_gfx_frame(void *data, const void *frame, if (msg) font_driver_render_msg(video_info, NULL, msg, NULL); - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); return true; } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index a179ffa997..b56c24d483 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1558,7 +1558,7 @@ static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t *video_info) slock_unlock(vk->context->queue_lock); #endif - video_context_driver_swap_buffers(video_info); + video_info->cb_swap_buffers(video_info->context_data, video_info); } static bool vulkan_frame(void *data, const void *frame, @@ -1924,12 +1924,11 @@ static bool vulkan_frame(void *data, const void *frame, slock_unlock(vk->context->queue_lock); #endif - video_context_driver_swap_buffers(video_info); + video_info->cb_swap_buffers(video_info->context_data, video_info); if (!vk->context->swap_interval_emulation_lock) - if (video_info->cb_update_window_title) - video_info->cb_update_window_title( - video_info->context_data, video_info); + video_info->cb_update_window_title( + video_info->context_data, video_info); /* Handle spurious swapchain invalidations as soon as we can, * i.e. right after swap buffers. */ diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7267d03c7c..9375cc24e1 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2322,6 +2322,14 @@ bool video_driver_texture_unload(uintptr_t *id) return true; } +static void update_window_title_null(void *data, video_frame_info_t *video_info) +{ +} + +static void swap_buffers_null(void *data, video_frame_info_t *video_info) +{ +} + void video_driver_build_info(video_frame_info_t *video_info) { bool is_perfcnt_enable = false; @@ -2412,11 +2420,15 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->context_data = video_context_data; - video_info->cb_update_window_title = NULL; + video_info->cb_update_window_title = update_window_title_null; + video_info->cb_swap_buffers = swap_buffers_null; + if (current_video_context) { if (current_video_context->update_window_title) video_info->cb_update_window_title = current_video_context->update_window_title; + if (current_video_context->swap_buffers) + video_info->cb_swap_buffers = current_video_context->swap_buffers; } #ifdef HAVE_THREADS diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 3d4838481a..eeffbfa2de 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -76,7 +76,8 @@ typedef void (*gfx_ctx_proc_t)(void); typedef struct video_frame_info video_frame_info_t; -typedef void (*update_window_title)(void*, video_frame_info_t *video_info); +typedef void (*update_window_title_cb)(void*, video_frame_info_t *video_info); +typedef void (*swap_buffers_cb)(void*, video_frame_info_t *video_info); typedef struct video_info { @@ -203,7 +204,8 @@ typedef struct video_frame_info float xmb_alpha_factor; char fps_text[128]; - update_window_title cb_update_window_title; + update_window_title_cb cb_update_window_title; + swap_buffers_cb cb_swap_buffers; void *context_data; } video_frame_info_t; @@ -248,7 +250,7 @@ typedef struct gfx_ctx_driver float (*translate_aspect)(void*, unsigned, unsigned); /* Asks driver to update window title (FPS, etc). */ - update_window_title update_window_title; + update_window_title_cb update_window_title; /* Queries for resize and quit events. * Also processes events. */ @@ -270,7 +272,7 @@ typedef struct gfx_ctx_driver /* Swaps buffers. VBlank sync depends on * earlier calls to swap_interval. */ - void (*swap_buffers)(void*, video_frame_info_t *video_info); + swap_buffers_cb swap_buffers; /* Most video backends will want to use a certain input driver. * Checks for it here. */ @@ -906,10 +908,6 @@ bool video_context_driver_set(const gfx_ctx_driver_t *data); void video_context_driver_destroy(void); -#define video_context_driver_swap_buffers(video_info) \ - if (current_video_context && current_video_context->swap_buffers) \ - current_video_context->swap_buffers(video_context_data, video_info) - #define video_context_driver_set_resize(mode_info) \ if (current_video_context && current_video_context->set_resize) \ current_video_context->set_resize(video_context_data, mode_info.width, mode_info.height)