diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index fb5e5d25b1..2ed94fc1d7 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -31,7 +31,6 @@ #include "../../frontend/frontend_driver.h" #include "../../input/common/input_x11_common.h" #include "../../verbosity.h" -#include "../../runloop.h" #ifdef HAVE_DBUS #include @@ -323,7 +322,7 @@ void x11_suspend_screensaver(Window wnd, bool enable) x11_suspend_screensaver_xdg_screensaver(wnd, enable); } -static bool get_video_mode(video_frame_info_t video_info, +static bool get_video_mode(video_frame_info_t *video_info, Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *mode, XF86VidModeModeInfo *desktop_mode) { @@ -345,7 +344,7 @@ static bool get_video_mode(video_frame_info_t video_info, /* If we use black frame insertion, we fake a 60 Hz monitor * for 120 Hz one, etc, so try to match that. */ - refresh_mod = video_info.black_frame_insertion ? 0.5f : 1.0f; + refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; for (i = 0; i < num_modes; i++) { @@ -361,7 +360,7 @@ static bool get_video_mode(video_frame_info_t video_info, continue; refresh = refresh_mod * m->dotclock * 1000.0f / (m->htotal * m->vtotal); - diff = fabsf(refresh - video_info.refresh_rate); + diff = fabsf(refresh - video_info->refresh_rate); if (!ret || diff < minimum_fps_diff) { @@ -375,7 +374,7 @@ static bool get_video_mode(video_frame_info_t video_info, return ret; } -bool x11_enter_fullscreen(video_frame_info_t video_info, +bool x11_enter_fullscreen(video_frame_info_t *video_info, Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode) { @@ -634,7 +633,7 @@ bool x11_alive(void *data) } void x11_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width = *width; unsigned new_height = *height; @@ -715,18 +714,16 @@ bool x11_connect(void) return true; } -void x11_update_window_title(void *data, video_frame_info_t video_info) +void x11_update_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buf_fps[128]; + char title[128]; - buf[0] = buf_fps[0] = '\0'; + title[0] = '\0'; - if (video_monitor_get_fps(video_info, - buf, sizeof(buf), buf_fps, sizeof(buf_fps))) - XStoreName(g_x11_dpy, g_x11_win, buf); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + video_driver_get_window_title(title, sizeof(title)); + + if (title[0] && video_info->monitor_fps_enable) + XStoreName(g_x11_dpy, g_x11_win, title); } bool x11_input_ctx_new(bool true_full) diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index b08db07e0f..78fd28791b 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -45,7 +45,7 @@ void x11_save_last_used_monitor(Window win); void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); void x11_suspend_screensaver(Window win, bool enable); -bool x11_enter_fullscreen(video_frame_info_t video_info, +bool x11_enter_fullscreen(video_frame_info_t *video_info, Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode); @@ -72,7 +72,7 @@ bool x11_get_metrics(void *data, enum display_metric_types type, float *value); void x11_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count); + bool *resize, unsigned *width, unsigned *height); void x11_get_video_size(void *data, unsigned *width, unsigned *height); @@ -84,7 +84,7 @@ bool x11_alive(void *data); bool x11_connect(void); -void x11_update_window_title(void *data, video_frame_info_t video_info); +void x11_update_title(void *data, video_frame_info_t *video_info); bool x11_input_ctx_new(bool true_full); diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index c56ca64b52..815fcb09af 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -15,13 +15,18 @@ * If not, see . */ -#include #include +#include + +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + +#include "../common/caca_common.h" + #include "../../driver.h" #include "../../verbosity.h" -#include "../../menu/menu_driver.h" -#include "../common/caca_common.h" static caca_canvas_t *caca_cv = NULL; static caca_dither_t *caca_dither = NULL; @@ -94,7 +99,7 @@ static void *caca_gfx_init(const video_info_t *video, static bool caca_gfx_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, - unsigned pitch, const char *msg, video_frame_info_t video_info) + unsigned pitch, const char *msg, video_frame_info_t *video_info) { size_t len = 0; void *buffer = NULL; @@ -145,7 +150,7 @@ static bool caca_gfx_frame(void *data, const void *frame, caca_clear_canvas(caca_cv); #ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); #endif if (msg) diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 44f36f98f5..ca90959423 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -26,11 +26,13 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../ctr/gpu_old.h" #include "ctr_gu.h" -#include "../../menu/menu_driver.h" - #include "../../configuration.h" #include "../../command.h" #include "../../driver.h" @@ -446,7 +448,7 @@ static void* ctr_init(const video_info_t* video, static bool ctr_frame(void* data, const void* frame, unsigned width, unsigned height, uint64_t frame_count, - unsigned pitch, const char* msg, video_frame_info_t info) + unsigned pitch, const char* msg, video_frame_info_t *video_info) { uint32_t diff; static uint64_t currentTick,lastTick; @@ -750,7 +752,7 @@ static bool ctr_frame(void* data, const void* frame, } ctr->msg_rendering_enabled = true; - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); ctr->msg_rendering_enabled = false; } diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 46e706e675..1ada4f5dd4 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -332,14 +332,16 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) d3d->renderchain_driver->viewport_info(d3d, vp); } -static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) +static void d3d_overlay_render(d3d_video_t *d3d, video_frame_info_t *video_info, + overlay_t *overlay) { struct video_viewport vp; - unsigned width, height; void *verts; unsigned i; float vert[4][9]; float overlay_width, overlay_height; + unsigned width = video_info->width; + unsigned height = video_info->height; if (!d3d || !overlay || !overlay->tex) return; @@ -429,8 +431,6 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) { D3DVIEWPORT vp_full; - video_driver_get_size(&width, &height); - vp_full.X = 0; vp_full.Y = 0; vp_full.Width = width; @@ -881,7 +881,7 @@ static bool d3d_alive(void *data) mode.width = temp_width; mode.height = temp_height; - video_context_driver_set_resize(&mode); + video_context_driver_set_resize(mode); d3d_restore(d3d); } @@ -1368,21 +1368,21 @@ static void d3d_get_overlay_interface(void *data, static bool d3d_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, - const char *msg, video_frame_info_t video_info) + const char *msg, video_frame_info_t *video_info) { - unsigned width, height; - static struct retro_perf_counter d3d_frame = {0}; + static struct + retro_perf_counter d3d_frame = {0}; unsigned i = 0; d3d_video_t *d3d = (d3d_video_t*)data; HWND window = win32_get_window(); + unsigned width = video_info->width; + unsigned height = video_info->height; (void)i; if (!frame) return true; - video_driver_get_size(&width, &height); - performance_counter_init(&d3d_frame, "d3d_frame"); performance_counter_start(&d3d_frame); @@ -1412,18 +1412,18 @@ static bool d3d_frame(void *data, const void *frame, /* render_chain() only clears out viewport, * clear out everything. */ D3DVIEWPORT screen_vp; - screen_vp.X = 0; - screen_vp.Y = 0; - screen_vp.MinZ = 0; - screen_vp.MaxZ = 1; - screen_vp.Width = width; + screen_vp.X = 0; + screen_vp.Y = 0; + screen_vp.MinZ = 0; + screen_vp.MaxZ = 1; + screen_vp.Width = width; screen_vp.Height = height; d3d_set_viewports(d3d->dev, &screen_vp); d3d_clear(d3d->dev, 0, 0, D3DCLEAR_TARGET, 0, 1, 0); /* Insert black frame first, so we * can screenshot, etc. */ - if (video_info.black_frame_insertion) + if (video_info->black_frame_insertion) { if (!d3d_swap(d3d, d3d->dev) || d3d->needs_restore) return true; @@ -1448,8 +1448,8 @@ static bool d3d_frame(void *data, const void *frame, #ifdef HAVE_MENU if (d3d->menu && d3d->menu->enabled) { - d3d_overlay_render(d3d, d3d->menu); - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + d3d_overlay_render(d3d, video_info, d3d->menu); + menu_driver_frame(video_info); } #endif @@ -1457,7 +1457,7 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->overlays_enabled) { for (i = 0; i < d3d->overlays.size(); i++) - d3d_overlay_render(d3d, &d3d->overlays[i]); + d3d_overlay_render(d3d, video_info, &d3d->overlays[i]); } #endif diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 873eced47c..fe3698a47a 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -21,6 +21,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../configuration.h" #include "../../driver.h" #include "../../retroarch.h" @@ -430,7 +434,7 @@ static void *dispmanx_gfx_init(const video_info_t *video, static bool dispmanx_gfx_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) + video_frame_info_t *video_info) { struct dispmanx_video *_dispvars = data; float aspect = video_driver_get_aspect_ratio(); @@ -438,7 +442,9 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, if (!frame) return true; - if (width != _dispvars->core_width || height != _dispvars->core_height || _dispvars->aspect_ratio != aspect) + if ( (width != _dispvars->core_width) || + (height != _dispvars->core_height) || + (_dispvars->aspect_ratio != aspect)) { /* Sanity check. */ if (width == 0 || height == 0) @@ -467,19 +473,16 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, settings->video.max_swapchain_images, 0, &_dispvars->main_surface); - + /* We need to recreate the menu surface too, if it exists already, so we * free it and let dispmanx_set_texture_frame() recreate it as it detects it's NULL.*/ - if (_dispvars->menu_active && _dispvars->menu_surface) { + if (_dispvars->menu_active && _dispvars->menu_surface) dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); - } } - if (video_info.fps_show) - { - char buf[128]; - video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0); - } +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif /* Update main surface: locate free page, blit and flip. */ dispmanx_surface_update(_dispvars, frame, _dispvars->main_surface); diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 9e21463134..c3c1e6b021 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -28,6 +28,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../font_driver.h" #include "../video_context_driver.h" #include "../../retroarch.h" @@ -744,11 +748,12 @@ static void *drm_gfx_init(const video_info_t *video, static bool drm_gfx_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) + video_frame_info_t *video_info) { struct drm_video *_drmvars = data; - if (width != _drmvars->core_width || height != _drmvars->core_height) + if ( ( width != _drmvars->core_width) || + (height != _drmvars->core_height)) { /* Sanity check. */ if (width == 0 || height == 0) @@ -778,13 +783,9 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, drm_plane_setup(_drmvars->main_surface); } - if (_drmvars->menu_active) - { - char buf[128]; - buf[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0); - } +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif /* Update main surface: locate free page, blit and flip. */ drm_surface_update(_drmvars, frame, _drmvars->main_surface); diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 68f5132eba..03b38b86d0 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -35,6 +35,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../common/drm_common.h" #include "../font_driver.h" #include "../../configuration.h" @@ -1159,7 +1163,6 @@ static int exynos_render_msg(struct exynos_video *vid, return exynos_blend_font(pdata); } - static void *exynos_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { @@ -1273,7 +1276,7 @@ static void exynos_gfx_free(void *data) static bool exynos_gfx_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) + video_frame_info_t *video_info) { struct exynos_video *vid = data; struct exynos_page *page = NULL; @@ -1304,18 +1307,6 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, goto fail; } - if (video_info.fps_show) - { - char buffer[128]; - char buffer_fps[128]; - - buffer[0] = buffer_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buffer, sizeof(buffer), - video_info.fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); - runloop_msg_queue_push(buffer_fps, 1, 1, false); - } - /* If at this point the dimension parameters are still zero, setup some * * fake blit parameters so that menu and font rendering work properly. */ if (vid->width == 0 || vid->height == 0) @@ -1328,6 +1319,9 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, { if (exynos_blend_menu(vid->data, vid->menu_rotation) != 0) goto fail; +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif } if (msg) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 5f5e419557..7733f05ab6 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -17,10 +17,17 @@ #include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../driver.h" #include "../../configuration.h" #include "../../verbosity.h" -#include "../../menu/menu_driver.h" #include "../common/gdi_common.h" #if defined(_WIN32) && !defined(_XBOX) @@ -146,7 +153,7 @@ error: static bool gdi_gfx_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, - unsigned pitch, const char *msg, video_frame_info_t video_info) + unsigned pitch, const char *msg, video_frame_info_t *video_info) { gfx_ctx_mode_t mode; RECT rect; @@ -162,7 +169,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, return true; #ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); #endif if (gdi_video_width != frame_width || gdi_video_height != frame_height || gdi_video_pitch != pitch) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 5c42dcce36..55a89ff0a8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -212,18 +212,18 @@ static void gl_overlay_tex_geom(void *data, tex[7] = y + h; } -static void gl_render_overlay(gl_t *gl) +static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_info_t shader_info; - unsigned i, width, height; + unsigned i; + unsigned width = video_info->width; + unsigned height = video_info->height; if (!gl || !gl->overlay_enable) return; - video_driver_get_size(&width, &height); - glEnable(GL_BLEND); if (gl->overlay_full_screen) @@ -299,32 +299,30 @@ static void gl_set_viewport_wrapper(void *data, unsigned viewport_width, video_driver_build_info(&video_info); - gl_set_viewport(data, video_info, + gl_set_viewport(data, &video_info, viewport_width, viewport_height, force_full, allow_rotate); } -void gl_set_viewport(void *data, video_frame_info_t video_info, +void gl_set_viewport(void *data, video_frame_info_t *video_info, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate) { gfx_ctx_aspect_t aspect_data; - unsigned width, height; - int x = 0; - int y = 0; - float device_aspect = (float)viewport_width / viewport_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}; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + unsigned height = video_info->height; - video_driver_get_size(&width, &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 (video_info.scale_integer && !force_full) + if (video_info->scale_integer && !force_full) { video_viewport_get_scaled_integer(&gl->vp, viewport_width, viewport_height, @@ -337,7 +335,7 @@ void gl_set_viewport(void *data, video_frame_info_t video_info, float desired_aspect = video_driver_get_aspect_ratio(); #if defined(HAVE_MENU) - if (video_info.aspect_ratio_idx == ASPECT_RATIO_CUSTOM) + if (video_info->aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { const struct video_viewport *custom = video_viewport_get_custom(); @@ -1013,13 +1011,14 @@ static void gl_pbo_async_readback(gl_t *gl) } #endif -static INLINE void gl_draw_texture(gl_t *gl) +static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_info_t shader_info; - unsigned width, height; GLfloat color[16]; + unsigned width = video_info->width; + unsigned height = video_info->height; color[ 0] = 1.0f; color[ 1] = 1.0f; @@ -1041,8 +1040,6 @@ static INLINE void gl_draw_texture(gl_t *gl) if (!gl->menu_texture) return; - video_driver_get_size(&width, &height); - gl->coords.vertex = vertexes_flipped; gl->coords.tex_coord = tex_coords; gl->coords.color = color; @@ -1090,16 +1087,18 @@ static bool gl_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg, - video_frame_info_t video_info) + video_frame_info_t *video_info) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; - unsigned width, height; struct video_tex_info feedback_info; video_shader_ctx_info_t shader_info; - static struct retro_perf_counter frame_run = {0}; + static struct + retro_perf_counter frame_run = {0}; gl_t *gl = (gl_t*)data; + unsigned width = video_info->width; + unsigned height = video_info->height; performance_counter_init(&frame_run, "frame_run"); performance_counter_start(&frame_run); @@ -1107,8 +1106,6 @@ static bool gl_frame(void *data, const void *frame, if (!gl) return false; - video_driver_get_size(&width, &height); - context_bind_hw_render(false); #ifndef HAVE_OPENGLES @@ -1146,7 +1143,7 @@ static bool gl_frame(void *data, const void *frame, mode.width = width; mode.height = height; - video_context_driver_set_resize(&mode); + video_context_driver_set_resize(mode); #ifdef HAVE_FBO if (gl->fbo_inited) @@ -1279,10 +1276,10 @@ static bool gl_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (gl->menu_texture_enable) { - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); if (gl->menu_texture_enable) - gl_draw_texture(gl); + gl_draw_texture(gl, video_info); } #endif @@ -1290,7 +1287,7 @@ static bool gl_frame(void *data, const void *frame, font_driver_render_msg(NULL, msg, NULL); #ifdef HAVE_OVERLAY - gl_render_overlay(gl); + gl_render_overlay(gl, video_info); #endif video_context_driver_update_window_title(video_info); @@ -1339,7 +1336,7 @@ static bool gl_frame(void *data, const void *frame, /* Disable BFI during fast forward, slow-motion, * and pause to prevent flicker. */ if ( - video_info.black_frame_insertion + video_info->black_frame_insertion && !input_driver_is_nonblock_state() && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) @@ -1351,7 +1348,7 @@ static bool gl_frame(void *data, const void *frame, video_context_driver_swap_buffers(video_info); #ifdef HAVE_GL_SYNC - if (video_info.hard_sync && gl->have_sync) + if (video_info->hard_sync && gl->have_sync) { static struct retro_perf_counter gl_fence = {0}; @@ -1361,7 +1358,7 @@ static bool gl_frame(void *data, const void *frame, gl->fences[gl->fence_count++] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - while (gl->fence_count > video_info.hard_sync_frames) + while (gl->fence_count > video_info->hard_sync_frames) { glClientWaitSync(gl->fences[0], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); diff --git a/gfx/drivers/gl_renderchains/render_chain_gl.h b/gfx/drivers/gl_renderchains/render_chain_gl.h index 24886dec0b..c329b83fb5 100644 --- a/gfx/drivers/gl_renderchains/render_chain_gl.h +++ b/gfx/drivers/gl_renderchains/render_chain_gl.h @@ -49,14 +49,14 @@ void gl_load_texture_data( const void *frame, unsigned base_size); void gl_renderchain_render(gl_t *gl, - video_frame_info_t video_info, + video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, const struct video_tex_info *feedback_info); void gl_renderchain_init(gl_t *gl, unsigned fbo_width, unsigned fbo_height); -void gl_set_viewport(void *data, video_frame_info_t video_info, +void gl_set_viewport(void *data, video_frame_info_t *video_info, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate); @@ -70,7 +70,7 @@ void gl_renderchain_recompute_pass_sizes(gl_t *gl, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height); -void gl_renderchain_start_render(gl_t *gl, video_frame_info_t video_info); +void gl_renderchain_start_render(gl_t *gl, video_frame_info_t *video_info); void gl_check_fbo_dimensions(gl_t *gl); diff --git a/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c b/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c index 55d687d812..987654cc07 100644 --- a/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c +++ b/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c @@ -239,7 +239,7 @@ void gl_check_fbo_dimensions(gl_t *gl) } } void gl_renderchain_render(gl_t *gl, - video_frame_info_t video_info, + video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, const struct video_tex_info *feedback_info) @@ -249,7 +249,6 @@ void gl_renderchain_render(gl_t *gl, video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; video_shader_ctx_info_t shader_info; - unsigned width, height; const struct video_fbo_rect *prev_rect; struct video_tex_info *fbo_info; struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS]; @@ -257,8 +256,8 @@ void gl_renderchain_render(gl_t *gl, GLfloat xamt, yamt; unsigned fbo_tex_info_cnt = 0; GLfloat fbo_tex_coords[8] = {0.0f}; - - video_driver_get_size(&width, &height); + unsigned width = video_info->width; + unsigned height = video_info->height; /* Render the rest of our passes. */ gl->coords.tex_coord = fbo_tex_coords; @@ -667,7 +666,7 @@ void gl_renderchain_recompute_pass_sizes(gl_t *gl, } } -void gl_renderchain_start_render(gl_t *gl, video_frame_info_t video_info) +void gl_renderchain_start_render(gl_t *gl, video_frame_info_t *video_info) { glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[0]); diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index d2ed4cb640..b131268973 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -27,6 +27,11 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#include "../../menu/menu_display.h" +#endif + #ifdef HW_RVL #include "../../memory/wii/mem2_manager.h" #endif @@ -36,8 +41,6 @@ #include "../../configuration.h" #include "../../driver.h" #include "../../runloop.h" -#include "../../menu/menu_driver.h" -#include "../../menu/menu_display.h" extern syssram* __SYS_LockSram(void); extern u32 __SYS_UnlockSram(u32 write); @@ -1438,7 +1441,7 @@ static bool gx_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) + video_frame_info_t *video_info) { char fps_txt[128]; char fps_text_buf[128]; @@ -1500,12 +1503,9 @@ static bool gx_frame(void *data, const void *frame, if (gx->menu_texture_enable && gx->menu_data) { - size_t fb_pitch; - unsigned fb_width, fb_height; - - fb_width = menu_display_get_width(); - fb_height = menu_display_get_height(); - fb_pitch = menu_display_get_framebuffer_pitch(); + unsigned fb_width = menu_display_get_width(); + unsigned fb_height = menu_display_get_height(); + size_t fb_pitch = menu_display_get_framebuffer_pitch(); convert_texture16( gx->menu_data, @@ -1518,6 +1518,10 @@ static bool gx_frame(void *data, const void *frame, fb_width * fb_pitch); } +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + GX_InvalidateTexAll(); GX_SetCurrentMtx(GX_PNMTX0); @@ -1538,10 +1542,7 @@ static bool gx_frame(void *data, const void *frame, GX_DrawDone(); - video_monitor_get_fps(video_info, fps_txt, sizeof(fps_txt), - fps_text_buf, sizeof(fps_text_buf)); - - if (video_info.fps_show) + if (video_info->fps_show) { char mem1_txt[128]; char mem2_txt[128]; diff --git a/gfx/drivers/nullgfx.c b/gfx/drivers/nullgfx.c index 2a9adebf50..30708f4dfd 100644 --- a/gfx/drivers/nullgfx.c +++ b/gfx/drivers/nullgfx.c @@ -32,7 +32,7 @@ static void *null_gfx_init(const video_info_t *video, static bool null_gfx_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 pitch, const char *msg, video_frame_info_t *video_info) { (void)data; (void)frame; diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index af46ff7687..fbc25df83b 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -25,12 +25,16 @@ #include #include +#include +#include + #ifdef HAVE_CONFIG_H #include "../../config.h" #endif -#include -#include +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif #include #include @@ -985,7 +989,7 @@ fail: static bool omap_gfx_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) + video_frame_info_t *video_info) { omap_video_t *vid = (omap_video_t*)data; @@ -1008,10 +1012,16 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width, omapfb_prepare(vid->omap); omapfb_blit_frame(vid->omap, frame, vid->height, pitch); + +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if (vid->menu.active) omapfb_blit_frame(vid->omap, vid->menu.frame, vid->menu.scaler.out_height, vid->menu.scaler.out_stride); + if (msg) omap_render_msg(vid, msg); diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 47887c0d05..1185064407 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -28,6 +28,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../defines/psp_defines.h" #include "../../runloop.h" @@ -467,7 +471,7 @@ static void *psp_init(const video_info_t *video, static bool psp_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 pitch, const char *msg, video_frame_info_t *video_info) { #ifdef DISPLAY_FPS uint32_t diff; @@ -476,8 +480,6 @@ static bool psp_frame(void *data, const void *frame, static float fps = 0.0; #endif static struct retro_perf_counter psp_frame_run = {0}; - static char fps_txt[128] = {0}; - static char fps_text_buf[128] = {0}; psp1_video_t *psp = (psp1_video_t*)data; if (!width || !height) @@ -495,14 +497,10 @@ static bool psp_frame(void *data, const void *frame, pspDebugScreenSetXY(0,0); - video_monitor_get_fps(video_info, fps_txt, sizeof(fps_txt), - video_info.fps_show ? fps_text_buf : NULL, - video_info.fps_show ? sizeof(fps_text_buf) : 0); - - if (video_info.fps_show) + if (video_info->fps_show) { - pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0); - pspDebugScreenPuts(fps_text_buf); + pspDebugScreenSetXY(68 - strlen(video_info->fps_text) - 1,0); + pspDebugScreenPuts(video_info->fps_text); pspDebugScreenSetXY(0,1); } @@ -567,6 +565,10 @@ static bool psp_frame(void *data, const void *frame, performance_counter_stop(&psp_frame_run); +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if(psp->menu.active) { sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage)); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 6d216d8986..6cc61b0a8c 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -498,13 +498,10 @@ static void check_window(sdl2_video_t *vid) static bool sdl2_gfx_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 pitch, const char *msg, video_frame_info_t *video_info) { - char buf[128]; sdl2_video_t *vid = (sdl2_video_t*)data; - buf[0] = '\0'; - if (vid->should_resize) sdl_refresh_viewport(vid); @@ -525,7 +522,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, SDL_RenderCopyEx(vid->renderer, vid->frame.tex, NULL, NULL, vid->rotation, NULL, SDL_FLIP_NONE); #ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); #endif if (vid->menu.active) @@ -536,8 +533,17 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, SDL_RenderPresent(vid->renderer); - if (video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0)) - SDL_SetWindowTitle(vid->window, buf); + if (video_info->monitor_fps_enable) + { + char title[128]; + + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + SDL_SetWindowTitle(vid->window, title); + } return true; } diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 45bdf8f1d6..e79fd926a9 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -27,6 +27,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #ifdef HAVE_X11 #include "../common/x11_common.h" #endif @@ -331,17 +335,14 @@ static void sdl_gfx_check_window(sdl_video_t *vid) static bool sdl_gfx_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 pitch, const char *msg, video_frame_info_t *video_info) { - char buf[128]; static struct retro_perf_counter sdl_scale = {0}; sdl_video_t *vid = (sdl_video_t*)data; if (!frame) return true; - buf[0] = '\0'; - if (SDL_MUSTLOCK(vid->screen)) SDL_LockSurface(vid->screen); @@ -361,6 +362,10 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, pitch); performance_counter_stop(&sdl_scale); +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if (vid->menu.active) SDL_BlitSurface(vid->menu.frame, NULL, vid->screen, NULL); @@ -370,8 +375,8 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, if (SDL_MUSTLOCK(vid->screen)) SDL_UnlockSurface(vid->screen); - if (video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0)) - SDL_WM_SetCaption(buf, NULL); + if (video_info->monitor_fps_enable) + SDL_WM_SetCaption(video_info->window_text, NULL); SDL_Flip(vid->screen); diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index da03c23332..3c290fa22c 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -28,6 +28,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../retroarch.h" #include "../../runloop.h" #include "../font_driver.h" @@ -763,7 +767,7 @@ static void sunxi_setup_scale (void *data, static bool sunxi_gfx_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) + video_frame_info_t *video_info) { struct sunxi_video *_dispvars = (struct sunxi_video*)data; @@ -779,13 +783,12 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, sunxi_setup_scale(_dispvars, width, height, pitch); } +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if (_dispvars->menu_active) { - char buf[128]; - - buf[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0); ioctl(_dispvars->sunxi_disp->fd_fb, FBIO_WAITFORVSYNC, 0); return true; } diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 91451518d1..700e1997a2 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -31,6 +31,10 @@ #include "../../config.h" #endif +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../video_context_driver.h" #include "../../retroarch.h" #include "../../runloop.h" @@ -281,10 +285,10 @@ static void vg_free(void *data) free(vg); } -static void vg_calculate_quad(vg_t *vg) +static void vg_calculate_quad(vg_t *vg, video_frame_info_t *video_info) { - unsigned width, height; - video_driver_get_size(&width, &height); + unsigned width = video_info->width; + unsigned heigh = video_info->height; /* set viewport for aspect ratio, taken from the OpenGL driver. */ if (vg->keep_aspect) @@ -378,25 +382,24 @@ static void vg_copy_frame(void *data, const void *frame, static bool vg_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg, - video_frame_info_t video_info) + video_frame_info_t *video_info) { - unsigned width, height; vg_t *vg = (vg_t*)data; static struct retro_perf_counter vg_fr = {0}; static struct retro_perf_counter vg_image = {0}; + unsigned width = video_info->width; + unsigned height = video_info->height; performance_counter_init(&vg_fr, "vg_fr"); performance_counter_start(&vg_fr); - video_driver_get_size(&width, &height); - if ( frame_width != vg->mRenderWidth || frame_height != vg->mRenderHeight || vg->should_resize) { vg->mRenderWidth = frame_width; vg->mRenderHeight = frame_height; - vg_calculate_quad(vg); + vg_calculate_quad(vg, video_info); matrix_3x3_quad_to_quad( vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2, /* needs to be flipped, Khronos loves their bottom-left origin */ @@ -417,6 +420,10 @@ static bool vg_frame(void *data, const void *frame, vg_copy_frame(vg, frame, frame_width, frame_height, pitch); performance_counter_stop(&vg_image); +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + vgDrawImage(vg->mImage); #if 0 diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 6d01afac36..f16d669dcc 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -133,54 +133,55 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita); static bool vita2d_gfx_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 pitch, const char *msg, video_frame_info_t *video_info) { void *tex_p; vita_video_t *vita = (vita_video_t *)data; - + if (frame) { - if(!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame)){ - unsigned i; - unsigned int stride; + if(!(vita->texture&&vita2d_texture_get_datap(vita->texture)==frame)) + { + unsigned i; + unsigned int stride; - if ((width != vita->width || height != vita->height) && vita->texture) - { - vita2d_free_texture(vita->texture); - vita->texture = NULL; - } + if ((width != vita->width || height != vita->height) && vita->texture) + { + vita2d_free_texture(vita->texture); + vita->texture = NULL; + } - if (!vita->texture) - { - RARCH_LOG("Creating texture: %ix%i\n", width, height); - vita->width = width; - vita->height = height; - vita->texture = vita2d_create_empty_texture_format(width, height, vita->format); - vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter); - } - tex_p = vita2d_texture_get_datap(vita->texture); - stride = vita2d_texture_get_stride(vita->texture); + if (!vita->texture) + { + RARCH_LOG("Creating texture: %ix%i\n", width, height); + vita->width = width; + vita->height = height; + vita->texture = vita2d_create_empty_texture_format(width, height, vita->format); + vita2d_texture_set_filters(vita->texture,vita->tex_filter,vita->tex_filter); + } + tex_p = vita2d_texture_get_datap(vita->texture); + stride = vita2d_texture_get_stride(vita->texture); - if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB) - { - stride /= 4; - pitch /= 4; - uint32_t *tex32 = tex_p; - const uint32_t *frame32 = frame; + if (vita->format == SCE_GXM_TEXTURE_FORMAT_X8U8U8U8_1RGB) + { + stride /= 4; + pitch /= 4; + uint32_t *tex32 = tex_p; + const uint32_t *frame32 = frame; - for (i = 0; i < height; i++) - memcpy_neon(&tex32[i*stride],&frame32[i*pitch],pitch*sizeof(uint32_t)); - } - else - { - stride /= 2; - pitch /= 2; - uint16_t *tex16 = tex_p; - const uint16_t *frame16 = frame; + for (i = 0; i < height; i++) + memcpy_neon(&tex32[i*stride],&frame32[i*pitch],pitch*sizeof(uint32_t)); + } + else + { + stride /= 2; + pitch /= 2; + uint16_t *tex16 = tex_p; + const uint16_t *frame16 = frame; - for (i = 0; i < height; i++) - memcpy_neon(&tex16[i*stride],&frame16[i*pitch],width*sizeof(uint16_t)); - } + for (i = 0; i < height; i++) + memcpy_neon(&tex16[i*stride],&frame16[i*pitch],width*sizeof(uint16_t)); + } } } @@ -188,9 +189,9 @@ static bool vita2d_gfx_frame(void *data, const void *frame, vita2d_gfx_update_viewport(vita); vita2d_start_drawing(); - + vita2d_draw_rectangle(0,0,PSP_FB_WIDTH,PSP_FB_HEIGHT,vita2d_get_clear_color()); - + if (vita->texture) { if (vita->fullscreen) @@ -205,21 +206,9 @@ static bool vita2d_gfx_frame(void *data, const void *frame, float scalex = vita->vp.width / (float)vita->width; float scaley = vita->vp.height / (float)vita->height; vita2d_draw_texture_scale_rotate(vita->texture,vita->vp.x, - vita->vp.y, scalex, scaley, rad); + vita->vp.y, scalex, scaley, rad); } } - - if (video_info.fps_show) - { - char buffer[128]; - char buffer_fps[128]; - - buffer[0] = buffer_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buffer, sizeof(buffer), - video_info.fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); - runloop_msg_queue_push(buffer_fps, 1, 1, false); - } #ifdef HAVE_OVERLAY if (vita->overlay_enable) @@ -228,43 +217,41 @@ static bool vita2d_gfx_frame(void *data, const void *frame, if (vita->menu.active) { - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); - - if(vita->menu.texture){ - if (vita->fullscreen) - vita2d_draw_texture_scale(vita->menu.texture, - 0, 0, - PSP_FB_WIDTH / (float)vita->menu.width, - PSP_FB_HEIGHT / (float)vita->menu.height); - else - { - if (vita->menu.width > vita->menu.height) - { - float scale = PSP_FB_HEIGHT / (float)vita->menu.height; - float w = vita->menu.width * scale; - vita2d_draw_texture_scale(vita->menu.texture, - PSP_FB_WIDTH / 2.0f - w/2.0f, 0.0f, - scale, scale); - } - else - { - float scale = PSP_FB_WIDTH / (float)vita->menu.width; - float h = vita->menu.height * scale; - vita2d_draw_texture_scale(vita->menu.texture, - 0.0f, PSP_FB_HEIGHT / 2.0f - h/2.0f, - scale, scale); - } - } - } - +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif - + if(vita->menu.texture){ + if (vita->fullscreen) + vita2d_draw_texture_scale(vita->menu.texture, + 0, 0, + PSP_FB_WIDTH / (float)vita->menu.width, + PSP_FB_HEIGHT / (float)vita->menu.height); + else + { + if (vita->menu.width > vita->menu.height) + { + float scale = PSP_FB_HEIGHT / (float)vita->menu.height; + float w = vita->menu.width * scale; + vita2d_draw_texture_scale(vita->menu.texture, + PSP_FB_WIDTH / 2.0f - w/2.0f, 0.0f, + scale, scale); + } + else + { + float scale = PSP_FB_WIDTH / (float)vita->menu.width; + float h = vita->menu.height * scale; + vita2d_draw_texture_scale(vita->menu.texture, + 0.0f, PSP_FB_HEIGHT / 2.0f - h/2.0f, + scale, scale); + } + } + } } - - + if(!string_is_empty(msg)) - font_driver_render_msg(NULL, msg, NULL); - + font_driver_render_msg(NULL, msg, NULL); + vita2d_end_drawing(); vita2d_swap_buffers(); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 4f5cfd04c4..5be806a7c9 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -54,7 +54,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, #ifdef HAVE_OVERLAY static void vulkan_overlay_free(vk_t *vk); -static void vulkan_render_overlay(vk_t *vk); +static void vulkan_render_overlay(vk_t *vk, video_frame_info_t *video_info); #endif static void vulkan_viewport_info(void *data, struct video_viewport *vp); @@ -1463,7 +1463,7 @@ static void vulkan_readback(vk_t *vk) VK_PIPELINE_STAGE_HOST_BIT); } -static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t video_info) +static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t *video_info) { VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; @@ -1520,10 +1520,10 @@ static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t video_info) static bool vulkan_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, - unsigned pitch, const char *msg, video_frame_info_t video_info) + unsigned pitch, const char *msg, video_frame_info_t *video_info) { struct vk_per_frame *chain; - unsigned width, height; + VkSemaphore signal_semaphores[2]; VkClearValue clear_value; vk_t *vk = (vk_t*)data; static struct retro_perf_counter frame_run = {0}; @@ -1534,7 +1534,8 @@ static bool vulkan_frame(void *data, const void *frame, static struct retro_perf_counter swapbuffers = {0}; static struct retro_perf_counter queue_submit = {0}; bool waits_for_semaphores = false; - VkSemaphore signal_semaphores[2]; + unsigned width = video_info->width; + unsigned height = video_info->height; VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; @@ -1554,8 +1555,6 @@ static bool vulkan_frame(void *data, const void *frame, performance_counter_init(&end_cmd, "end_command"); performance_counter_start(&frame_run); - video_driver_get_size(&width, &height); - /* Bookkeeping on start of frame. */ chain = &vk->swapchain[frame_index]; vk->chain = chain; @@ -1738,7 +1737,7 @@ static bool vulkan_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (vk->menu.enable) { - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE) { @@ -1779,7 +1778,7 @@ static bool vulkan_frame(void *data, const void *frame, #ifdef HAVE_OVERLAY if (vk->overlay.enable) - vulkan_render_overlay(vk); + vulkan_render_overlay(vk, video_info); #endif performance_counter_stop(&build_cmd); @@ -1922,7 +1921,7 @@ static bool vulkan_frame(void *data, const void *frame, gfx_ctx_mode_t mode; mode.width = width; mode.height = height; - video_context_driver_set_resize(&mode); + video_context_driver_set_resize(mode); vk->should_resize = false; } @@ -1931,7 +1930,7 @@ static bool vulkan_frame(void *data, const void *frame, /* Disable BFI during fast forward, slow-motion, * and pause to prevent flicker. */ if ( - video_info.black_frame_insertion + video_info->black_frame_insertion && !input_driver_is_nonblock_state() && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) @@ -2394,17 +2393,17 @@ static void vulkan_overlay_set_alpha(void *data, } } -static void vulkan_render_overlay(vk_t *vk) +static void vulkan_render_overlay(vk_t *vk, video_frame_info_t *video_info) { - unsigned width, height; unsigned i; struct video_viewport vp; + unsigned width = video_info->width; + unsigned height = video_info->height; if (!vk) return; - video_driver_get_size(&width, &height); - vp = vk->vp; + vp = vk->vp; vulkan_set_viewport(vk, width, height, vk->overlay.full_screen, false); for (i = 0; i < vk->overlay.count; i++) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 2055b2d7ff..c1fb356e5f 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -13,14 +13,23 @@ * If not, see . */ +#include +#include +#include + #include "../../driver.h" #include "../../configuration.h" #include "../../verbosity.h" #include "performance_counters.h" -#include -#include -#include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "gx2.h" #include "system/memory.h" #include "system/wiiu.h" @@ -550,7 +559,7 @@ static void wiiu_gfx_free(void* data) static bool wiiu_gfx_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 pitch, const char* msg, video_frame_info_t *video_info) { (void)msg; int i; @@ -668,6 +677,10 @@ static bool wiiu_gfx_frame(void* data, const void* frame, GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1); +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if (wiiu->menu.enable) { GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->menu.position), sizeof(*wiiu->menu.position), wiiu->menu.position); diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index eeb99f5c1b..da74eac58b 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -192,7 +192,7 @@ static void *xenon360_gfx_init(const video_info_t *video, const input_driver_t * } static bool xenon360_gfx_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) + uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { gl_t *vid = data; @@ -230,6 +230,10 @@ static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, un Xe_SetShader(vid->gl_device, SHADER_TYPE_PIXEL, vid->g_pPixelTexturedShader, 0); Xe_SetShader(vid->gl_device, SHADER_TYPE_VERTEX, vid->g_pVertexShader, 0); +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + // Draw Xe_DrawPrimitive(vid->gl_device, XE_PRIMTYPE_TRIANGLELIST, 0, 1); diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 8bb8ec9478..31bf833df0 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -94,7 +94,7 @@ static void *xshm_gfx_init(const video_info_t *video, static bool xshm_gfx_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 pitch, const char *msg, video_frame_info_t *video_info) { xshm_t* xshm = (xshm_t*)data; int y; @@ -104,6 +104,10 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, memcpy((uint8_t*)xshm->shmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y, (uint8_t*)frame + pitch*y, pitch); } + +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image, 0, 0, 0, 0, xshm->width, xshm->height, False); diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index d8fce331ba..463e1f28c2 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -30,6 +30,14 @@ #include +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#ifdef HAVE_MENU +#include "../../menu/menu_driver.h" +#endif + #include "../../configuration.h" #include "../../frontend/frontend_driver.h" #include "../../verbosity.h" @@ -530,8 +538,17 @@ static void *xv_init(const video_info_t *video, video_driver_build_info(&video_info); - if (video_monitor_get_fps(video_info, buf, sizeof(buf), NULL, 0)) - XStoreName(g_x11_dpy, g_x11_win, buf); + if (video_info.monitor_fps_enable) + { + char title[128]; + + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + XStoreName(g_x11_dpy, g_x11_win, title); + } x11_set_window_attr(g_x11_dpy, g_x11_win); @@ -784,7 +801,7 @@ static void xv_render_msg(xv_t *xv, const char *msg, static bool xv_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 pitch, const char *msg, video_frame_info_t *video_info) { XWindowAttributes target; xv_t *xv = (xv_t*)data; @@ -802,6 +819,10 @@ static bool xv_frame(void *data, const void *frame, unsigned width, xv->vp.full_width = target.width; xv->vp.full_height = target.height; +#ifdef HAVE_MENU + menu_driver_frame(video_info); +#endif + if (msg) xv_render_msg(xv, msg, width << 1, height << 1); @@ -811,7 +832,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, true); XSync(g_x11_dpy, False); - x11_update_window_title(NULL, video_info); + x11_update_title(NULL, video_info); return true; } diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index ee672c8b95..9c7a4e7b3c 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -230,14 +230,12 @@ static void android_gfx_ctx_get_video_size(void *data, } static void android_gfx_ctx_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width = 0; unsigned new_height = 0; android_ctx_data_t *and = (android_ctx_data_t*)data; - (void)frame_count; - *quit = false; switch (android_api) @@ -314,21 +312,8 @@ static bool android_gfx_ctx_set_resize(void *data, return false; } -static void android_gfx_ctx_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool android_gfx_ctx_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -436,12 +421,6 @@ static bool android_gfx_ctx_suppress_screensaver(void *data, bool enable) return false; } -static bool android_gfx_ctx_has_windowed(void *data) -{ - (void)data; - return false; -} - static void dpi_get_density(char *s, size_t len) { system_property_get("getprop", "ro.sf.lcd_density", s); @@ -493,7 +472,7 @@ dpi_fallback: return true; } -static void android_gfx_ctx_swap_buffers(void *data, video_frame_info_t video_info) +static void android_gfx_ctx_swap_buffers(void *data, video_frame_info_t *video_info) { android_ctx_data_t *and = (android_ctx_data_t*)data; @@ -618,12 +597,12 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, /* get_video_output_next */ android_gfx_ctx_get_metrics, NULL, - android_gfx_ctx_update_window_title, + NULL, /* update_title */ android_gfx_ctx_check_window, android_gfx_ctx_set_resize, android_gfx_ctx_has_focus, android_gfx_ctx_suppress_screensaver, - android_gfx_ctx_has_windowed, + NULL, /* has_windowed */ android_gfx_ctx_swap_buffers, android_gfx_ctx_input_driver, android_gfx_ctx_get_proc_address, diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index b5412a189f..68229bc89a 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -29,7 +29,6 @@ #include #include -#include "../../runloop.h" #include "../video_context_driver.h" typedef int CGSConnectionID; @@ -78,11 +77,10 @@ static void gfx_ctx_cgl_get_video_size(void *data, unsigned *width, unsigned *he } static void gfx_ctx_cgl_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { - unsigned new_width, new_height; - - (void)frame_count; + unsigned new_width = 0; + unsigned new_height = 0; *quit = false; @@ -95,37 +93,15 @@ static void gfx_ctx_cgl_check_window(void *data, bool *quit, } } -static void gfx_ctx_cgl_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_cgl_swap_buffers(void *data, video_frame_info_t *video_info) { gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)data; CGLFlushDrawable(cgl->glCtx); } -static bool gfx_ctx_cgl_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_cgl_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - - static bool gfx_ctx_cgl_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -195,12 +171,6 @@ static bool gfx_ctx_cgl_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_cgl_has_windowed(void *data) -{ - (void)data; - return false; -} - static bool gfx_ctx_cgl_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { @@ -364,12 +334,12 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_cgl_update_window_title, + NULL, /* update_title */ gfx_ctx_cgl_check_window, - gfx_ctx_cgl_set_resize, + NULL, /* set_resize */ gfx_ctx_cgl_has_focus, gfx_ctx_cgl_suppress_screensaver, - gfx_ctx_cgl_has_windowed, + NULL, /* has_windowed */ gfx_ctx_cgl_swap_buffers, gfx_ctx_cgl_input_driver, gfx_ctx_cgl_get_proc_address, diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 566869809a..e3a49f8ab3 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -330,7 +330,7 @@ static void cocoagl_gfx_ctx_show_mouse(void *data, bool state) } static bool cocoagl_gfx_ctx_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { #if defined(HAVE_COCOA) @@ -416,28 +416,27 @@ static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned *height = CGRectGetHeight(size) * screenscale; } -static void cocoagl_gfx_ctx_update_window_title(void *data, video_frame_info_t video_info) +#if defined(HAVE_COCOA) +static void cocoagl_gfx_ctx_update_title(void *data, video_frame_info_t *video_info) { -#if defined(HAVE_COCOA) ui_window_cocoa_t view; - const ui_window_t *window = NULL; -#endif - static char buf_fps[128] = {0}; - static char buf[128] = {0}; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - -#if defined(HAVE_COCOA) - window = ui_companion_driver_get_window_ptr(); + const ui_window_t *window = ui_companion_driver_get_window_ptr(); + view.data = (CocoaView*)nsview_get_ptr(); - if (window && *buf) - window->set_title(&view, buf); -#endif - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + if (window && video_info->monitor_fps_enable) + { + char title[128]; + + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + window->set_title(&view, title); + } } +#endif static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types type, float *value) @@ -526,18 +525,14 @@ static bool cocoagl_gfx_ctx_suppress_screensaver(void *data, bool enable) return false; } +#if !defined(HAVE_COCOATOUCH) static bool cocoagl_gfx_ctx_has_windowed(void *data) { - (void)data; - -#if defined(HAVE_COCOATOUCH) - return false; -#else return true; -#endif } +#endif -static void cocoagl_gfx_ctx_swap_buffers(void *data, video_frame_info_t video_info) +static void cocoagl_gfx_ctx_swap_buffers(void *data, video_frame_info_t *video_info) { if (!(--g_fast_forward_skips < 0)) return; @@ -564,10 +559,9 @@ CFStringRef)BOXSTRING(symbol_name) } static void cocoagl_gfx_ctx_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; - (void)frame_count; *quit = false; @@ -580,14 +574,6 @@ static void cocoagl_gfx_ctx_check_window(void *data, bool *quit, } } -static bool cocoagl_gfx_ctx_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - static void cocoagl_gfx_ctx_input_driver(void *data, const char *name, const input_driver_t **input, void **input_data) @@ -631,12 +617,20 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { NULL, /* get_video_output_next */ cocoagl_gfx_ctx_get_metrics, NULL, - cocoagl_gfx_ctx_update_window_title, +#if defined(HAVE_COCOA) + cocoagl_gfx_ctx_update_title, +#else + NULL, /* update_title */ +#endif cocoagl_gfx_ctx_check_window, - cocoagl_gfx_ctx_set_resize, + NULL, /* set_resize */ cocoagl_gfx_ctx_has_focus, cocoagl_gfx_ctx_suppress_screensaver, +#if defined(HAVE_COCOATOUCH) + NULL, +#else cocoagl_gfx_ctx_has_windowed, +#endif cocoagl_gfx_ctx_swap_buffers, cocoagl_gfx_ctx_input_driver, cocoagl_gfx_ctx_get_proc_address, diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index f5d4233bb1..98f65be158 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -29,7 +29,6 @@ #include "../drivers/d3d.h" #include "../common/win32_common.h" -#include "../../runloop.h" #include "../../verbosity.h" #include "../../ui/ui_companion_driver.h" @@ -76,7 +75,7 @@ static bool gfx_ctx_d3d_set_resize(void *data, unsigned new_width, unsigned new_ return true; } -static void gfx_ctx_d3d_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_d3d_swap_buffers(void *data, video_frame_info_t *video_info) { d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; @@ -84,25 +83,11 @@ static void gfx_ctx_d3d_swap_buffers(void *data, video_frame_info_t video_info) d3d_swap(d3d, d3dr); } -static void gfx_ctx_d3d_update_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_d3d_update_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buffer_fps[128]; - const ui_window_t *window = ui_companion_driver_get_window_ptr(); - - buf[0] = buffer_fps[0] = '\0'; - - if (window && video_monitor_get_fps(video_info, buf, sizeof(buf), - buffer_fps, sizeof(buffer_fps))) - { -#ifndef _XBOX - window->set_title(&main_window, buf); -#endif - } - - if (video_info.fps_show) - { #ifdef _XBOX + if (video_info->fps_show) + { MEMORYSTATUS stat; char mem[128]; @@ -111,10 +96,24 @@ static void gfx_ctx_d3d_update_title(void *data, video_frame_info_t video_info) GlobalMemoryStatus(&stat); snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); - strlcat(buffer_fps, mem, sizeof(buffer_fps)); -#endif - runloop_msg_queue_push(buffer_fps, 1, 1, false); + strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text)); } +#else + const ui_window_t *window = ui_companion_driver_get_window_ptr(); + + if (window && video_info->monitor_fps_enable) + { + 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 void gfx_ctx_d3d_show_mouse(void *data, bool state) @@ -126,7 +125,7 @@ static void gfx_ctx_d3d_show_mouse(void *data, bool state) static void gfx_ctx_d3d_check_window(void *data, bool *quit, bool *resize, unsigned *width, - unsigned *height, unsigned frame_count) + unsigned *height) { win32_check_window(quit, resize, width, height); } @@ -141,16 +140,14 @@ static bool gfx_ctx_d3d_suppress_screensaver(void *data, bool enable) return win32_suppress_screensaver(data, enable); } +#ifndef _XBOX static bool gfx_ctx_d3d_has_windowed(void *data) { (void)data; -#ifdef _XBOX - return false; -#else return true; -#endif } +#endif static bool gfx_ctx_d3d_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) @@ -197,7 +194,7 @@ static void gfx_ctx_d3d_input_driver(void *data, } static bool gfx_ctx_d3d_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -347,7 +344,11 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_set_resize, gfx_ctx_d3d_has_focus, gfx_ctx_d3d_suppress_screensaver, +#ifdef _XBOX + NULL, +#else gfx_ctx_d3d_has_windowed, +#endif gfx_ctx_d3d_swap_buffers, gfx_ctx_d3d_input_driver, NULL, diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 9452198716..4c68edc575 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -36,7 +36,6 @@ #include #include "../../verbosity.h" -#include "../../runloop.h" #include "../../frontend/frontend_driver.h" #include "../common/drm_common.h" @@ -138,10 +137,9 @@ static void gfx_ctx_drm_swap_interval(void *data, unsigned interval) } static void gfx_ctx_drm_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { (void)data; - (void)frame_count; (void)width; (void)height; @@ -225,7 +223,7 @@ static bool gfx_ctx_drm_queue_flip(void) return false; } -static void gfx_ctx_drm_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_drm_swap_buffers(void *data, video_frame_info_t *video_info) { gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; @@ -253,37 +251,13 @@ static void gfx_ctx_drm_swap_buffers(void *data, video_frame_info_t video_info) waiting_for_flip = gfx_ctx_drm_queue_flip(); /* Triple-buffered page flips */ - if (video_info.max_swapchain_images >= 3 && + if (video_info->max_swapchain_images >= 3 && gbm_surface_has_free_buffers(g_gbm_surface)) return; gfx_ctx_drm_wait_flip(true); } -static bool gfx_ctx_drm_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - - return false; -} - -static void gfx_ctx_drm_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - - if (video_info.fps_show) - runloop_msg_queue_push( buf_fps, 1, 1, false); -} - static void gfx_ctx_drm_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -617,7 +591,7 @@ error: #endif static bool gfx_ctx_drm_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -634,7 +608,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, /* If we use black frame insertion, * we fake a 60 Hz monitor for 120 Hz one, * etc, so try to match that. */ - refresh_mod = video_info.black_frame_insertion + refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; /* Find desired video mode, and use that. @@ -660,7 +634,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, continue; diff = fabsf(refresh_mod * g_drm_connector->modes[i].vrefresh - - video_info.refresh_rate); + - video_info->refresh_rate); if (!g_drm_mode || diff < minimum_fps_diff) { @@ -765,12 +739,6 @@ static bool gfx_ctx_drm_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_drm_has_windowed(void *data) -{ - (void)data; - return false; -} - static bool gfx_ctx_drm_bind_api(void *video_driver, enum gfx_ctx_api api, unsigned major, unsigned minor) { @@ -889,12 +857,12 @@ const gfx_ctx_driver_t gfx_ctx_drm = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_drm_update_window_title, + NULL, /* update_window_title */ gfx_ctx_drm_check_window, - gfx_ctx_drm_set_resize, + NULL, /* set_resize */ gfx_ctx_drm_has_focus, gfx_ctx_drm_suppress_screensaver, - gfx_ctx_drm_has_windowed, + NULL, /* has_windowed */ gfx_ctx_drm_swap_buffers, gfx_ctx_drm_input_driver, gfx_ctx_drm_get_proc_address, diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 1b750a3689..cb8e45e93d 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -52,7 +52,7 @@ static void gfx_ctx_emscripten_swap_interval(void *data, unsigned interval) } static void gfx_ctx_emscripten_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { int input_width; int input_height; @@ -60,7 +60,6 @@ static void gfx_ctx_emscripten_check_window(void *data, bool *quit, emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data; (void)data; - (void)frame_count; emscripten_get_canvas_size(&input_width, &input_height, &is_fullscreen); *width = (unsigned)input_width; @@ -75,34 +74,12 @@ static void gfx_ctx_emscripten_check_window(void *data, bool *quit, *quit = false; } -static void gfx_ctx_emscripten_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_emscripten_swap_buffers(void *data, video_frame_info_t *video_info) { (void)data; /* no-op in emscripten, no way to force swap/wait for VSync in browsers */ } -static bool gfx_ctx_emscripten_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_emscripten_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static void gfx_ctx_emscripten_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -189,7 +166,7 @@ error: } static bool gfx_ctx_emscripten_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -330,9 +307,9 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ gfx_ctx_emscripten_translate_aspect, - gfx_ctx_emscripten_update_window_title, + NULL, /* update_title */ gfx_ctx_emscripten_check_window, - gfx_ctx_emscripten_set_resize, + NULL, /* set_resize */ gfx_ctx_emscripten_has_focus, gfx_ctx_emscripten_suppress_screensaver, gfx_ctx_emscripten_has_windowed, diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index 7f35a5a993..dea9050840 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -34,7 +34,6 @@ #include "../../configuration.h" #include "../../dynamic.h" -#include "../../runloop.h" #include "../../verbosity.h" #include "../video_context_driver.h" @@ -65,7 +64,7 @@ static void setup_gdi_pixel_format(HDC hdc) } static void gfx_ctx_gdi_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { win32_check_window(quit, resize, width, height); } @@ -87,19 +86,21 @@ static bool gfx_ctx_gdi_set_resize(void *data, return false; } -static void gfx_ctx_gdi_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_gdi_update_window_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buf_fps[128]; const ui_window_t *window = ui_companion_driver_get_window_ptr(); - buf[0] = buf_fps[0] = '\0'; + if (window && video_info->monitor_fps_enable) + { + char title[128]; - if (window && video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) - window->set_title(&main_window, buf); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + window->set_title(&main_window, title); + } } static void gfx_ctx_gdi_get_video_size(void *data, @@ -190,7 +191,7 @@ static void gfx_ctx_gdi_destroy(void *data) } static bool gfx_ctx_gdi_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -287,7 +288,7 @@ static uint32_t gfx_ctx_gdi_get_flags(void *data) return flags; } -static void gfx_ctx_gdi_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_gdi_swap_buffers(void *data, video_frame_info_t *video_info) { (void)data; diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index f4cf4f63d5..18c81a60df 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -25,9 +25,8 @@ static void gfx_ctx_null_swap_interval(void *data, unsigned interval) } static void gfx_ctx_null_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { - (void)frame_count; (void)data; (void)quit; (void)width; @@ -35,25 +34,11 @@ static void gfx_ctx_null_check_window(void *data, bool *quit, (void)resize; } -static void gfx_ctx_null_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_null_swap_buffers(void *data, video_frame_info_t *video_info) { (void)data; } -static bool gfx_ctx_null_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_null_update_window_title(void *data, video_frame_info_t video_info) -{ - (void)data; - (void)video_info; -} - static void gfx_ctx_null_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; @@ -62,7 +47,7 @@ static void gfx_ctx_null_get_video_size(void *data, unsigned *width, unsigned *h } static bool gfx_ctx_null_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -101,12 +86,6 @@ static bool gfx_ctx_null_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_null_has_windowed(void *data) -{ - (void)data; - return true; -} - static bool gfx_ctx_null_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { (void)data; @@ -161,12 +140,12 @@ const gfx_ctx_driver_t gfx_ctx_null = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_null_update_window_title, + NULL, /* update_title */ gfx_ctx_null_check_window, - gfx_ctx_null_set_resize, + NULL, /* set_resize */ gfx_ctx_null_has_focus, gfx_ctx_null_suppress_screensaver, - gfx_ctx_null_has_windowed, + NULL, /* has_windowed */ gfx_ctx_null_swap_buffers, gfx_ctx_null_input_driver, NULL, diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 80276bae10..a8cdc5ae1b 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -74,10 +74,9 @@ error: } static void gfx_ctx_khr_display_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; - (void)frame_count; *resize = khr->vk.need_new_swapchain; @@ -110,21 +109,8 @@ static bool gfx_ctx_khr_display_set_resize(void *data, return false; } -static void gfx_ctx_khr_display_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_khr_display_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -184,12 +170,6 @@ static bool gfx_ctx_khr_display_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_khr_display_has_windowed(void *data) -{ - (void)data; - return false; -} - static void gfx_ctx_khr_display_set_swap_interval(void *data, unsigned swap_interval) { khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; @@ -201,7 +181,7 @@ static void gfx_ctx_khr_display_set_swap_interval(void *data, unsigned swap_inte } } -static void gfx_ctx_khr_display_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_khr_display_swap_buffers(void *data, video_frame_info_t *video_info) { khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; vulkan_present(&khr->vk, khr->vk.context.current_swapchain_index); @@ -243,12 +223,12 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_khr_display_update_window_title, + NULL, /* update_title */ gfx_ctx_khr_display_check_window, gfx_ctx_khr_display_set_resize, gfx_ctx_khr_display_has_focus, gfx_ctx_khr_display_suppress_screensaver, - gfx_ctx_khr_display_has_windowed, + NULL, /* has_windowed */ gfx_ctx_khr_display_swap_buffers, gfx_ctx_khr_display_input_driver, gfx_ctx_khr_display_get_proc_address, diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index de76f06aea..cb1561ee9d 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -131,12 +131,10 @@ error: } static void gfx_ctx_mali_fbdev_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; - (void)frame_count; - gfx_ctx_mali_fbdev_get_video_size(data, &new_width, &new_height); if (new_width != *width || new_height != *height) @@ -149,30 +147,8 @@ static void gfx_ctx_mali_fbdev_check_window(void *data, bool *quit, *quit = (bool)frontend_driver_get_signal_handler_state(); } -static bool gfx_ctx_mali_fbdev_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_mali_fbdev_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -254,12 +230,6 @@ static bool gfx_ctx_mali_fbdev_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_mali_fbdev_has_windowed(void *data) -{ - (void)data; - return false; -} - static void gfx_ctx_mali_fbdev_set_swap_interval(void *data, unsigned swap_interval) { mali_ctx_data_t *mali = (mali_ctx_data_t*)data; @@ -269,7 +239,7 @@ static void gfx_ctx_mali_fbdev_set_swap_interval(void *data, unsigned swap_inter #endif } -static void gfx_ctx_mali_fbdev_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_mali_fbdev_swap_buffers(void *data, video_frame_info_t *video_info) { mali_ctx_data_t *mali = (mali_ctx_data_t*)data; @@ -319,12 +289,12 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_mali_fbdev_update_window_title, + NULL, /* update_title */ gfx_ctx_mali_fbdev_check_window, - gfx_ctx_mali_fbdev_set_resize, + NULL, /* set_resize */ gfx_ctx_mali_fbdev_has_focus, gfx_ctx_mali_fbdev_suppress_screensaver, - gfx_ctx_mali_fbdev_has_windowed, + NULL, /* has_windowed */ gfx_ctx_mali_fbdev_swap_buffers, gfx_ctx_mali_fbdev_input_driver, gfx_ctx_mali_fbdev_get_proc_address, diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index bab164cadc..411221e5b4 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -29,7 +29,6 @@ #endif #include "../../frontend/frontend_driver.h" -#include "../../runloop.h" typedef struct { @@ -113,7 +112,7 @@ static void gfx_ctx_opendingux_get_video_size(void *data, } static void gfx_ctx_opendingux_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; opendingux_ctx_data_t *viv = (opendingux_ctx_data_t*)data; @@ -132,30 +131,8 @@ static void gfx_ctx_opendingux_check_window(void *data, bool *quit, *quit = (bool)frontend_driver_get_signal_handler_state(); } -static bool gfx_ctx_opendingux_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_opendingux_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_opendingux_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -226,13 +203,7 @@ static bool gfx_ctx_opendingux_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_opendingux_has_windowed(void *data) -{ - (void)data; - return false; -} - -static void gfx_ctx_opendingux_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_opendingux_swap_buffers(void *data, video_frame_info_t *video_info) { opendingux_ctx_data_t *viv = (opendingux_ctx_data_t*)data; @@ -292,12 +263,12 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_opendingux_update_window_title, + NULL, /* update_title */ gfx_ctx_opendingux_check_window, - gfx_ctx_opendingux_set_resize, + NULL, /* set_resize */ gfx_ctx_opendingux_has_focus, gfx_ctx_opendingux_suppress_screensaver, - gfx_ctx_opendingux_has_windowed, + NULL, /* has_windowed */ gfx_ctx_opendingux_swap_buffers, gfx_ctx_opendingux_input_driver, gfx_ctx_opendingux_get_proc_address, diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 9ae80c151b..c80457da93 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -56,7 +56,6 @@ typedef struct gfx_osmesa_ctx_data int height; int pixsize; - int frame_count; OSMesaContext ctx; int socket; int client; @@ -240,7 +239,7 @@ static void osmesa_ctx_swap_interval(void *data, unsigned interval) } static bool osmesa_ctx_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -308,24 +307,9 @@ static void osmesa_ctx_get_video_size(void *data, *height = osmesa->height; } -static void osmesa_ctx_update_window_title(void *data, video_frame_info_t video_info) -{ - static char buf[128] = {0}; - static char buf_fps[128] = {0}; - gfx_ctx_osmesa_data_t *osmesa = (gfx_ctx_osmesa_data_t*)data; - - if (!osmesa) - return; - - video_monitor_get_fps(video_info, buf, - sizeof(buf), buf_fps, sizeof(buf_fps)); - - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - -static void osmesa_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *width, - unsigned *height, unsigned frame_count) +static void osmesa_ctx_check_window(void *data, bool *quit, + bool *resize,unsigned *width, + unsigned *height) { gfx_ctx_osmesa_data_t *osmesa = (gfx_ctx_osmesa_data_t*)data; @@ -333,15 +317,6 @@ static void osmesa_ctx_check_window(void *data, bool *quit, bool *resize,unsigne *height = osmesa->height; *resize = false; *quit = false; - osmesa->frame_count = frame_count; -} - -static bool osmesa_ctx_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; } static bool osmesa_ctx_has_focus(void *data) @@ -363,7 +338,7 @@ static bool osmesa_ctx_has_windowed(void *data) return true; } -static void osmesa_ctx_swap_buffers(void *data, video_frame_info_t video_info) +static void osmesa_ctx_swap_buffers(void *data, video_frame_info_t *video_info) { gfx_ctx_osmesa_data_t *osmesa = (gfx_ctx_osmesa_data_t*)data; osmesa_fifo_accept(osmesa); @@ -419,9 +394,9 @@ const gfx_ctx_driver_t gfx_ctx_osmesa = NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, /* translate_aspect */ - osmesa_ctx_update_window_title, + NULL, /* update_title */ osmesa_ctx_check_window, - osmesa_ctx_set_resize, + NULL, /* set_resize */ osmesa_ctx_has_focus, osmesa_ctx_suppress_screensaver, osmesa_ctx_has_windowed, diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index fa34420ec9..7f35f60daa 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -31,7 +31,6 @@ #endif #include "../../configuration.h" -#include "../../runloop.h" #include "../../defines/ps3_defines.h" #include "../common/gl_common.h" #include "../video_context_driver.h" @@ -149,7 +148,7 @@ static void gfx_ctx_ps3_set_swap_interval(void *data, unsigned interval) } static void gfx_ctx_ps3_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { gl_t *gl = data; @@ -173,13 +172,7 @@ static bool gfx_ctx_ps3_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_ps3_has_windowed(void *data) -{ - (void)data; - return false; -} - -static void gfx_ctx_ps3_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_ps3_swap_buffers(void *data, video_frame_info_t *video_info) { (void)data; #ifdef HAVE_LIBDBGFONT @@ -193,27 +186,6 @@ static void gfx_ctx_ps3_swap_buffers(void *data, video_frame_info_t video_info) #endif } -static bool gfx_ctx_ps3_set_resize(void *data, - unsigned width, unsigned height) -{ - return false; -} - -static void gfx_ctx_ps3_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - (void)data; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static void gfx_ctx_ps3_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -302,15 +274,10 @@ static void *gfx_ctx_ps3_init(video_frame_info_t video_info, void *video_driver) } static bool gfx_ctx_ps3_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { - global_t *global = global_get_ptr(); - - if (!global) - return false; - return true; } @@ -438,12 +405,12 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_ps3_get_video_output_next, NULL, /* get_metrics */ NULL, - gfx_ctx_ps3_update_window_title, + NULL, /* update_title */ gfx_ctx_ps3_check_window, - gfx_ctx_ps3_set_resize, + NULL, /* set_resize */ gfx_ctx_ps3_has_focus, gfx_ctx_ps3_suppress_screensaver, - gfx_ctx_ps3_has_windowed, + NULL, /* has_windowed */ gfx_ctx_ps3_swap_buffers, gfx_ctx_ps3_input_driver, NULL, diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 31ffdbda4b..252f89808d 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -284,14 +284,11 @@ static void gfx_ctx_qnx_get_video_size(void *data, } static void gfx_ctx_qnx_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; qnx_ctx_data_t *qnx = (qnx_ctx_data_t*)data; - (void)data; - (void)frame_count; - *quit = false; #ifdef HAVE_EGL @@ -310,30 +307,8 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit, *quit = true; } -static bool gfx_ctx_qnx_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_qnx_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_qnx_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -375,12 +350,6 @@ static bool gfx_ctx_qnx_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_qnx_has_windowed(void *data) -{ - (void)data; - return false; -} - static int dpi_get_density(qnx_ctx_data_t *qnx) { int screen_dpi[2]; @@ -444,7 +413,7 @@ static void gfx_ctx_qnx_set_swap_interval(void *data, unsigned swap_interval) #endif } -static void gfx_ctx_qnx_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_qnx_swap_buffers(void *data, video_frame_info_t *video_info) { qnx_ctx_data_t *qnx = (qnx_ctx_data_t*)data; @@ -493,12 +462,12 @@ const gfx_ctx_driver_t gfx_ctx_qnx = { NULL, /* get_video_output_next */ gfx_ctx_qnx__get_metrics, NULL, - gfx_ctx_qnx_update_window_title, + NULL, /* update_title */ gfx_ctx_qnx_check_window, - gfx_ctx_qnx_set_resize, + NULL, /* set_resize */ gfx_ctx_qnx_has_focus, gfx_ctx_qnx_suppress_screensaver, - gfx_ctx_qnx_has_windowed, + NULL, /* has_windowed */ gfx_ctx_qnx_swap_buffers, gfx_ctx_qnx_input_driver, gfx_ctx_qnx_get_proc_address, diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 50dd0c33a9..8b1847e44c 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -25,7 +25,6 @@ #endif #include "../../configuration.h" -#include "../../runloop.h" #include "../common/gl_common.h" static enum gfx_ctx_api sdl_api = GFX_CTX_OPENGL_API; @@ -42,7 +41,6 @@ typedef struct gfx_ctx_sdl_data bool g_full; bool g_resized; - int g_frame_count; #ifdef HAVE_SDL2 SDL_Window *g_win; SDL_GLContext g_ctx; @@ -163,7 +161,7 @@ static void sdl_ctx_swap_interval(void *data, unsigned interval) } static bool sdl_ctx_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -177,7 +175,7 @@ static bool sdl_ctx_set_video_mode(void *data, if (fullscreen) { - if (video_info.windowed_fullscreen) + if (video_info->windowed_fullscreen) fsflag = SDL_WINDOW_FULLSCREEN_DESKTOP; else fsflag = SDL_WINDOW_FULLSCREEN; @@ -192,7 +190,7 @@ static bool sdl_ctx_set_video_mode(void *data, } else { - unsigned display = video_info.monitor_index; + unsigned display = video_info->monitor_index; sdl->g_win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), @@ -268,31 +266,30 @@ static void sdl_ctx_get_video_size(void *data, } } -static void sdl_ctx_update_window_title(void *data, video_frame_info_t video_info) +static void sdl_ctx_update_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buf_fps[128]; + char title[128]; - buf[0] = buf_fps[0] = '\0'; + title[0] = '\0'; - if (video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) + video_driver_get_window_title(title, sizeof(title)); + + if (video_info->monitor_fps_enable) { #ifdef HAVE_SDL2 gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data; - if (sdl) - SDL_SetWindowTitle(sdl->g_win, buf); + + if (sdl && title[0]) + SDL_SetWindowTitle(sdl->g_win, title); #else - SDL_WM_SetCaption(buf, NULL); + if (title[0]) + SDL_WM_SetCaption(title, NULL); #endif } - - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); } static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *width, - unsigned *height, unsigned frame_count) + unsigned *height) { SDL_Event event; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data; @@ -340,16 +337,6 @@ static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned * *resize = true; sdl->g_resized = false; } - - sdl->g_frame_count = frame_count; -} - -static bool sdl_ctx_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; } static bool sdl_ctx_has_focus(void *data) @@ -379,7 +366,7 @@ static bool sdl_ctx_has_windowed(void *data) return true; } -static void sdl_ctx_swap_buffers(void *data, video_frame_info_t video_info) +static void sdl_ctx_swap_buffers(void *data, video_frame_info_t *video_info) { #ifdef HAVE_SDL2 gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data; @@ -435,9 +422,9 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, /* translate_aspect */ - sdl_ctx_update_window_title, + sdl_ctx_update_title, sdl_ctx_check_window, - sdl_ctx_set_resize, + NULL, /* set_resize */ sdl_ctx_has_focus, sdl_ctx_suppress_screensaver, sdl_ctx_has_windowed, diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 959b0571e3..c2b98d5ebd 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -86,10 +86,9 @@ static INLINE bool gfx_ctx_vc_egl_query_extension(vc_ctx_data_t *vc, const char } static void gfx_ctx_vc_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { (void)data; - (void)frame_count; (void)width; (void)height; @@ -97,27 +96,6 @@ static void gfx_ctx_vc_check_window(void *data, bool *quit, *quit = (bool)frontend_driver_get_signal_handler_state(); } -static bool gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_vc_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static void gfx_ctx_vc_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -319,7 +297,7 @@ static void gfx_ctx_vc_set_swap_interval(void *data, unsigned swap_interval) } static bool gfx_ctx_vc_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -471,12 +449,6 @@ static bool gfx_ctx_vc_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_vc_has_windowed(void *data) -{ - (void)data; - return false; -} - static float gfx_ctx_vc_translate_aspect(void *data, unsigned width, unsigned height) { @@ -608,7 +580,7 @@ error: return false; } -static void gfx_ctx_vc_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_vc_swap_buffers(void *data, video_frame_info_t *video_info) { vc_ctx_data_t *vc = (vc_ctx_data_t*)data; @@ -659,12 +631,12 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ gfx_ctx_vc_translate_aspect, - gfx_ctx_vc_update_window_title, + NULL, /* update_title */ gfx_ctx_vc_check_window, - gfx_ctx_vc_set_resize, + NULL, /* set_resize */ gfx_ctx_vc_has_focus, gfx_ctx_vc_suppress_screensaver, - gfx_ctx_vc_has_windowed, + NULL, /* has_windowed */ gfx_ctx_vc_swap_buffers, gfx_ctx_vc_input_driver, gfx_ctx_vc_get_proc_address, diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index ac12fc7afa..c59e5dd577 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -29,7 +29,6 @@ #endif #include "../../frontend/frontend_driver.h" -#include "../../runloop.h" typedef struct { @@ -117,7 +116,7 @@ static void gfx_ctx_vivante_get_video_size(void *data, } static void gfx_ctx_vivante_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data; @@ -136,30 +135,8 @@ static void gfx_ctx_vivante_check_window(void *data, bool *quit, *quit = (bool)frontend_driver_get_signal_handler_state(); } -static bool gfx_ctx_vivante_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - -static void gfx_ctx_vivante_update_window_title(void *data, video_frame_info_t video_info) -{ - char buf[128]; - char buf_fps[128]; - - buf[0] = buf_fps[0] = '\0'; - - video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); -} - static bool gfx_ctx_vivante_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -231,12 +208,6 @@ static bool gfx_ctx_vivante_suppress_screensaver(void *data, bool enable) return false; } -static bool gfx_ctx_vivante_has_windowed(void *data) -{ - (void)data; - return false; -} - static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned swap_interval) { vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data; @@ -246,7 +217,7 @@ static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned swap_interval #endif } -static void gfx_ctx_vivante_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_vivante_swap_buffers(void *data, video_frame_info_t *video_info) { vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data; @@ -297,12 +268,12 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_vivante_update_window_title, + NULL, /* update_title */ gfx_ctx_vivante_check_window, - gfx_ctx_vivante_set_resize, + NULL, /* set_resize */ gfx_ctx_vivante_has_focus, gfx_ctx_vivante_suppress_screensaver, - gfx_ctx_vivante_has_windowed, + NULL, /* has_windowed */ gfx_ctx_vivante_swap_buffers, gfx_ctx_vivante_input_driver, gfx_ctx_vivante_get_proc_address, diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index a59e99f91c..70100b88a3 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -643,14 +643,11 @@ static void flush_wayland_fd(gfx_ctx_wayland_data_t *wl) } static void gfx_ctx_wl_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, - unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { unsigned new_width, new_height; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - (void)frame_count; - flush_wayland_fd(wl); new_width = *width; @@ -719,20 +716,17 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) return true; } -static void gfx_ctx_wl_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_wl_update_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buf_fps[128]; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + char title[128]; - buf[0] = buf_fps[0] = '\0'; + title[0] = '\0'; - if (video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) - wl_shell_surface_set_title(wl->shell_surf, buf); + video_driver_get_window_title(title, sizeof(title)); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + if (wl && title[0] && video_info->monitor_fps_enable) + wl_shell_surface_set_title(wl->shell_surf, title); } @@ -1075,7 +1069,7 @@ static void gfx_ctx_wl_set_swap_interval(void *data, unsigned swap_interval) } static bool gfx_ctx_wl_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -1557,7 +1551,7 @@ static void *gfx_ctx_wl_get_context_data(void *data) } #endif -static void gfx_ctx_wl_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_wl_swap_buffers(void *data, video_frame_info_t *video_info) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; @@ -1676,7 +1670,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, /* get_video_output_next */ gfx_ctx_wl_get_metrics, NULL, - gfx_ctx_wl_update_window_title, + gfx_ctx_wl_update_title, gfx_ctx_wl_check_window, gfx_ctx_wl_set_resize, gfx_ctx_wl_has_focus, diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index fba99cf998..18b83ba5c0 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -41,7 +41,6 @@ #include "../../configuration.h" #include "../../dynamic.h" -#include "../../runloop.h" #include "../video_context_driver.h" #include "../common/win32_common.h" @@ -312,7 +311,7 @@ static void gfx_ctx_wgl_swap_interval(void *data, unsigned interval) } static void gfx_ctx_wgl_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { win32_check_window(quit, resize, width, height); @@ -331,7 +330,7 @@ static void gfx_ctx_wgl_check_window(void *data, bool *quit, } } -static void gfx_ctx_wgl_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_wgl_swap_buffers(void *data, video_frame_info_t *video_info) { (void)data; @@ -386,19 +385,21 @@ static bool gfx_ctx_wgl_set_resize(void *data, return false; } -static void gfx_ctx_wgl_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_wgl_update_title(void *data, video_frame_info_t *video_info) { - char buf[128]; - char buf_fps[128]; const ui_window_t *window = ui_companion_driver_get_window_ptr(); - buf[0] = buf_fps[0] = '\0'; + if (window && video_info->monitor_fps_enable) + { + char title[128]; - if (window && video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) - window->set_title(&main_window, buf); - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + window->set_title(&main_window, title); + } } static void gfx_ctx_wgl_get_video_size(void *data, @@ -525,7 +526,7 @@ static void gfx_ctx_wgl_destroy(void *data) } static bool gfx_ctx_wgl_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -687,7 +688,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { NULL, /* get_video_output_next */ gfx_ctx_wgl_get_metrics, NULL, - gfx_ctx_wgl_update_window_title, + gfx_ctx_wgl_update_title, gfx_ctx_wgl_check_window, gfx_ctx_wgl_set_resize, gfx_ctx_wgl_has_focus, diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 50a504abc2..08a6e64170 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -302,7 +302,7 @@ static void gfx_ctx_x_swap_interval(void *data, unsigned interval) } } -static void gfx_ctx_x_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_x_swap_buffers(void *data, video_frame_info_t *video_info) { gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; @@ -347,9 +347,9 @@ static void gfx_ctx_x_swap_buffers(void *data, video_frame_info_t video_info) } static void gfx_ctx_x_check_window(void *data, bool *quit, - bool *resize, unsigned *width, unsigned *height, unsigned frame_count) + bool *resize, unsigned *width, unsigned *height) { - x11_check_window(data, quit, resize, width, height, frame_count); + x11_check_window(data, quit, resize, width, height); switch (x_api) { @@ -545,7 +545,7 @@ error: } static bool gfx_ctx_x_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -565,7 +565,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, if (!x) return false; - windowed_full = video_info.windowed_fullscreen; + windowed_full = video_info->windowed_fullscreen; true_full = false; switch (x_api) @@ -613,8 +613,8 @@ static bool gfx_ctx_x_set_video_mode(void *data, RARCH_ERR("[GLX]: Entering true fullscreen failed. Will attempt windowed mode.\n"); } - if (video_info.monitor_index) - g_x11_screen = video_info.monitor_index - 1; + if (video_info->monitor_index) + g_x11_screen = video_info->monitor_index - 1; #ifdef HAVE_XINERAMA if (fullscreen || g_x11_screen != 0) @@ -660,9 +660,8 @@ static bool gfx_ctx_x_set_video_mode(void *data, break; } - x11_set_window_attr(g_x11_dpy, g_x11_win); - x11_update_window_title(NULL, video_info); + x11_update_title(NULL, video_info); if (fullscreen) x11_show_mouse(g_x11_dpy, g_x11_win, false); @@ -789,7 +788,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, { bool quit, resize; unsigned width = 0, height = 0; - x11_check_window(x, &quit, &resize, &width, &height, 0); + x11_check_window(x, &quit, &resize, &width, &height); /* Use XCB surface since it's the most supported WSI. * We can obtain the XCB connection directly from X11. */ @@ -1081,7 +1080,7 @@ const gfx_ctx_driver_t gfx_ctx_x = { NULL, /* get_video_output_next */ x11_get_metrics, NULL, - x11_update_window_title, + x11_update_title, gfx_ctx_x_check_window, gfx_ctx_x_set_resize, x11_has_focus, diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 133736d847..661d5239c0 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -91,15 +91,6 @@ EGL_BLUE_SIZE, 1, \ EGL_ALPHA_SIZE, 0, \ EGL_DEPTH_SIZE, 0 -static bool gfx_ctx_xegl_set_resize(void *data, - unsigned width, unsigned height) -{ - (void)data; - (void)width; - (void)height; - return false; -} - static void *gfx_ctx_xegl_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL @@ -257,7 +248,7 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) static void gfx_ctx_xegl_set_swap_interval(void *data, unsigned swap_interval); static bool gfx_ctx_xegl_set_video_mode(void *data, - video_frame_info_t video_info, + video_frame_info_t *video_info, unsigned width, unsigned height, bool fullscreen) { @@ -298,7 +289,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, ButtonPressMask | ButtonReleaseMask | KeyReleaseMask; swa.override_redirect = fullscreen ? True : False; - if (fullscreen && !video_info.windowed_fullscreen) + if (fullscreen && !video_info->windowed_fullscreen) { if (x11_enter_fullscreen(video_info, g_x11_dpy, width, height, &xegl->desktop_mode)) { @@ -309,8 +300,8 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, RARCH_ERR("[X/EGL]: Entering true fullscreen failed. Will attempt windowed mode.\n"); } - if (video_info.monitor_index) - g_x11_screen = video_info.monitor_index - 1; + if (video_info->monitor_index) + g_x11_screen = video_info->monitor_index - 1; #ifdef HAVE_XINERAMA if (fullscreen || g_x11_screen != 0) @@ -352,7 +343,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, goto error; x11_set_window_attr(g_x11_dpy, g_x11_win); - x11_update_window_title(NULL, video_info); + x11_update_title(NULL, video_info); if (fullscreen) x11_show_mouse(g_x11_dpy, g_x11_win, false); @@ -490,7 +481,7 @@ static void gfx_ctx_xegl_show_mouse(void *data, bool state) x11_show_mouse(g_x11_dpy, g_x11_win, state); } -static void gfx_ctx_xegl_swap_buffers(void *data, video_frame_info_t video_info) +static void gfx_ctx_xegl_swap_buffers(void *data, video_frame_info_t *video_info) { xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; @@ -591,9 +582,9 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = NULL, /* get_video_output_next */ x11_get_metrics, NULL, - x11_update_window_title, + x11_update_title, x11_check_window, - gfx_ctx_xegl_set_resize, + NULL, /* set_resize */ x11_has_focus, gfx_ctx_xegl_suppress_screensaver, gfx_ctx_xegl_has_windowed, diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index 2409aec4e1..58a4e9878a 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -33,7 +33,10 @@ /* FIXME: this is just a workaround to avoid * using ctrGuCopyImage, since it seems to cause * a freeze/blackscreen when used here. */ -//#define FONT_TEXTURE_IN_VRAM + +#if 0 +#define FONT_TEXTURE_IN_VRAM +#endif typedef struct { @@ -227,7 +230,8 @@ static void ctr_font_render_line( return; ctrGuSetVertexShaderFloatUniform(0, (float*)&font->scale_vector, 1); - GSPGPU_FlushDataCache(ctr->vertex_cache.current, (v - ctr->vertex_cache.current) * sizeof(ctr_vertex_t)); + GSPGPU_FlushDataCache(ctr->vertex_cache.current, + (v - ctr->vertex_cache.current) * sizeof(ctr_vertex_t)); ctrGuSetAttributeBuffers(2, VIRT_TO_PHYS(ctr->vertex_cache.current), CTRGU_ATTRIBFMT(GPU_SHORT, 4) << 0 | @@ -241,18 +245,25 @@ static void ctr_font_render_line( GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_R, GPU_TEVOP_RGB_SRC_ALPHA, 0), GPU_MODULATE, GPU_MODULATE, color); -// printf("%s\n", msg); -// DEBUG_VAR(color); -// GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_R, 0, 0), GPU_REPLACE, GPU_REPLACE, 0); - ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(font->texture.data), font->texture.width, font->texture.height, - GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST) | - GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), - GPU_L8); + +#if 0 + printf("%s\n", msg); + DEBUG_VAR(color); + GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, + GPU_TEVOPERANDS(GPU_TEVOP_RGB_SRC_R, 0, 0), GPU_REPLACE, GPU_REPLACE, 0); +#endif + + ctrGuSetTexture(GPU_TEXUNIT0, VIRT_TO_PHYS(font->texture.data), + font->texture.width, font->texture.height, + GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST) | + GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_EDGE) | GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_EDGE), + GPU_L8); GPU_SetViewport(NULL, - VIRT_TO_PHYS(ctr->drawbuffers.top.left), - 0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, - ctr->video_mode == CTR_VIDEO_MODE_800x240 ? CTR_TOP_FRAMEBUFFER_WIDTH * 2 : CTR_TOP_FRAMEBUFFER_WIDTH); + VIRT_TO_PHYS(ctr->drawbuffers.top.left), + 0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, + ctr->video_mode == CTR_VIDEO_MODE_800x240 + ? CTR_TOP_FRAMEBUFFER_WIDTH * 2 : CTR_TOP_FRAMEBUFFER_WIDTH); GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, v - ctr->vertex_cache.current); @@ -265,29 +276,32 @@ static void ctr_font_render_line( GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, v - ctr->vertex_cache.current); } - - - -// v = font->vertices; -// v->x0 = 0; -// v->y0 = 0; -// v->u0 = 0; -// v->v0 = 0; -// v->x1 = font->texture.width; -// v->y1 = font->texture.height; -// v->u1 = font->texture.width; -// v->v1 = font->texture.height; -// GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1); +#if 0 + v = font->vertices; + v->x0 = 0; + v->y0 = 0; + v->u0 = 0; + v->v0 = 0; + v->x1 = font->texture.width; + v->y1 = font->texture.height; + v->u1 = font->texture.width; + v->v1 = font->texture.height; + GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, 1); +#endif GPU_SetTexEnv(0, GPU_TEXTURE0, GPU_TEXTURE0, 0, 0, GPU_REPLACE, GPU_REPLACE, 0); - // DEBUG_VAR(v - font->vertices); - // v = font->vertices; - // printf("OSDMSG: %s\n", msg); - // printf("vertex : (%i,%i,%i,%i) - (%i,%i,%i,%i)\n", - // v->x0, v->y0, v->x1, v->y1, - // v->u0, v->v0, v->u1, v->v1); -// printf("%s\n", msg); +#if 0 + DEBUG_VAR(v - font->vertices); + v = font->vertices; + printf("OSDMSG: %s\n", msg); + printf("vertex : (%i,%i,%i,%i) - (%i,%i,%i,%i)\n", + v->x0, v->y0, v->x1, v->y1, + v->u0, v->v0, v->u1, v->v1); + + printf("%s\n", msg); +#endif + ctr->vertex_cache.current = v; } diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 9bf06e725d..a8cc52e78d 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -282,7 +282,7 @@ bool video_context_driver_check_window(gfx_ctx_size_t *size_data) size_data->quit, size_data->resize, size_data->width, - size_data->height, (unsigned int)video_driver_get_frame_count()); + size_data->height); return true; } @@ -456,22 +456,12 @@ bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info) video_driver_build_info(&video_info); if (!current_video_context->set_video_mode( - video_context_data, video_info, mode_info->width, + video_context_data, &video_info, mode_info->width, mode_info->height, mode_info->fullscreen)) return false; return true; } -bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info) -{ - if (!current_video_context) - return false; - if (!current_video_context->set_resize( - video_context_data, mode_info->width, mode_info->height)) - return false; - return true; -} - bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info) { if (!current_video_context || !current_video_context->get_video_size) diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 55a150c177..52baf831d9 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -78,7 +78,7 @@ typedef struct gfx_ctx_driver void (*swap_interval)(void *data, unsigned); /* Sets video mode. Creates a window, etc. */ - bool (*set_video_mode)(void*, video_frame_info_t video_info, unsigned, unsigned, bool); + bool (*set_video_mode)(void*, video_frame_info_t *video_info, unsigned, unsigned, bool); /* Gets current window size. * If not initialized yet, it returns current screen size. */ @@ -101,12 +101,12 @@ typedef struct gfx_ctx_driver float (*translate_aspect)(void*, unsigned, unsigned); /* Asks driver to update window title (FPS, etc). */ - void (*update_window_title)(void*, video_frame_info_t video_info); + void (*update_window_title)(void*, video_frame_info_t *video_info); /* Queries for resize and quit events. * Also processes events. */ void (*check_window)(void*, bool*, bool*, - unsigned*, unsigned*, unsigned); + unsigned*, unsigned*); /* Acknowledge a resize event. This is needed for some APIs. * Most backends will ignore this. */ @@ -123,7 +123,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); + void (*swap_buffers)(void*, video_frame_info_t *video_info); /* Most video backends will want to use a certain input driver. * Checks for it here. */ @@ -302,6 +302,10 @@ void video_context_driver_destroy(void); #define video_context_driver_focus() ((video_context_data && current_video_context->has_focus && current_video_context->has_focus(video_context_data)) ? true : false) +#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) + bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data); bool video_context_driver_swap_interval(unsigned *interval); @@ -314,8 +318,6 @@ bool video_context_driver_get_ident(gfx_ctx_ident_t *ident); bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info); -bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info); - bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info); bool video_context_driver_get_context_data(void *data); @@ -334,7 +336,7 @@ bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect); bool video_context_driver_input_driver(gfx_ctx_input_t *inp); -#define video_context_driver_has_windowed() ((video_context_data && current_video_context->has_windowed(video_context_data)) ? true : false) +#define video_context_driver_has_windowed() ((video_context_data && current_video_context->has_windowed && current_video_context->has_windowed(video_context_data)) ? true : false) void video_context_driver_free(void); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 9ad62c93be..e3928f934c 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -137,6 +137,8 @@ static unsigned video_driver_height = 0; static enum rarch_display_type video_driver_display_type = RARCH_DISPLAY_NONE; static char video_driver_title_buf[64] = {0}; +static char video_driver_window_title[128] = {0}; +static bool video_driver_window_title_update = true; static retro_time_t video_driver_frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT]; static uint64_t video_driver_frame_time_count = 0; @@ -971,18 +973,22 @@ void video_driver_cached_frame_get(const void **data, unsigned *width, void video_driver_get_size(unsigned *width, unsigned *height) { + video_driver_threaded_lock(); if (width) *width = video_driver_width; if (height) *height = video_driver_height; + video_driver_threaded_unlock(); } void video_driver_set_size(unsigned *width, unsigned *height) { + video_driver_threaded_lock(); if (width) video_driver_width = *width; if (height) video_driver_height = *height; + video_driver_threaded_unlock(); } /** @@ -1057,89 +1063,6 @@ bool video_monitor_fps_statistics(double *refresh_rate, } -/** - * video_monitor_get_fps: - * @buf : string suitable for Window title - * @size : size of buffer. - * @buf_fps : string of raw FPS only (optional). - * @size_fps : size of raw FPS buffer. - * - * Get the amount of frames per seconds. - * - * Returns: true if framerate per seconds could be obtained, - * otherwise false. - * - **/ -bool video_monitor_get_fps( - video_frame_info_t video_info, - char *buf, size_t size, - char *buf_fps, size_t size_fps) -{ - static retro_time_t curr_time; - static retro_time_t fps_time; - retro_time_t new_time = cpu_features_get_time_usec(); - uint64_t frame_count = 0; - - video_driver_threaded_lock(); - frame_count = video_driver_frame_count; - video_driver_threaded_unlock(); - - *buf = '\0'; - - if (frame_count) - { - static float last_fps; - bool ret = false; - unsigned write_index = video_driver_frame_time_count++ & - (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); - - video_driver_frame_time_samples[write_index] = new_time - fps_time; - fps_time = new_time; - - if ((frame_count % FPS_UPDATE_INTERVAL) == 0) - { - char frames_text[64]; - - last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); - curr_time = new_time; - - fill_pathname_noext(buf, - video_driver_title_buf, - " || ", - size); - - if (video_info.fps_show) - { - char fps_text[64]; - snprintf(fps_text, sizeof(fps_text), " FPS: %6.1f || ", last_fps); - strlcat(buf, fps_text, size); - } - - strlcat(buf, "Frames: ", size); - - snprintf(frames_text, sizeof(frames_text), STRING_REP_UINT64, - (unsigned long long)frame_count); - - strlcat(buf, frames_text, size); - ret = true; - } - - if (buf_fps && video_info.fps_show) - snprintf(buf_fps, size_fps, "FPS: %6.1f || %s: " STRING_REP_UINT64, - last_fps, - msg_hash_to_str(MSG_FRAMES), - (unsigned long long)frame_count); - - return ret; - } - - curr_time = fps_time = new_time; - strlcpy(buf, video_driver_title_buf, size); - if (buf_fps) - strlcpy(buf_fps, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), size_fps); - - return true; -} float video_driver_get_aspect_ratio(void) { @@ -2086,6 +2009,96 @@ unsigned video_pixel_get_alignment(unsigned pitch) return 8; } +/** + * video_monitor_get_fps: + * + * Get the amount of frames per seconds. + * + * Returns: true if framerate per seconds could be obtained, + * otherwise false. + * + **/ +static bool video_monitor_get_fps(video_frame_info_t *video_info) +{ + static retro_time_t curr_time; + static retro_time_t fps_time; + retro_time_t new_time = cpu_features_get_time_usec(); + + if (video_info->frame_count) + { + static float last_fps; + bool ret = false; + unsigned write_index = video_driver_frame_time_count++ & + (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); + + video_driver_frame_time_samples[write_index] = new_time - fps_time; + fps_time = new_time; + + if ((video_info->frame_count % FPS_UPDATE_INTERVAL) == 0) + { + char frames_text[64]; + + last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); + curr_time = new_time; + + fill_pathname_noext(video_driver_window_title, + video_driver_title_buf, + " || ", + sizeof(video_driver_window_title)); + + if (video_info->fps_show) + { + snprintf(video_info->fps_text, + sizeof(video_info->fps_text), + " FPS: %6.1f || ", last_fps); + strlcat(video_driver_window_title, + video_info->fps_text, + sizeof(video_driver_window_title)); + } + + strlcat(video_driver_window_title, + "Frames: ", + sizeof(video_driver_window_title)); + + snprintf(frames_text, + sizeof(frames_text), + STRING_REP_UINT64, + (unsigned long long)video_info->frame_count); + + strlcat(video_driver_window_title, + frames_text, + sizeof(video_driver_window_title)); + ret = true; + + video_driver_window_title_update = true; + } + + if (video_info->fps_show) + snprintf( + video_info->fps_text, + sizeof(video_info->fps_text), + "FPS: %6.1f || %s: " STRING_REP_UINT64, + last_fps, + msg_hash_to_str(MSG_FRAMES), + (unsigned long long)video_info->frame_count); + + return ret; + } + + curr_time = fps_time = new_time; + strlcpy(video_driver_window_title, + video_driver_title_buf, + sizeof(video_driver_window_title)); + + strlcpy(video_info->fps_text, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), + sizeof(video_info->fps_text)); + + video_driver_window_title_update = true; + + return true; +} + /** * video_driver_frame: * @data : pointer to data of the video frame. @@ -2127,10 +2140,21 @@ void video_driver_frame(const void *data, unsigned width, performance_counter_stop(&video_frame_conv); - video_driver_cached_frame_set(data, width, height, pitch); + if (data) + frame_cache_data = data; + frame_cache_width = width; + frame_cache_height = height; + frame_cache_pitch = pitch; video_driver_build_info(&video_info); + video_driver_threaded_lock(); + video_info.frame_count = video_driver_frame_count; + video_driver_frame_count++; + video_driver_threaded_unlock(); + + video_info.monitor_fps_enable = video_monitor_get_fps(&video_info); + /* Slightly messy code, * but we really need to do processing before blocking on VSync * for best possible scheduling. @@ -2161,16 +2185,14 @@ void video_driver_frame(const void *data, unsigned width, && video_info.font_enable && msg) strlcpy(video_driver_msg, msg, sizeof(video_driver_msg)); - video_driver_threaded_lock(); - frame_count = video_driver_frame_count; - video_driver_frame_count++; - video_driver_threaded_unlock(); - if (!current_video || !current_video->frame( video_driver_data, data, width, height, frame_count, - pitch, video_driver_msg, video_info)) + pitch, video_driver_msg, &video_info)) video_driver_active = false; + + if (video_info.fps_show) + runloop_msg_queue_push(video_info.fps_text, 1, 1, false); } void video_driver_display_type_set(enum rarch_display_type type) @@ -2229,6 +2251,7 @@ bool video_driver_texture_unload(uintptr_t *id) void video_driver_build_info(video_frame_info_t *video_info) { + video_driver_threaded_lock(); settings_t *settings = config_get_ptr(); video_info->refresh_rate = settings->video.refresh_rate; video_info->black_frame_insertion = @@ -2245,6 +2268,14 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->monitor_index = settings->video.monitor_index; video_info->shared_context = settings->video.shared_context; video_info->font_enable = settings->video.font_enable; + + video_info->frame_count = 0; + video_info->fps_text[0] = '\0'; + + video_info->width = video_driver_width; + video_info->height = video_driver_height; + + video_driver_threaded_unlock(); } /** @@ -2300,3 +2331,12 @@ bool video_driver_translate_coord_viewport( return true; } + +void video_driver_get_window_title(char *buf, unsigned len) +{ + if (buf && video_driver_window_title_update) + { + strlcpy(buf, video_driver_window_title, len); + video_driver_window_title_update = false; + } +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 768b896607..479cb77cf7 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -101,6 +101,12 @@ typedef struct video_frame_info bool fullscreen; unsigned monitor_index; bool font_enable; + bool monitor_fps_enable; + char fps_text[128]; + uint64_t frame_count; + + unsigned width; + unsigned height; } video_frame_info_t; /* Optionally implemented interface to poke more @@ -163,7 +169,7 @@ typedef struct video_viewport typedef bool (*video_driver_frame_t)(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 pitch, const char *msg, video_frame_info_t *video_info); typedef struct video_driver { @@ -242,7 +248,7 @@ extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; #if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) #define video_driver_has_windowed() (false) #else -#define video_driver_has_windowed() (current_video->has_windowed(video_driver_data)) +#define video_driver_has_windowed() (current_video->has_windowed && current_video->has_windowed(video_driver_data)) #endif #define video_driver_cached_frame_has_valid_framebuffer() (frame_cache_data ? (frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID) : false) @@ -462,25 +468,6 @@ void video_monitor_set_refresh_rate(float hz); bool video_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points); -/** - * video_monitor_get_fps: - * @video_info : information about the video frame - * @buf : string suitable for Window title - * @size : size of buffer. - * @buf_fps : string of raw FPS only (optional). - * @size_fps : size of raw FPS buffer. - * - * Get the amount of frames per seconds. - * - * Returns: true if framerate per seconds could be obtained, - * otherwise false. - * - **/ -bool video_monitor_get_fps( - video_frame_info_t video_info, - char *buf, size_t size, - char *buf_fps, size_t size_fps); - unsigned video_pixel_get_alignment(unsigned pitch); const video_poke_interface_t *video_driver_get_poke(void); @@ -543,6 +530,8 @@ void video_driver_build_info(video_frame_info_t *video_info); void video_driver_reinit(void); +void video_driver_get_window_title(char *buf, unsigned len); + extern video_driver_t video_gl; extern video_driver_t video_vulkan; extern video_driver_t video_psp1; diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index ed868fb1d7..0e1bb2c6f6 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -619,7 +619,7 @@ static void video_thread_loop(void *data) thr->frame.buffer, thr->frame.width, thr->frame.height, thr->frame.count, thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL, - video_info); + &video_info); } slock_unlock(thr->frame.lock); @@ -706,7 +706,7 @@ static bool video_thread_has_windowed(void *data) static bool video_thread_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 pitch, const char *msg, video_frame_info_t *video_info) { unsigned copy_stride; static struct retro_perf_counter thr_frame = {0}; @@ -741,7 +741,7 @@ static bool video_thread_frame(void *data, const void *frame_, { retro_time_t target_frame_time = (retro_time_t) - roundf(1000000 / video_info.refresh_rate); + roundf(1000000 / video_info->refresh_rate); retro_time_t target = thr->last_time + target_frame_time; /* Ideally, use absolute time, but that is only a good idea on POSIX. */ diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 056974cde4..cc0a7897c9 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -270,26 +270,28 @@ static void mui_draw_tab(mui_handle_t *mui, &tab_color[0]); } -static void mui_render_keyboard(mui_handle_t *mui, const char *grid[], unsigned id) +static void mui_render_keyboard(mui_handle_t *mui, + video_frame_info_t *video_info, + const char *grid[], unsigned id) { int ptr_width, ptr_height; - unsigned i, width, height; - float dark[16]= { + unsigned i; + unsigned width = video_info->width; + unsigned height = video_info->height; + float dark[16] = { 0.00, 0.00, 0.00, 0.85, 0.00, 0.00, 0.00, 0.85, 0.00, 0.00, 0.00, 0.85, 0.00, 0.00, 0.00, 0.85, }; - float white[16]= { + float white[16] = { 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, }; - video_driver_get_size(&width, &height); - menu_display_draw_quad(0, height/2.0, width, height/2.0, width, height, &dark[0]); @@ -327,17 +329,16 @@ static void mui_render_keyboard(mui_handle_t *mui, const char *grid[], unsigned } /* Returns the OSK key at a given position */ -static int mui_osk_ptr_at_pos(void *data, int x, int y) +static int mui_osk_ptr_at_pos(void *data, int x, int y, + unsigned width, unsigned height) { + unsigned i; int ptr_width, ptr_height; - unsigned i, width, height; - mui_handle_t *mui = (mui_handle_t*)data; + if (!mui) return -1; - video_driver_get_size(&width, &height); - ptr_width = width / 11; ptr_height = height / 10; @@ -364,7 +365,7 @@ static void mui_draw_tab_begin(mui_handle_t *mui, { float scale_factor = menu_display_get_dpi(); - mui->tabs_height = scale_factor / 3; + mui->tabs_height = scale_factor / 3; /* tabs background */ menu_display_draw_quad(0, height - mui->tabs_height, width, @@ -395,16 +396,17 @@ static void mui_draw_tab_end(mui_handle_t *mui, &active_tab_marker_color[0]); } -static float mui_content_height() +static float mui_content_height(void) { + unsigned i; file_list_t *list = menu_entries_get_selection_buf_ptr(0); - float sum = 0; - unsigned i = 0; - for (; i < menu_entries_get_end(); i++) + float sum = 0; + + for (i = 0; i < menu_entries_get_end(); i++) { - mui_node_t *node = (mui_node_t*) - menu_entries_get_userdata_at_offset(list, i); - sum += node->line_height; + mui_node_t *node = (mui_node_t*) + menu_entries_get_userdata_at_offset(list, i); + sum += node->line_height; } return sum; } @@ -412,38 +414,31 @@ static float mui_content_height() static void mui_draw_scrollbar(mui_handle_t *mui, unsigned width, unsigned height, float *coord_color) { - unsigned header_height; - float content_height, total_height, - scrollbar_height, scrollbar_margin, y; - - if (!mui) - return; - - header_height = menu_display_get_header_height(); - - content_height = mui_content_height(); - total_height = height - header_height - mui->tabs_height; - scrollbar_margin = mui->scrollbar_width; - scrollbar_height = total_height / (content_height / total_height); - y = total_height * mui->scroll_y / content_height; + unsigned header_height = menu_display_get_header_height(); + float content_height = mui_content_height(); + float total_height = height - header_height - mui->tabs_height; + float scrollbar_margin = mui->scrollbar_width; + float scrollbar_height = total_height / (content_height / total_height); + float y = total_height * mui->scroll_y / content_height; /* apply a margin on the top and bottom of the scrollbar for aestetic */ - scrollbar_height -= scrollbar_margin * 2; - y += scrollbar_margin; + scrollbar_height -= scrollbar_margin * 2; + y += scrollbar_margin; - if (content_height >= total_height) - { - /* if the scrollbar is extremely short, display it as a square */ - if (scrollbar_height <= mui->scrollbar_width) - scrollbar_height = mui->scrollbar_width; + if (content_height < total_height) + return; - menu_display_draw_quad( width - mui->scrollbar_width - scrollbar_margin, - header_height + y, - mui->scrollbar_width, - scrollbar_height, - width, height, - coord_color); - } + /* if the scrollbar is extremely short, display it as a square */ + if (scrollbar_height <= mui->scrollbar_width) + scrollbar_height = mui->scrollbar_width; + + menu_display_draw_quad( + width - mui->scrollbar_width - scrollbar_margin, + header_height + y, + mui->scrollbar_width, + scrollbar_height, + width, height, + coord_color); } static void mui_get_message(void *data, const char *message) @@ -457,10 +452,13 @@ static void mui_get_message(void *data, const char *message) } static void mui_render_messagebox(mui_handle_t *mui, + video_frame_info_t *video_info, const char *message, float *body_bg_color, uint32_t font_color) { - unsigned i, width, height, y_position; + unsigned i, y_position; int x, y, line_height, longest = 0, longest_width = 0; + unsigned width = video_info->width; + unsigned height = video_info->height; struct string_list *list = (struct string_list*) string_split(message, "\n"); @@ -469,8 +467,6 @@ static void mui_render_messagebox(mui_handle_t *mui, if (list->elems == 0) goto end; - video_driver_get_size(&width, &height); - line_height = mui->font->size * 1.2; y_position = height / 2; @@ -515,27 +511,30 @@ static void mui_render_messagebox(mui_handle_t *mui, } if (menu_input_dialog_get_display_kb()) - mui_render_keyboard(mui, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); + mui_render_keyboard(mui, + video_info, + menu_event_get_osk_grid(), menu_event_get_osk_ptr()); end: string_list_free(list); } -static unsigned count_lines(const char *str) +static unsigned mui_count_lines(const char *str) { - unsigned c = 0; + unsigned c = 0; unsigned lines = 1; + for (c = 0; str[c]; c++) lines += (str[c] == '\n'); return lines; } -static void compute_entries_box(mui_handle_t* mui, int width) +static void mui_compute_entries_box(mui_handle_t* mui, int width) { size_t usable_width = width - (mui->margin * 2); - file_list_t *list = menu_entries_get_selection_buf_ptr(0); - float sum = 0; - unsigned i = 0; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + float sum = 0; + unsigned i = 0; for (; i < menu_entries_get_end(); i++) { @@ -550,7 +549,7 @@ static void compute_entries_box(mui_handle_t* mui, int width) if (menu_entry_get_sublabel(i, sublabel_str, sizeof(sublabel_str))) { word_wrap(sublabel_str, sublabel_str, (int)(usable_width / mui->glyph_width2)); - lines = count_lines(sublabel_str); + lines = mui_count_lines(sublabel_str); } scale_factor = menu_display_get_dpi(); @@ -562,20 +561,20 @@ static void compute_entries_box(mui_handle_t* mui, int width) static void mui_render(void *data) { - size_t i = 0; menu_animation_ctx_delta_t delta; float delta_time; unsigned bottom, width, height, header_height; + size_t i = 0; mui_handle_t *mui = (mui_handle_t*)data; settings_t *settings = config_get_ptr(); - file_list_t *list = menu_entries_get_selection_buf_ptr(0); + file_list_t *list = menu_entries_get_selection_buf_ptr(0); if (!mui) return; video_driver_get_size(&width, &height); - compute_entries_box(mui, width); + mui_compute_entries_box(mui, width); menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time); @@ -800,7 +799,9 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, ); } -static void mui_render_menu_list(mui_handle_t *mui, +static void mui_render_menu_list( + video_frame_info_t *video_info, + mui_handle_t *mui, unsigned width, unsigned height, uint32_t font_normal_color, uint32_t font_hover_color, @@ -809,9 +810,8 @@ static void mui_render_menu_list(mui_handle_t *mui, float sum = 0; unsigned header_height = 0; size_t i = 0; - uint64_t frame_count = 0; file_list_t *list = NULL; - frame_count = video_driver_get_frame_count(); + uint64_t frame_count = video_info->frame_count; if (!menu_display_get_update_pending()) return; @@ -938,7 +938,7 @@ static void mui_draw_bg(menu_display_ctx_draw_t *draw) menu_display_blend_end(); } -static void mui_frame(void *data) +static void mui_frame(void *data, video_frame_info_t *video_info) { float black_bg[16] = { 0, 0, 0, 0.75, @@ -1028,15 +1028,15 @@ static void mui_frame(void *data) float header_bg_color_real[16] = {0}; file_list_t *list = NULL; mui_node_t *node = NULL; - unsigned width = 0; - unsigned height = 0; + unsigned width = video_info->width; + unsigned height = video_info->height; unsigned ticker_limit = 0; unsigned i = 0; unsigned header_height = 0; size_t selection = 0; size_t title_margin = 0; mui_handle_t *mui = (mui_handle_t*)data; - uint64_t frame_count = video_driver_get_frame_count(); + uint64_t frame_count = video_info->frame_count; settings_t *settings = config_get_ptr(); bool background_rendered = false; bool libretro_running = menu_display_libretro_running(); @@ -1210,9 +1210,7 @@ static void mui_frame(void *data) menu_display_set_alpha(header_bg_color_real, settings->menu.header.opacity); menu_display_set_alpha(footer_bg_color_real, settings->menu.footer.opacity); - video_driver_get_size(&width, &height); - - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); header_height = menu_display_get_header_height(); if (libretro_running) @@ -1293,6 +1291,7 @@ static void mui_frame(void *data) menu_display_font_bind_block(mui->font2, &mui->raster_block2); mui_render_menu_list( + video_info, mui, width, height, @@ -1405,13 +1404,13 @@ static void mui_frame(void *data) menu_display_draw_quad(0, 0, width, height, width, height, &black_bg[0]); snprintf(msg, sizeof(msg), "%s\n%s", label, str); - mui_render_messagebox(mui, msg, &body_bg_color[0], font_hover_color); + mui_render_messagebox(mui, video_info, msg, &body_bg_color[0], font_hover_color); } if (!string_is_empty(mui->box_message)) { menu_display_draw_quad(0, 0, width, height, width, height, &black_bg[0]); - mui_render_messagebox(mui, mui->box_message, &body_bg_color[0], font_hover_color); + mui_render_messagebox(mui, video_info, mui->box_message, &body_bg_color[0], font_hover_color); mui->box_message[0] = '\0'; } @@ -1426,7 +1425,7 @@ static void mui_frame(void *data) height); menu_display_restore_clear_color(); - menu_display_unset_viewport(); + menu_display_unset_viewport(video_info->width, video_info->height); } static void mui_layout(mui_handle_t *mui) @@ -1661,7 +1660,6 @@ static void mui_context_reset(void *data) if (!mui || !settings) return; - mui_layout(mui); mui_context_bg_destroy(mui); menu_display_allocate_white_texture(); diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 78b37184c5..618385a713 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -145,6 +145,9 @@ static void xmb_init_ribbon(nk_menu_handle_t * xmb) static void *nk_menu_init(void **userdata) { +#if 1 + unsigned i; +#endif settings_t *settings = config_get_ptr(); nk_menu_handle_t *nk = NULL; menu_handle_t *menu = (menu_handle_t*) @@ -169,16 +172,18 @@ static void *nk_menu_init(void **userdata) "nuklear", sizeof(nk->assets_directory)); nk_menu_init_device(nk); - /* for demo puposes only, opens all windows */ + /* for demo purposes only, opens all windows */ #if 1 - for (int i=0; i < NK_WND_LAST; i++) + for (i = 0; i < NK_WND_LAST; i++) nk->window[i].open = true; #else nk->window[NK_WND_MAIN].open = true; #endif xmb_init_ribbon(nk); + return menu; error: + if (menu) free(menu); return NULL; @@ -250,6 +255,7 @@ static void nk_menu_get_message(void *data, const char *message) static void nk_draw_bg( nk_menu_handle_t *nk, + video_frame_info_t *video_info, unsigned width, unsigned height, float alpha, @@ -273,7 +279,7 @@ static void nk_draw_bg( draw.pipeline.id = 0; menu_display_blend_begin(); - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); draw.pipeline.id = VIDEO_SHADER_MENU_5; draw.pipeline.active = false; @@ -302,18 +308,24 @@ static void nk_menu_main(nk_menu_handle_t *nk) } -static void nk_menu_frame(void *data) +static void nk_menu_frame(void *data, video_frame_info_t *video_info) { - float white_bg[16]= { + unsigned ticker_limit, i; + float coord_black[16], coord_white[16]; + nk_menu_handle_t *nk = (nk_menu_handle_t*)data; + settings_t *settings = config_get_ptr(); + unsigned width = video_info->width; + unsigned height = video_info->height; + bool libretro_running = menu_display_libretro_running(); + float white_bg[16] = { 0.98, 0.98, 0.98, 1, 0.98, 0.98, 0.98, 1, 0.98, 0.98, 0.98, 1, 0.98, 0.98, 0.98, 1, }; - float coord_black[16], coord_white[16]; - for (int i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { coord_black[i] = 0; coord_white[i] = 1.0f; @@ -322,18 +334,10 @@ static void nk_menu_frame(void *data) menu_display_set_alpha(coord_black, 0.75); menu_display_set_alpha(coord_white, 0.75); - unsigned width, height, ticker_limit, i; - nk_menu_handle_t *nk = (nk_menu_handle_t*)data; - settings_t *settings = config_get_ptr(); - - bool libretro_running = menu_display_libretro_running(); - if (!nk) return; - video_driver_get_size(&width, &height); - - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); nk_input_begin(&nk->ctx); nk_menu_input_gamepad(nk); @@ -350,7 +354,7 @@ static void nk_menu_frame(void *data) nk_input_end(&nk->ctx); nk_menu_main(nk); - nk_draw_bg(nk, width, height, 0.5, nk->textures.bg, coord_black, coord_white); + nk_draw_bg(nk, video_info, width, height, 0.5, nk->textures.bg, coord_black, coord_white); nk_common_device_draw(&device, &nk->ctx, width, height, NK_ANTI_ALIASING_ON); menu_display_draw_cursor( @@ -363,7 +367,7 @@ static void nk_menu_frame(void *data) height); menu_display_restore_clear_color(); - menu_display_unset_viewport(); + menu_display_unset_viewport(video_info->width, video_info->height); } static void nk_menu_free(void *data) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 2b683af47c..ba677413b6 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -62,6 +62,7 @@ typedef struct unsigned last_height; float scroll_y; bool mouse_show; + unsigned int frame_count; } rgui_t; static uint16_t *rgui_framebuf_data = NULL; @@ -381,6 +382,12 @@ static void rgui_blit_cursor(void) rgui_color_rect(fb_pitch, fb_width, fb_height, x - 5, y, 11, 1, 0xFFFF); } +static void rgui_frame(void *data, video_frame_info_t *video_info) +{ + rgui_t *rgui = (rgui_t*)data; + rgui->frame_count = video_info->frame_count; +} + static void rgui_render(void *data) { menu_animation_ctx_ticker_t ticker; @@ -394,11 +401,9 @@ static void rgui_render(void *data) char title_msg[64]; char msg[255]; bool msg_force = false; - uint64_t frame_count = 0; settings_t *settings = config_get_ptr(); rgui_t *rgui = (rgui_t*)data; - - frame_count = video_driver_get_frame_count(); + uint64_t frame_count = rgui->frame_count; msg[0] = title[0] = title_buf[0] = title_msg[0] = '\0'; @@ -874,7 +879,7 @@ menu_ctx_driver_t menu_ctx_rgui = { rgui_set_message, generic_menu_iterate, rgui_render, - NULL, + rgui_frame, rgui_init, rgui_free, NULL, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8fe641b054..0a46fced2e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -706,11 +706,15 @@ static void xmb_messagebox(void *data, const char *message) strlcpy(xmb->box_message, message, sizeof(xmb->box_message)); } -static void xmb_render_keyboard(xmb_handle_t *xmb, const char *grid[], unsigned id) +static void xmb_render_keyboard(xmb_handle_t *xmb, + video_frame_info_t *video_info, + const char *grid[], unsigned id) { + unsigned i; int ptr_width, ptr_height; - unsigned i, width, height; - float dark[16]= { + unsigned width = video_info->height; + unsigned height = video_info->height; + float dark[16] = { 0.00, 0.00, 0.00, 0.85, 0.00, 0.00, 0.00, 0.85, 0.00, 0.00, 0.00, 0.85, @@ -724,8 +728,6 @@ static void xmb_render_keyboard(xmb_handle_t *xmb, const char *grid[], unsigned 1.00, 1.00, 1.00, 1.00, }; - video_driver_get_size(&width, &height); - menu_display_draw_quad(0, height/2.0, width, height/2.0, width, height, &dark[0]); @@ -765,18 +767,16 @@ static void xmb_render_keyboard(xmb_handle_t *xmb, const char *grid[], unsigned } /* Returns the OSK key at a given position */ -static int xmb_osk_ptr_at_pos(void *data, int x, int y) +static int xmb_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) { + unsigned i; int ptr_width, ptr_height; - unsigned i, width, height; - xmb_handle_t *xmb = (xmb_handle_t*)data; + if (!xmb) return -1; - video_driver_get_size(&width, &height); - - ptr_width = width / 11; + ptr_width = width / 11; ptr_height = height / 10; if (ptr_width >= ptr_height) @@ -798,19 +798,14 @@ static int xmb_osk_ptr_at_pos(void *data, int x, int y) static void xmb_render_messagebox_internal( menu_display_frame_info_t menu_disp_info, + video_frame_info_t *video_info, xmb_handle_t *xmb, const char *message) { - int x, y, longest = 0, longest_width = 0; unsigned i, y_position; - unsigned width, height; - struct string_list *list = NULL; - - if (!xmb) - return; - - video_driver_get_size(&width, &height); - - list = string_split(message, "\n"); + int x, y, longest = 0, longest_width = 0; + unsigned width = video_info->width; + unsigned height = video_info->height; + struct string_list *list = string_split(message, "\n"); if (!list) return; @@ -856,6 +851,7 @@ static void xmb_render_messagebox_internal( if (menu_input_dialog_get_display_kb()) xmb_render_keyboard(xmb, + video_info, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); @@ -2064,6 +2060,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, } static void xmb_draw_items( + video_frame_info_t *video_info, menu_display_frame_info_t menu_disp_info, xmb_handle_t *xmb, file_list_t *list, file_list_t *stack, @@ -2073,10 +2070,9 @@ static void xmb_draw_items( size_t i; math_matrix_4x4 mymat; menu_display_ctx_rotate_draw_t rotate_draw; - uint64_t frame_count = 0; xmb_node_t *core_node = NULL; size_t end = 0; - frame_count = video_driver_get_frame_count(); + uint64_t frame_count = video_info->frame_count; if (!list || !list->size) return; @@ -2413,6 +2409,7 @@ static bool xmb_shader_pipeline_active(settings_t *settings) static void xmb_draw_bg( xmb_handle_t *xmb, + video_frame_info_t *video_info, unsigned width, unsigned height, float alpha, @@ -2427,7 +2424,7 @@ static void xmb_draw_bg( RARCH_LOG("DRAW BG %d %d \n",width,height); #endif - bool running = menu_display_libretro_running(); + bool running = menu_display_libretro_running(); draw.x = 0; draw.y = 0; @@ -2443,7 +2440,7 @@ static void xmb_draw_bg( draw.pipeline.active = xmb_shader_pipeline_active(settings); menu_display_blend_begin(); - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); #ifdef HAVE_SHADERPIPELINE if (settings->menu.xmb.shader_pipeline > XMB_SHADER_PIPELINE_WALLPAPER @@ -2553,18 +2550,20 @@ static void xmb_draw_dark_layer( menu_display_blend_end(); } -static void xmb_frame(void *data) +static void xmb_frame(void *data, video_frame_info_t *video_info) { size_t selection; size_t percent_width = 0; math_matrix_4x4 mymat; - unsigned i, width, height; + unsigned i; float item_color[16], coord_black[16], coord_white[16]; menu_display_ctx_rotate_draw_t rotate_draw; char msg[1024]; char title_msg[255]; char title_truncated[255]; menu_display_frame_info_t menu_disp_info; + unsigned width = video_info->width; + unsigned height = video_info->height; bool render_background = false; file_list_t *selection_buf = NULL; file_list_t *menu_stack = NULL; @@ -2580,8 +2579,6 @@ static void xmb_frame(void *data) title_msg[0] = '\0'; title_truncated[0] = '\0'; - video_driver_get_size(&width, &height); - menu_display_font_bind_block(xmb->font, &xmb->raster_block); menu_display_font_bind_block(xmb->font2, &xmb->raster_block2); @@ -2601,6 +2598,7 @@ static void xmb_frame(void *data) xmb_draw_bg( xmb, + video_info, width, height, xmb->alpha, @@ -2813,7 +2811,9 @@ static void xmb_frame(void *data) menu_display_blend_end(); /* Vertical icons */ - xmb_draw_items(menu_disp_info, + xmb_draw_items( + video_info, + menu_disp_info, xmb, xmb->selection_buf_old, xmb->menu_stack_old, @@ -2828,6 +2828,7 @@ static void xmb_frame(void *data) menu_stack = menu_entries_get_menu_stack_ptr(0); xmb_draw_items( + video_info, menu_disp_info, xmb, selection_buf, @@ -2882,7 +2883,7 @@ static void xmb_frame(void *data) { xmb_draw_dark_layer(xmb, width, height); - xmb_render_messagebox_internal(menu_disp_info, xmb, msg); + xmb_render_messagebox_internal(menu_disp_info, video_info, xmb, msg); } /* Cursor image */ @@ -2899,7 +2900,7 @@ static void xmb_frame(void *data) height); } - menu_display_unset_viewport(); + menu_display_unset_viewport(video_info->width, video_info->height); } static void xmb_layout_ps3(xmb_handle_t *xmb, int width) diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index c688ab193a..909efd21e8 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -399,7 +399,7 @@ end: string_list_free(list); } -static void xui_frame(void *data) +static void xui_frame(void *data, video_frame_info_t *video_info) { XUIMessage msg; XUIMessageRender msgRender; @@ -417,7 +417,7 @@ static void xui_frame(void *data) if (!d3dr) return; - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); app.RunFrame(); XuiTimersRun(); @@ -445,7 +445,7 @@ static void xui_frame(void *data) XuiRenderEnd( app.GetDC() ); - menu_display_unset_viewport(); + menu_display_unset_viewport(video_info->width, video_info->height); } static void blit_line(int x, int y, const char *message, bool green) diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 34a6d38e81..1b967fd0d2 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -311,19 +311,19 @@ static bool zarch_zui_button(zui_t *zui, int x1, int y1, const char *label) + zarch_zui_strwidth(zui->font, label, 1.0) + 24, y1 + 64, label); } -static bool zarch_zui_list_item(zui_t *zui, struct zui_tabbed *tab, int x1, int y1, +static bool zarch_zui_list_item(video_frame_info_t *video_info, + zui_t *zui, struct zui_tabbed *tab, int x1, int y1, const char *label, unsigned item_id, const char *entry, bool selected) { menu_animation_ctx_ticker_t ticker; unsigned ticker_size; char title_buf[PATH_MAX_LENGTH]; - uint64_t frame_count = NULL; unsigned id = zarch_zui_hash(zui, label); int x2 = x1 + zui->width - 290 - 40; int y2 = y1 + 50; bool active = zarch_zui_check_button_up(zui, id, x1, y1, x2, y2); const float *bg = zui_bg_panel; - frame_count = video_driver_get_frame_count(); + uint64_t frame_count = video_info->frame_count; title_buf[0] = '\0'; @@ -500,7 +500,9 @@ static bool zarch_zui_gamepad_input(zui_t *zui, return false; } -static int zarch_zui_render_lay_root_recent(zui_t *zui, struct zui_tabbed *tabbed) +static int zarch_zui_render_lay_root_recent( + video_frame_info_t *video_info, + zui_t *zui, struct zui_tabbed *tabbed) { if (zarch_zui_tab(zui, tabbed, "Recent", 0)) { @@ -524,7 +526,9 @@ static int zarch_zui_render_lay_root_recent(zui_t *zui, struct zui_tabbed *tabbe menu_entry_get_rich_label(i, rich_label, sizeof(rich_label)); menu_entry_get_value(i, NULL, entry_value,sizeof(entry_value)); - if (zarch_zui_list_item(zui, tabbed, 0, + if (zarch_zui_list_item( + video_info, + zui, tabbed, 0, tabbed->tabline_size + j * ZUI_ITEM_SIZE_PX, rich_label, i, entry_value, gamepad_index == (signed)i)) { @@ -563,7 +567,9 @@ static void zarch_zui_render_lay_root_load_set_new_path(zui_t *zui, zui->load_dlist = NULL; } -static int zarch_zui_render_lay_root_load(zui_t *zui, +static int zarch_zui_render_lay_root_load( + video_frame_info_t *video_info, + zui_t *zui, struct zui_tabbed *tabbed) { char parent_dir[PATH_MAX_LENGTH]; @@ -605,7 +611,9 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, fill_pathname_parent_dir(parent_dir, zui->load_cwd, sizeof(parent_dir)); if (!string_is_empty(parent_dir) && - zarch_zui_list_item(zui, tabbed, 0, + zarch_zui_list_item( + video_info, + zui, tabbed, 0, tabbed->tabline_size + 73, " ..", 0, NULL, false /* TODO/FIXME */)) { zarch_zui_render_lay_root_load_set_new_path(zui, parent_dir); @@ -651,7 +659,9 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, if (path_is_directory(path)) strncat(label, "/", sizeof(label)-1); - if (zarch_zui_list_item(zui, tabbed, 0, + if (zarch_zui_list_item( + video_info, + zui, tabbed, 0, tabbed->tabline_size + 73 + j * ZUI_ITEM_SIZE_PX, label, i, NULL, gamepad_index == (signed)(i-skip))) { @@ -709,7 +719,8 @@ static int zarch_zui_render_lay_root_downloads( return 0; } -static int zarch_zui_render_lay_root(zui_t *zui) +static int zarch_zui_render_lay_root(video_frame_info_t *video_info, + zui_t *zui) { char item[PATH_MAX_LENGTH]; static struct zui_tabbed tabbed = {~0U}; @@ -719,9 +730,9 @@ static int zarch_zui_render_lay_root(zui_t *zui) tabbed.width = zui->width - 290 - 40; zui->next_selection_set = false; - if (zarch_zui_render_lay_root_recent(zui, &tabbed)) + if (zarch_zui_render_lay_root_recent(video_info, zui, &tabbed)) return 0; - if (zarch_zui_render_lay_root_load (zui, &tabbed)) + if (zarch_zui_render_lay_root_load(video_info, zui, &tabbed)) return 0; if (zarch_zui_render_lay_root_collections(zui, &tabbed)) return 0; @@ -792,7 +803,8 @@ static void zarch_zui_draw_cursor(float x, float y) { } -static int zarch_zui_render_pick_core(zui_t *zui) +static int zarch_zui_render_pick_core(video_frame_info_t *video_info, + zui_t *zui) { static struct zui_tabbed tabbed = {~0U}; unsigned i, j = 0; @@ -814,7 +826,9 @@ static int zarch_zui_render_pick_core(zui_t *zui) if (!zui->pick_supported) { - zarch_zui_list_item(zui, &tabbed, 0, ZUI_ITEM_SIZE_PX, + zarch_zui_list_item( + video_info, + zui, &tabbed, 0, ZUI_ITEM_SIZE_PX, "Content unsupported", 0, NULL, false /* TODO/FIXME */); return 1; } @@ -828,7 +842,9 @@ static int zarch_zui_render_pick_core(zui_t *zui) if (j > 10) break; - if (zarch_zui_list_item(zui, &tabbed, 0, ZUI_ITEM_SIZE_PX + j * ZUI_ITEM_SIZE_PX, + if (zarch_zui_list_item( + video_info, + zui, &tabbed, 0, ZUI_ITEM_SIZE_PX + j * ZUI_ITEM_SIZE_PX, zui->pick_cores[i].display_name, i, NULL, false)) { int ret = zarch_zui_load_content(zui, i); @@ -846,7 +862,7 @@ static int zarch_zui_render_pick_core(zui_t *zui) return 0; } -static void zarch_frame(void *data) +static void zarch_frame(void *data, video_frame_info_t *video_info) { unsigned i; float coord_color[16]; @@ -862,7 +878,7 @@ static void zarch_frame(void *data) video_driver_get_size(&zui->width, &zui->height); - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); for (i = 0; i < 16; i++) { @@ -899,7 +915,7 @@ static void zarch_frame(void *data) case LAY_HOME: if (zarch_zui_render_sidebar(zui)) return; - if (zarch_zui_render_lay_root(zui)) + if (zarch_zui_render_lay_root(video_info, zui)) return; break; case LAY_SETTINGS: @@ -908,7 +924,7 @@ static void zarch_frame(void *data) case LAY_PICK_CORE: if (zarch_zui_render_sidebar(zui)) return; - if (zarch_zui_render_pick_core(zui)) + if (zarch_zui_render_pick_core(video_info, zui)) return; break; } @@ -967,7 +983,7 @@ static void zarch_frame(void *data) zui->rendering = false; menu_display_font_flush_block((font_data_t*)zui->font); - menu_display_unset_viewport(); + menu_display_unset_viewport(video_info->width, video_info->height); } static void *zarch_init(void **userdata) diff --git a/menu/menu_display.c b/menu/menu_display.c index 6ed84a065b..ca003a4f46 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -397,17 +397,13 @@ bool menu_display_get_update_pending(void) return false; } -void menu_display_set_viewport(void) +void menu_display_set_viewport(unsigned width, unsigned height) { - unsigned width, height; - video_driver_get_size(&width, &height); video_driver_set_viewport(width, height, true, false); } -void menu_display_unset_viewport(void) +void menu_display_unset_viewport(unsigned width, unsigned height) { - unsigned width, height; - video_driver_get_size(&width, &height); video_driver_set_viewport(width, height, false, true); } diff --git a/menu/menu_display.h b/menu/menu_display.h index 6e7faa5c42..5310dc4097 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -227,8 +227,8 @@ void menu_display_set_msg_force(bool state); bool menu_display_get_font_data_init(void); void menu_display_set_font_data_init(bool state); bool menu_display_get_update_pending(void); -void menu_display_set_viewport(void); -void menu_display_unset_viewport(void); +void menu_display_set_viewport(unsigned width, unsigned height); +void menu_display_unset_viewport(unsigned width, unsigned height); bool menu_display_get_framebuffer_dirty_flag(void); void menu_display_set_framebuffer_dirty_flag(void); void menu_display_unset_framebuffer_dirty_flag(void); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6bd0a55681..e0e787a697 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -302,6 +302,15 @@ const char *menu_driver_ident(void) return menu_driver_ctx->ident; } +void menu_driver_frame(video_frame_info_t *video_info) +{ + if (!menu_driver_alive) + return; + + if (menu_driver_ctx->frame) + menu_driver_ctx->frame(menu_userdata, video_info); +} + /** * menu_update_libretro_info: * @@ -484,12 +493,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_data->state = 0; break; - case RARCH_MENU_CTL_FRAME: - if (!menu_driver_alive) - return false; - if (menu_driver_ctx->frame) - menu_driver_ctx->frame(menu_userdata); - break; case RARCH_MENU_CTL_SET_PREVENT_POPULATE: menu_driver_prevent_populate = true; break; @@ -883,14 +886,17 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) break; case RARCH_MENU_CTL_OSK_PTR_AT_POS: { + unsigned width = 0; + unsigned height = 0; menu_ctx_pointer_t *point = (menu_ctx_pointer_t*)data; if (!menu_driver_ctx || !menu_driver_ctx->osk_ptr_at_pos) { point->retcode = 0; return false; } + video_driver_get_size(&width, &height); point->retcode = menu_driver_ctx->osk_ptr_at_pos(menu_userdata, - point->x, point->y); + point->x, point->y, width, height); } break; case RARCH_MENU_CTL_BIND_INIT: diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e097fd6a06..8c49e734e5 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -99,7 +99,6 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_BLIT_RENDER, RARCH_MENU_CTL_RENDER, RARCH_MENU_CTL_RENDER_MESSAGEBOX, - RARCH_MENU_CTL_FRAME, RARCH_MENU_CTL_SET_PREVENT_POPULATE, RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, RARCH_MENU_CTL_IS_PREVENT_POPULATE, @@ -238,7 +237,7 @@ typedef struct menu_ctx_driver void (*render_messagebox)(void *data, const char *msg); int (*iterate)(void *data, void *userdata, enum menu_action action); void (*render)(void *data); - void (*frame)(void *data); + void (*frame)(void *data, video_frame_info_t *video_info); void* (*init)(void**); void (*free)(void*); void (*context_reset)(void *data); @@ -277,7 +276,7 @@ typedef struct menu_ctx_driver menu_entry_t *entry, unsigned action); void (*update_thumbnail_path)(void *data, unsigned i); void (*update_thumbnail_image)(void *data); - int (*osk_ptr_at_pos)(void *data, int x, int y); + int (*osk_ptr_at_pos)(void *data, int x, int y, unsigned width, unsigned height); void (*update_savestate_thumbnail_path)(void *data, unsigned i); void (*update_savestate_thumbnail_image)(void *data); } menu_ctx_driver_t; @@ -390,6 +389,8 @@ bool menu_driver_is_binding_state(void); void menu_driver_set_binding_state(bool on); +void menu_driver_frame(video_frame_info_t *video_info); + extern menu_ctx_driver_t menu_ctx_xui; extern menu_ctx_driver_t menu_ctx_rgui; extern menu_ctx_driver_t menu_ctx_mui;