From a6a4808e94ed9a427f9558def127dd88934a424f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 17:41:27 +0100 Subject: [PATCH 01/35] Refactor frame monitor code --- gfx/common/x11_common.c | 22 +- gfx/common/x11_common.h | 4 +- gfx/drivers/caca_gfx.c | 2 +- gfx/drivers/ctr_gfx.c | 2 +- gfx/drivers/d3d.cpp | 14 +- gfx/drivers/dispmanx_gfx.c | 17 +- gfx/drivers/drm_gfx.c | 13 +- gfx/drivers/exynos_gfx.c | 15 +- gfx/drivers/gdi_gfx.c | 2 +- gfx/drivers/gl.c | 16 +- gfx/drivers/gl_renderchains/render_chain_gl.h | 6 +- .../gl_renderchains/render_chain_gl_legacy.c | 4 +- gfx/drivers/gx_gfx.c | 7 +- gfx/drivers/nullgfx.c | 2 +- gfx/drivers/omap_gfx.c | 2 +- gfx/drivers/psp1_gfx.c | 14 +- gfx/drivers/sdl2_gfx.c | 9 +- gfx/drivers/sdl_gfx.c | 9 +- gfx/drivers/sunxi_gfx.c | 7 +- gfx/drivers/vg.c | 2 +- gfx/drivers/vita2d_gfx.c | 159 +++++++-------- gfx/drivers/vulkan.c | 6 +- gfx/drivers/wiiu_gfx.c | 2 +- gfx/drivers/xenon360_gfx.c | 2 +- gfx/drivers/xshm_gfx.c | 2 +- gfx/drivers/xvideo.c | 8 +- gfx/drivers_context/android_ctx.c | 17 +- gfx/drivers_context/cgl_ctx.c | 16 +- gfx/drivers_context/cocoa_gl_ctx.m | 24 +-- gfx/drivers_context/d3d_ctx.cpp | 35 ++-- gfx/drivers_context/drm_ctx.c | 22 +- gfx/drivers_context/emscriptenegl_ctx.c | 17 +- gfx/drivers_context/gdi_ctx.cpp | 17 +- gfx/drivers_context/gfx_null_ctx.c | 8 +- gfx/drivers_context/khr_display_ctx.c | 15 +- gfx/drivers_context/mali_fbdev_ctx.c | 17 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 15 +- gfx/drivers_context/osmesa_ctx.c | 20 +- gfx/drivers_context/ps3_ctx.c | 24 +-- gfx/drivers_context/qnx_ctx.c | 17 +- gfx/drivers_context/sdl_gl_ctx.c | 27 +-- gfx/drivers_context/vc_egl_ctx.c | 17 +- gfx/drivers_context/vivante_fbdev_ctx.c | 17 +- gfx/drivers_context/wayland_ctx.c | 20 +- gfx/drivers_context/wgl_ctx.cpp | 19 +- gfx/drivers_context/x_ctx.c | 14 +- gfx/drivers_context/xegl_ctx.c | 14 +- gfx/video_context_driver.c | 2 +- gfx/video_context_driver.h | 6 +- gfx/video_driver.c | 191 ++++++++++-------- gfx/video_driver.h | 25 +-- gfx/video_thread_wrapper.c | 6 +- 52 files changed, 364 insertions(+), 606 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index fb5e5d25b1..a79c6037f7 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -323,7 +323,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 +345,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 +361,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 +375,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) { @@ -715,18 +715,10 @@ 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]; - - buf[0] = buf_fps[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); + if (video_info->monitor_fps_enable) + XStoreName(g_x11_dpy, g_x11_win, video_info->window_text); } bool x11_input_ctx_new(bool true_full) diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index b08db07e0f..c4ffec01d7 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); @@ -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..b55eb5bd40 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -94,7 +94,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; diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 44f36f98f5..67afa4e360 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -446,7 +446,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; diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 46e706e675..abf51ba807 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -1368,7 +1368,7 @@ 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}; @@ -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; diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 873eced47c..1c27cd26f9 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -430,7 +430,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 +438,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,18 +469,11 @@ 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); } /* Update main surface: locate free page, blit and flip. */ diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 9e21463134..62c22f8b55 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -744,11 +744,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,14 +779,6 @@ 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); - } - /* Update main surface: locate free page, blit and flip. */ drm_surface_update(_drmvars, frame, _drmvars->main_surface); return true; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 68f5132eba..00f0fae394 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1159,7 +1159,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 +1272,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 +1303,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) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 05f9e00509..b0aecc2924 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -146,7 +146,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; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 5c42dcce36..09c0bd7dc4 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -299,11 +299,11 @@ 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) @@ -324,7 +324,7 @@ void gl_set_viewport(void *data, video_frame_info_t video_info, 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 +337,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(); @@ -1090,7 +1090,7 @@ 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; @@ -1339,7 +1339,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 +1351,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 +1361,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..8cc1681184 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) @@ -667,7 +667,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..9b9439cf5f 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -1438,7 +1438,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]; @@ -1538,10 +1538,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..1344865ea3 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -985,7 +985,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; diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 47887c0d05..2fbd141fcd 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -467,7 +467,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 +476,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 +493,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); } diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 6d216d8986..438abdeb4c 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); @@ -536,8 +533,8 @@ 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) + SDL_SetWindowTitle(vid->window, video_info->window_text); return true; } diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 45bdf8f1d6..787c8d8c58 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -331,17 +331,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); @@ -370,8 +367,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..c01cb7919b 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -763,7 +763,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; @@ -781,11 +781,6 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, 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..7791b9b5e3 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -378,7 +378,7 @@ 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; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 6d01afac36..bf784591ea 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,39 @@ 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); - } - } - } - + 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); + } + } + } } - - + 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..a9c2e958a2 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -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,7 +1520,7 @@ 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; @@ -1931,7 +1931,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)) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 2055b2d7ff..928993e1e7 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -550,7 +550,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; diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index eeb99f5c1b..97efef1224 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; diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 8bb8ec9478..1a5704aee5 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; diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index d8fce331ba..782771bda1 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -530,8 +530,8 @@ 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) + XStoreName(g_x11_dpy, g_x11_win, video_info.window_text); x11_set_window_attr(g_x11_dpy, g_x11_win); @@ -784,7 +784,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; @@ -811,7 +811,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..8058495574 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -314,21 +314,12 @@ 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) +static void android_gfx_ctx_update_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) { @@ -493,7 +484,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,7 +609,7 @@ 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, + android_gfx_ctx_update_title, android_gfx_ctx_check_window, android_gfx_ctx_set_resize, android_gfx_ctx_has_focus, diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index b5412a189f..6403d6ed35 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -95,7 +95,7 @@ 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; @@ -110,22 +110,12 @@ static bool gfx_ctx_cgl_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_cgl_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_cgl_update_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) { diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 566869809a..4876383858 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,27 +416,17 @@ 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) +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); + if (window && video_info->monitor_fps_enable) + window->set_title(&view, video_info->window_text); #endif - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); } static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types type, @@ -537,7 +527,7 @@ static bool cocoagl_gfx_ctx_has_windowed(void *data) #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; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index f5d4233bb1..9c6acaaafb 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -76,7 +76,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 +84,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 +97,15 @@ 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) + window->set_title(&main_window, video_info->window_text); +#endif + } static void gfx_ctx_d3d_show_mouse(void *data, bool state) @@ -197,7 +188,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) { diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 9452198716..9ca36685cb 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -225,7 +225,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,7 +253,7 @@ 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; @@ -270,18 +270,8 @@ static bool gfx_ctx_drm_set_resize(void *data, return false; } -static void gfx_ctx_drm_update_window_title(void *data, video_frame_info_t video_info) +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, @@ -617,7 +607,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 +624,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 +650,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) { diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 1b750a3689..6e5c5eb854 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -75,7 +75,7 @@ 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 */ @@ -90,17 +90,8 @@ static bool gfx_ctx_emscripten_set_resize(void *data, return false; } -static void gfx_ctx_emscripten_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_emscripten_update_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, @@ -189,7 +180,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,7 +321,7 @@ 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, + gfx_ctx_emscripten_update_title, gfx_ctx_emscripten_check_window, gfx_ctx_emscripten_set_resize, gfx_ctx_emscripten_has_focus, diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index 7f35a5a993..1c3d30cef9 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -87,19 +87,12 @@ 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_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_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); + if (window && video_info->monitor_fps_enable) + window->set_title(&main_window, video_info->window_text); } static void gfx_ctx_gdi_get_video_size(void *data, @@ -190,7 +183,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 +280,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..90b1cb2def 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -35,7 +35,7 @@ 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; } @@ -48,10 +48,8 @@ static bool gfx_ctx_null_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_null_update_window_title(void *data, video_frame_info_t video_info) +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) @@ -62,7 +60,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) { diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 80276bae10..c6fcd07e2e 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -110,21 +110,12 @@ 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) +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) { @@ -201,7 +192,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); diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index de76f06aea..977919627b 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -158,21 +158,12 @@ static bool gfx_ctx_mali_fbdev_set_resize(void *data, return false; } -static void gfx_ctx_mali_fbdev_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_mali_fbdev_update_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) { @@ -269,7 +260,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,7 +310,7 @@ 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, + gfx_ctx_mali_fbdev_update_title, gfx_ctx_mali_fbdev_check_window, gfx_ctx_mali_fbdev_set_resize, gfx_ctx_mali_fbdev_has_focus, diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index bab164cadc..d613c18a86 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -141,21 +141,12 @@ static bool gfx_ctx_opendingux_set_resize(void *data, return false; } -static void gfx_ctx_opendingux_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_opendingux_update_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) { @@ -232,7 +223,7 @@ static bool gfx_ctx_opendingux_has_windowed(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; diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index f6899ece1b..829d6c38bb 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -238,7 +238,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) { @@ -306,20 +306,8 @@ 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 void osmesa_ctx_update_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, @@ -361,7 +349,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); @@ -417,7 +405,7 @@ const gfx_ctx_driver_t gfx_ctx_osmesa = NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, /* translate_aspect */ - osmesa_ctx_update_window_title, + osmesa_ctx_update_title, osmesa_ctx_check_window, osmesa_ctx_set_resize, osmesa_ctx_has_focus, diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index fa34420ec9..4a26e0b4ca 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -179,7 +179,7 @@ static bool gfx_ctx_ps3_has_windowed(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 @@ -199,19 +199,8 @@ static bool gfx_ctx_ps3_set_resize(void *data, return false; } -static void gfx_ctx_ps3_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_ps3_update_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, @@ -302,15 +291,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,7 +422,7 @@ 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, + gfx_ctx_ps3_update_title, gfx_ctx_ps3_check_window, gfx_ctx_ps3_set_resize, gfx_ctx_ps3_has_focus, diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 31ffdbda4b..8308f60fcf 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -319,21 +319,12 @@ static bool gfx_ctx_qnx_set_resize(void *data, return false; } -static void gfx_ctx_qnx_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_qnx_update_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) { @@ -444,7 +435,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,7 +484,7 @@ 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, + gfx_ctx_qnx_update_title, gfx_ctx_qnx_check_window, gfx_ctx_qnx_set_resize, gfx_ctx_qnx_has_focus, diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 50dd0c33a9..e4c34a8194 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -163,7 +163,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 +177,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 +192,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,27 +268,18 @@ 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]; - - buf[0] = buf_fps[0] = '\0'; - - if (video_monitor_get_fps(video_info, buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) + 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); + SDL_SetWindowTitle(sdl->g_win, video_info->window_text); #else - SDL_WM_SetCaption(buf, NULL); + SDL_WM_SetCaption(video_info->window_text, 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, @@ -379,7 +370,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,7 +426,7 @@ 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, sdl_ctx_has_focus, diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 959b0571e3..090c507ec6 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -105,17 +105,8 @@ static bool gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_vc_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_vc_update_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, @@ -319,7 +310,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) { @@ -608,7 +599,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,7 +650,7 @@ 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, + gfx_ctx_vc_update_title, gfx_ctx_vc_check_window, gfx_ctx_vc_set_resize, gfx_ctx_vc_has_focus, diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index ac12fc7afa..ea10357d0e 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -145,21 +145,12 @@ static bool gfx_ctx_vivante_set_resize(void *data, return false; } -static void gfx_ctx_vivante_update_window_title(void *data, video_frame_info_t video_info) +static void gfx_ctx_vivante_update_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) { @@ -246,7 +237,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,7 +288,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_vivante_update_window_title, + gfx_ctx_vivante_update_title, gfx_ctx_vivante_check_window, gfx_ctx_vivante_set_resize, gfx_ctx_vivante_has_focus, diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index a59e99f91c..13a9990e94 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -719,20 +719,12 @@ 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; - buf[0] = buf_fps[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); - - if (video_info.fps_show) - runloop_msg_queue_push(buf_fps, 1, 1, false); + if (wl && video_info->monitor_fps_enable) + wl_shell_surface_set_title(wl->shell_surf, video_info->window_text); } @@ -1075,7 +1067,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 +1549,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 +1668,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..57c38441de 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -331,7 +331,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 +386,12 @@ 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_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); + if (window && video_info->monitor_fps_enable) + window->set_title(&main_window, video_info->window_text); } static void gfx_ctx_wgl_get_video_size(void *data, @@ -525,7 +518,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 +680,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..cb5cac0582 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; @@ -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) @@ -662,7 +662,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, 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); @@ -1081,7 +1081,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..c375a68615 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -257,7 +257,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 +298,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 +309,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 +352,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 +490,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,7 +591,7 @@ 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, x11_has_focus, diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 9bf06e725d..254961f58a 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -456,7 +456,7 @@ 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; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 55a150c177..9b85f6d31a 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,7 +101,7 @@ 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. */ @@ -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. */ diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 9ad62c93be..7146ed805b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1057,89 +1057,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 +2003,93 @@ 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_info->window_text, + video_driver_title_buf, + " || ", + sizeof(video_info->window_text)); + + if (video_info->fps_show) + { + char fps_text[64]; + snprintf(video_info->fps_text, + sizeof(video_info->fps_text), + " FPS: %6.1f || ", last_fps); + strlcat(video_info->window_text, + fps_text, + sizeof(video_info->window_text)); + } + + strlcat(video_info->window_text, + "Frames: ", + sizeof(video_info->window_text)); + + snprintf(frames_text, + sizeof(frames_text), + STRING_REP_UINT64, + (unsigned long long)video_info->frame_count); + + strlcat(video_info->window_text, + frames_text, + sizeof(video_info->window_text)); + ret = true; + } + + if (video_info->fps_text && 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_info->window_text, + video_driver_title_buf, + sizeof(video_info->window_text)); + if (video_info->fps_text) + strlcpy(video_info->fps_text, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), + sizeof(video_info->fps_text)); + + return true; +} + /** * video_driver_frame: * @data : pointer to data of the video frame. @@ -2131,6 +2135,13 @@ void video_driver_frame(const void *data, unsigned width, 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 +2172,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) @@ -2245,6 +2254,10 @@ 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->window_text[0] = '\0'; + video_info->fps_text[0] = '\0'; } /** diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 768b896607..906deea80e 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -101,6 +101,10 @@ typedef struct video_frame_info bool fullscreen; unsigned monitor_index; bool font_enable; + bool monitor_fps_enable; + char window_text[128]; + char fps_text[128]; + uint64_t frame_count; } video_frame_info_t; /* Optionally implemented interface to poke more @@ -163,7 +167,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 { @@ -462,25 +466,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); 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. */ From e620b9b6970c3aa54601dbb5fd0e2124e28a1c7c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 17:42:11 +0100 Subject: [PATCH 02/35] (OSX) Fix OSX --- gfx/drivers_context/cocoa_gl_ctx.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 4876383858..62b9c0a47a 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -621,7 +621,7 @@ 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, + cocoagl_gfx_ctx_update_title, cocoagl_gfx_ctx_check_window, cocoagl_gfx_ctx_set_resize, cocoagl_gfx_ctx_has_focus, From 40cd1b70cda820a982232ef24c22449dff32cf4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 17:43:23 +0100 Subject: [PATCH 03/35] Remove runloop.h header includes --- gfx/drivers_context/cgl_ctx.c | 1 - gfx/drivers_context/d3d_ctx.cpp | 1 - gfx/drivers_context/drm_ctx.c | 1 - gfx/drivers_context/gdi_ctx.cpp | 1 - gfx/drivers_context/opendingux_fbdev_ctx.c | 1 - gfx/drivers_context/ps3_ctx.c | 1 - gfx/drivers_context/sdl_gl_ctx.c | 1 - gfx/drivers_context/vivante_fbdev_ctx.c | 1 - gfx/drivers_context/wgl_ctx.cpp | 1 - 9 files changed, 9 deletions(-) diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 6403d6ed35..f31f3c0ad6 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; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 9c6acaaafb..d163755cf4 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" diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 9ca36685cb..79402dee86 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" diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index 1c3d30cef9..a910159f15 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" diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index d613c18a86..4240c25e7c 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 { diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 4a26e0b4ca..430f0ceabb 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" diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index e4c34a8194..cfb1754679 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; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index ea10357d0e..61f72aa716 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 { diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 57c38441de..901ed3205d 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" From 6247e9900bee109eb6b0b5c014700561a7001032 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 17:46:08 +0100 Subject: [PATCH 04/35] Remove another header include --- gfx/common/x11_common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index a79c6037f7..69a22fb3f2 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 From bf511b72e65ad5a6d873d63d2c95d9cc23e20014 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 21:23:18 +0100 Subject: [PATCH 05/35] Create menu_driver_frame --- gfx/drivers/caca_gfx.c | 2 +- gfx/drivers/ctr_gfx.c | 2 +- gfx/drivers/d3d.cpp | 2 +- gfx/drivers/gdi_gfx.c | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/vita2d_gfx.c | 2 +- gfx/drivers/vulkan.c | 2 +- menu/drivers/materialui.c | 2 +- menu/drivers/nuklear.c | 2 +- menu/drivers/xmb.c | 2 +- menu/drivers/xui.cpp | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_driver.c | 15 +++++++++------ menu/menu_driver.h | 5 +++-- 15 files changed, 25 insertions(+), 21 deletions(-) diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index b55eb5bd40..4ac19e03cc 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -145,7 +145,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 67afa4e360..dd0debe44d 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -750,7 +750,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 abf51ba807..6e796f4548 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -1449,7 +1449,7 @@ static bool d3d_frame(void *data, const void *frame, if (d3d->menu && d3d->menu->enabled) { d3d_overlay_render(d3d, d3d->menu); - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); } #endif diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index b0aecc2924..560146c7df 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -162,7 +162,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 09c0bd7dc4..4ca72da58b 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1279,7 +1279,7 @@ 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); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 438abdeb4c..8dd22ccdcd 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -522,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) diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index bf784591ea..e1747e354d 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -217,7 +217,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, if (vita->menu.active) { - menu_driver_ctl(RARCH_MENU_CTL_FRAME, NULL); + menu_driver_frame(video_info); if(vita->menu.texture){ if (vita->fullscreen) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index a9c2e958a2..0765c9fc9c 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1738,7 +1738,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) { diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 056974cde4..d86d9a7498 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -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, diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 78b37184c5..c7dc425ab6 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -302,7 +302,7 @@ 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]= { 0.98, 0.98, 0.98, 1, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8fe641b054..f017cb0a8d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2553,7 +2553,7 @@ 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; diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index c688ab193a..3c57b9808c 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; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 34a6d38e81..2eeae2d002 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -846,7 +846,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]; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6bd0a55681..73f284c8c1 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; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e097fd6a06..3d1b9c6731 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); @@ -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; From dc196498021d37524ac0849f65b93ee7d08ff149 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 21:40:56 +0100 Subject: [PATCH 06/35] Reduce dependence on video_driver_get_frame_count --- menu/drivers/materialui.c | 10 ++++---- menu/drivers/rgui.c | 4 +--- menu/drivers/xmb.c | 9 +++++--- menu/drivers/zarch.c | 48 ++++++++++++++++++++++++++------------- 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index d86d9a7498..754ec1d813 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -800,7 +800,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 +811,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; @@ -1036,7 +1037,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 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(); @@ -1293,6 +1294,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) menu_display_font_bind_block(mui->font2, &mui->raster_block2); mui_render_menu_list( + video_info, mui, width, height, diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 2b683af47c..416e4c7502 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -394,11 +394,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 = video_driver_get_frame_count(); msg[0] = title[0] = title_buf[0] = title_msg[0] = '\0'; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index f017cb0a8d..6b23aa2548 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2064,6 +2064,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 +2074,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; @@ -2813,7 +2813,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) 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 +2830,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) menu_stack = menu_entries_get_menu_stack_ptr(0); xmb_draw_items( + video_info, menu_disp_info, xmb, selection_buf, diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 2eeae2d002..8409ab780b 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); @@ -899,7 +915,7 @@ static void zarch_frame(void *data, video_frame_info_t *video_info) 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, video_frame_info_t *video_info) 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; } From 34da27c36b2842f2ded8c259bf4c662d3eeb8d52 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 21:47:12 +0100 Subject: [PATCH 07/35] Don't need 'frame_count' variable for check_window --- gfx/common/x11_common.c | 2 +- gfx/common/x11_common.h | 2 +- gfx/drivers_context/android_ctx.c | 4 +--- gfx/drivers_context/cgl_ctx.c | 7 +++---- gfx/drivers_context/d3d_ctx.cpp | 2 +- gfx/drivers_context/drm_ctx.c | 3 +-- gfx/drivers_context/emscriptenegl_ctx.c | 3 +-- gfx/drivers_context/gdi_ctx.cpp | 2 +- gfx/drivers_context/gfx_null_ctx.c | 3 +-- gfx/drivers_context/khr_display_ctx.c | 3 +-- gfx/drivers_context/mali_fbdev_ctx.c | 4 +--- gfx/drivers_context/opendingux_fbdev_ctx.c | 2 +- gfx/drivers_context/osmesa_ctx.c | 7 +++---- gfx/drivers_context/ps3_ctx.c | 2 +- gfx/drivers_context/qnx_ctx.c | 5 +---- gfx/drivers_context/sdl_gl_ctx.c | 5 +---- gfx/drivers_context/vc_egl_ctx.c | 3 +-- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 5 +---- gfx/drivers_context/wgl_ctx.cpp | 2 +- gfx/drivers_context/x_ctx.c | 6 +++--- gfx/video_context_driver.c | 2 +- gfx/video_context_driver.h | 2 +- 23 files changed, 29 insertions(+), 49 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 69a22fb3f2..196f73ae75 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -633,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; diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index c4ffec01d7..78fd28791b 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -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); diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 8058495574..6700c319ae 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) diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index f31f3c0ad6..771aa48f96 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -77,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; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index d163755cf4..9136096e49 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -116,7 +116,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); } diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 79402dee86..4e1a42409b 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -137,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; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 6e5c5eb854..bb6b9dfd10 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; diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index a910159f15..190f0532be 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -64,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); } diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 90b1cb2def..2198ffb46c 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; diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index c6fcd07e2e..f25d66a541 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; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 977919627b..cd6ae9403f 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) diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 4240c25e7c..8ce9f91120 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -112,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; diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 829d6c38bb..27465247b5 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -54,7 +54,6 @@ typedef struct gfx_osmesa_ctx_data int height; int pixsize; - int frame_count; OSMesaContext ctx; int socket; int client; @@ -310,8 +309,9 @@ static void osmesa_ctx_update_title(void *data, video_frame_info_t *video_info) { } -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; @@ -319,7 +319,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) diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 430f0ceabb..ff8cc1e030 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -148,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; diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 8308f60fcf..c2e4c15114 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 diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index cfb1754679..3a38de6a0b 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -41,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; @@ -282,7 +281,7 @@ static void sdl_ctx_update_title(void *data, video_frame_info_t *video_info) } 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; @@ -330,8 +329,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) diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 090c507ec6..581fd8919d 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; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 61f72aa716..6a555db596 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -116,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; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 13a9990e94..ddcbb55ce3 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; diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 901ed3205d..ee7e48a75b 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -311,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); diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index cb5cac0582..01ebe904eb 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -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) { @@ -789,7 +789,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. */ diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 254961f58a..e66066cfe3 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; } diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 9b85f6d31a..f033471ece 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -106,7 +106,7 @@ typedef struct gfx_ctx_driver /* 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. */ From d010a852e42e111565e696a8c40aec87816a681d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:20:47 +0100 Subject: [PATCH 08/35] Call menu_driver_frame once per video_frame call --- gfx/drivers/caca_gfx.c | 11 ++++++++--- gfx/drivers/ctr_gfx.c | 6 ++++-- gfx/drivers/dispmanx_gfx.c | 8 ++++++++ gfx/drivers/drm_gfx.c | 8 ++++++++ gfx/drivers/exynos_gfx.c | 7 +++++++ gfx/drivers/gdi_gfx.c | 9 ++++++++- gfx/drivers/gx_gfx.c | 20 ++++++++++++-------- gfx/drivers/omap_gfx.c | 14 ++++++++++++-- gfx/drivers/psp1_gfx.c | 8 ++++++++ gfx/drivers/sdl_gfx.c | 8 ++++++++ gfx/drivers/sunxi_gfx.c | 8 ++++++++ gfx/drivers/vg.c | 8 ++++++++ gfx/drivers/vita2d_gfx.c | 2 ++ gfx/drivers/wiiu_gfx.c | 19 ++++++++++++++++--- gfx/drivers/xenon360_gfx.c | 4 ++++ gfx/drivers/xshm_gfx.c | 4 ++++ gfx/drivers/xvideo.c | 12 ++++++++++++ 17 files changed, 137 insertions(+), 19 deletions(-) diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index 4ac19e03cc..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; diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index dd0debe44d..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" diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 1c27cd26f9..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" @@ -476,6 +480,10 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); } +#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); return true; diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 62c22f8b55..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" @@ -779,6 +783,10 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, drm_plane_setup(_drmvars->main_surface); } +#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); return true; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 00f0fae394..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" @@ -1315,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 560146c7df..90af988ec4 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) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 9b9439cf5f..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); @@ -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); diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 1344865ea3..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 @@ -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 2fbd141fcd..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" @@ -561,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/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 787c8d8c58..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 @@ -358,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); diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index c01cb7919b..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" @@ -779,6 +783,10 @@ 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) { ioctl(_dispvars->sunxi_disp->fd_fb, FBIO_WAITFORVSYNC, 0); diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 7791b9b5e3..008e754114 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" @@ -417,6 +421,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 e1747e354d..f16d669dcc 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -217,7 +217,9 @@ static bool vita2d_gfx_frame(void *data, const void *frame, if (vita->menu.active) { +#ifdef HAVE_MENU menu_driver_frame(video_info); +#endif if(vita->menu.texture){ if (vita->fullscreen) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 928993e1e7..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" @@ -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 97efef1224..da74eac58b 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -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 1a5704aee5..31bf833df0 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -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 782771bda1..ca862d0f60 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" @@ -802,6 +810,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); From 84f9d8674fbd87b82e85a012797b7361ecbcf3ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:23:19 +0100 Subject: [PATCH 09/35] Implement rgui_frame --- menu/drivers/rgui.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 416e4c7502..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; @@ -396,7 +403,7 @@ static void rgui_render(void *data) bool msg_force = false; settings_t *settings = config_get_ptr(); rgui_t *rgui = (rgui_t*)data; - uint64_t 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'; @@ -872,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, From c089a925b17301332cb5d70d473a3a58b4ff8672 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 18 Jan 2017 16:23:44 -0500 Subject: [PATCH 10/35] fix race condition when toggling menu with threaded_video on --- gfx/video_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7146ed805b..34bed5063a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -971,18 +971,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(); } /** From 1981c4b83ea40aa73d00dc5c8604f217ecba453c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:25:11 +0100 Subject: [PATCH 11/35] Typo fix --- gfx/drivers/xvideo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index ca862d0f60..6ee19f84e8 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -35,7 +35,7 @@ #endif #ifdef HAVE_MENU -#include ".././menu/menu_driver.h" +#include "../../menu/menu_driver.h" #endif #include "../../configuration.h" From f3e700aa767d9fef8940049ecee95623c9a21754 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:30:16 +0100 Subject: [PATCH 12/35] Add width/height members to video_frame_info --- gfx/video_driver.c | 2 ++ gfx/video_driver.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 34bed5063a..cdbd829932 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2140,6 +2140,8 @@ void video_driver_frame(const void *data, unsigned width, video_driver_build_info(&video_info); video_driver_threaded_lock(); + video_info.width = video_driver_width; + video_info.height = video_driver_height; video_info.frame_count = video_driver_frame_count; video_driver_frame_count++; video_driver_threaded_unlock(); diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 906deea80e..5bd08e8d1f 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -105,6 +105,9 @@ typedef struct video_frame_info char window_text[128]; char fps_text[128]; uint64_t frame_count; + + unsigned width; + unsigned height; } video_frame_info_t; /* Optionally implemented interface to poke more From f4adbd04ae4d4908640cb4eb3f851db695d491df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 22:55:03 +0100 Subject: [PATCH 13/35] (gl.c) Reduce amount of time video_driver_get_size is called inside gl_frame --- gfx/drivers/gl.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 4ca72da58b..9fc9948e78 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) @@ -309,14 +309,13 @@ void gl_set_viewport(void *data, video_frame_info_t *video_info, 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; struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; gl_t *gl = (gl_t*)data; - - video_driver_get_size(&width, &height); + unsigned width = video_info->width; + unsigned height = video_info->height; aspect_data.aspect = &device_aspect; aspect_data.width = viewport_width; @@ -1013,13 +1012,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 +1041,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; @@ -1095,11 +1093,13 @@ static bool gl_frame(void *data, const void *frame, 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 +1107,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 @@ -1282,7 +1280,7 @@ static bool gl_frame(void *data, const void *frame, menu_driver_frame(video_info); if (gl->menu_texture_enable) - gl_draw_texture(gl); + gl_draw_texture(gl, video_info); } #endif @@ -1290,7 +1288,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); From c5445d298043f9166ed94d517a9aaa40480b189b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 23:02:24 +0100 Subject: [PATCH 14/35] Reduce amount of times video_driver_get_size is called --- gfx/drivers/vg.c | 13 ++++++------- gfx/drivers/vulkan.c | 19 +++++++++---------- menu/drivers/materialui.c | 7 ++----- menu/drivers/xmb.c | 6 +++--- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 008e754114..700e1997a2 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -285,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) @@ -384,23 +384,22 @@ static bool vg_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, const char *msg, 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 */ diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 0765c9fc9c..dcdd4429fa 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); @@ -1523,7 +1523,7 @@ static bool vulkan_frame(void *data, const void *frame, 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; @@ -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); @@ -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/menu/drivers/materialui.c b/menu/drivers/materialui.c index 754ec1d813..4114911a69 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1029,8 +1029,8 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 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; @@ -1211,8 +1211,6 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 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(); header_height = menu_display_get_header_height(); @@ -1663,7 +1661,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/xmb.c b/menu/drivers/xmb.c index 6b23aa2548..ca6f894ac2 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2558,13 +2558,15 @@ 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 +2582,6 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) 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); From 55b8b8c2445b825b1948fffb58d05d4621a292fd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 23:07:05 +0100 Subject: [PATCH 15/35] Reduce amount of calls to video_driver_get_size --- gfx/drivers/d3d.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 6e796f4548..43f1f429b8 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; @@ -1370,19 +1370,19 @@ static bool d3d_frame(void *data, const void *frame, uint64_t frame_count, unsigned pitch, 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); @@ -1448,7 +1448,7 @@ static bool d3d_frame(void *data, const void *frame, #ifdef HAVE_MENU if (d3d->menu && d3d->menu->enabled) { - d3d_overlay_render(d3d, d3d->menu); + 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 From 1a30cfea0996b53587899253153619c38c341e24 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 23:13:19 +0100 Subject: [PATCH 16/35] Remove more video_driver_get_size calls --- gfx/drivers/gl_renderchains/render_chain_gl_legacy.c | 5 ++--- menu/drivers/materialui.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c b/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c index 8cc1681184..987654cc07 100644 --- a/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c +++ b/gfx/drivers/gl_renderchains/render_chain_gl_legacy.c @@ -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; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 4114911a69..bd8cad9f11 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -562,13 +562,13 @@ 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; From afd4494c2fb400bade89d728e73eec36e40aebe8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 18 Jan 2017 23:59:22 +0100 Subject: [PATCH 17/35] (menu_driver.c) Get rid of video_driver_get_size call --- menu/drivers/materialui.c | 2 +- menu/drivers/nuklear.c | 7 ++++--- menu/drivers/xmb.c | 6 ++++-- menu/drivers/xui.cpp | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_display.c | 4 +--- menu/menu_display.h | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index bd8cad9f11..f6a12e6143 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1211,7 +1211,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) menu_display_set_alpha(header_bg_color_real, settings->menu.header.opacity); menu_display_set_alpha(footer_bg_color_real, settings->menu.footer.opacity); - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); header_height = menu_display_get_header_height(); if (libretro_running) diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index c7dc425ab6..075c430a66 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -250,6 +250,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 +274,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; @@ -333,7 +334,7 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info) 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 +351,7 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info) 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( diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ca6f894ac2..622b90c9f8 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2413,6 +2413,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 +2428,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 +2444,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 @@ -2601,6 +2602,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) xmb_draw_bg( xmb, + video_info, width, height, xmb->alpha, diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index 3c57b9808c..b44aeb1ffa 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -417,7 +417,7 @@ static void xui_frame(void *data, video_frame_info_t *video_info) if (!d3dr) return; - menu_display_set_viewport(); + menu_display_set_viewport(video_info->width, video_info->height); app.RunFrame(); XuiTimersRun(); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 8409ab780b..510a51c154 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -878,7 +878,7 @@ static void zarch_frame(void *data, video_frame_info_t *video_info) 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++) { diff --git a/menu/menu_display.c b/menu/menu_display.c index 6ed84a065b..a13559eab7 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -397,10 +397,8 @@ 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); } diff --git a/menu/menu_display.h b/menu/menu_display.h index 6e7faa5c42..e127c58128 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -227,7 +227,7 @@ 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_set_viewport(unsigned width, unsigned height); void menu_display_unset_viewport(void); bool menu_display_get_framebuffer_dirty_flag(void); void menu_display_set_framebuffer_dirty_flag(void); From 00adc9a2d37665c3addd293d28b506f5b6da5bcd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 00:01:55 +0100 Subject: [PATCH 18/35] Rewrite menu_display_unset_viewport --- menu/drivers/materialui.c | 2 +- menu/drivers/nuklear.c | 2 +- menu/drivers/xmb.c | 2 +- menu/drivers/xui.cpp | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_display.c | 4 +--- menu/menu_display.h | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index f6a12e6143..6a4410db3d 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1426,7 +1426,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 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) diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 075c430a66..e70a14aa1f 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -364,7 +364,7 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info) 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/xmb.c b/menu/drivers/xmb.c index 622b90c9f8..0e2bf7d4f6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2904,7 +2904,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) 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 b44aeb1ffa..909efd21e8 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -445,7 +445,7 @@ static void xui_frame(void *data, video_frame_info_t *video_info) 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 510a51c154..1b967fd0d2 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -983,7 +983,7 @@ static void zarch_frame(void *data, video_frame_info_t *video_info) 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 a13559eab7..ca003a4f46 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -402,10 +402,8 @@ void menu_display_set_viewport(unsigned width, unsigned 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 e127c58128..5310dc4097 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -228,7 +228,7 @@ 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(unsigned width, unsigned height); -void menu_display_unset_viewport(void); +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); From 24e0542bdb75e911551ba0dc87a936a1be585e2f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 00:09:38 +0100 Subject: [PATCH 19/35] (menu) reduce calls to video_driver_get_size --- menu/drivers/materialui.c | 29 +++++++++++++++++------------ menu/drivers/xmb.c | 30 ++++++++++++++---------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 6a4410db3d..53f16bddf6 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]); @@ -457,10 +459,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 +474,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,7 +518,9 @@ 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); @@ -1405,13 +1410,13 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 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'; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0e2bf7d4f6..90b5e261fe 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]); @@ -798,19 +800,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 +853,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()); @@ -2887,7 +2885,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) { 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 */ From 99622cee1428e400974f61bfcf8a0ddac6678c53 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 19 Jan 2017 00:10:42 +0100 Subject: [PATCH 20/35] (Cocoa ) Update --- gfx/drivers_context/cocoa_gl_ctx.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 62b9c0a47a..ba71512fb0 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -554,10 +554,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; From 78e06ca07f885c815e1cc024be10b1572ee99f30 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 19 Jan 2017 00:11:29 +0100 Subject: [PATCH 21/35] Cleanup variables --- gfx/drivers/gl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9fc9948e78..7cab60b1e3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -309,17 +309,16 @@ void gl_set_viewport(void *data, video_frame_info_t *video_info, bool force_full, bool allow_rotate) { gfx_ctx_aspect_t aspect_data; - int x = 0; - int y = 0; - float device_aspect = (float)viewport_width / viewport_height; + 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; - unsigned width = video_info->width; - unsigned height = video_info->height; + gl_t *gl = (gl_t*)data; + unsigned height = video_info->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); From 57f1c0c3b60ced6aeea93c4ab5ee4709f2160b8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:24:21 +0100 Subject: [PATCH 22/35] FIx threaded video --- gfx/video_driver.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index cdbd829932..7be9a5d69e 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2140,8 +2140,6 @@ void video_driver_frame(const void *data, unsigned width, video_driver_build_info(&video_info); video_driver_threaded_lock(); - video_info.width = video_driver_width; - video_info.height = video_driver_height; video_info.frame_count = video_driver_frame_count; video_driver_frame_count++; video_driver_threaded_unlock(); @@ -2244,6 +2242,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 = @@ -2264,6 +2263,10 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->frame_count = 0; video_info->window_text[0] = '\0'; video_info->fps_text[0] = '\0'; + + video_info->width = video_driver_width; + video_info->height = video_driver_height; + video_driver_threaded_unlock(); } /** From 832840f91c5ecedbfd294b71ddd3ce4ccd0597fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:33:47 +0100 Subject: [PATCH 23/35] Cut down on more video_driver_get_size calls --- menu/drivers/materialui.c | 6 ++---- menu/drivers/nuklear.c | 20 +++++++++----------- menu/drivers/xmb.c | 10 ++++------ menu/menu_driver.c | 5 ++++- menu/menu_driver.h | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 53f16bddf6..583997847d 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -329,17 +329,15 @@ static void mui_render_keyboard(mui_handle_t *mui, } /* 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) { int ptr_width, ptr_height; - unsigned i, width, height; + unsigned i; 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; diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index e70a14aa1f..c18fac5ea5 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -305,16 +305,22 @@ static void nk_menu_main(nk_menu_handle_t *nk) 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; @@ -323,17 +329,9 @@ static void nk_menu_frame(void *data, video_frame_info_t *video_info) 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(video_info->width, video_info->height); nk_input_begin(&nk->ctx); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 90b5e261fe..0a46fced2e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -767,18 +767,16 @@ static void xmb_render_keyboard(xmb_handle_t *xmb, } /* 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) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 73f284c8c1..e0e787a697 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -886,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 3d1b9c6731..8c49e734e5 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -276,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; From a9a7f360d0a93b2da4a031309a49ad658df40f4b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:36:40 +0100 Subject: [PATCH 24/35] (nuklear) cleanup --- menu/drivers/nuklear.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index c18fac5ea5..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; From b6c0e57946e3cd1a20e304c8a62490a3f1f3152d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:39:11 +0100 Subject: [PATCH 25/35] Silence some warnings --- gfx/video_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7be9a5d69e..547f13d6fc 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2070,7 +2070,7 @@ static bool video_monitor_get_fps(video_frame_info_t *video_info) ret = true; } - if (video_info->fps_text && video_info->fps_show) + if (video_info->fps_show) snprintf( video_info->fps_text, sizeof(video_info->fps_text), @@ -2086,10 +2086,10 @@ static bool video_monitor_get_fps(video_frame_info_t *video_info) strlcpy(video_info->window_text, video_driver_title_buf, sizeof(video_info->window_text)); - if (video_info->fps_text) - strlcpy(video_info->fps_text, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), - sizeof(video_info->fps_text)); + + strlcpy(video_info->fps_text, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), + sizeof(video_info->fps_text)); return true; } From b96e0bb82037fad97b3f8e230d5fdc87c3d3bf41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 01:58:44 +0100 Subject: [PATCH 26/35] Remove stub update_title functions --- gfx/drivers_context/android_ctx.c | 6 +----- gfx/drivers_context/cgl_ctx.c | 6 +----- gfx/drivers_context/cocoa_gl_ctx.m | 8 ++++++-- gfx/drivers_context/drm_ctx.c | 6 +----- gfx/drivers_context/emscriptenegl_ctx.c | 6 +----- gfx/drivers_context/gfx_null_ctx.c | 6 +----- gfx/drivers_context/khr_display_ctx.c | 6 +----- gfx/drivers_context/mali_fbdev_ctx.c | 6 +----- gfx/drivers_context/opendingux_fbdev_ctx.c | 6 +----- gfx/drivers_context/osmesa_ctx.c | 6 +----- gfx/drivers_context/ps3_ctx.c | 6 +----- gfx/drivers_context/qnx_ctx.c | 6 +----- gfx/drivers_context/vc_egl_ctx.c | 6 +----- gfx/drivers_context/vivante_fbdev_ctx.c | 6 +----- gfx/drivers_context/x_ctx.c | 1 - 15 files changed, 19 insertions(+), 68 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 6700c319ae..353117e977 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -312,10 +312,6 @@ static bool android_gfx_ctx_set_resize(void *data, return false; } -static void android_gfx_ctx_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool android_gfx_ctx_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -607,7 +603,7 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, /* get_video_output_next */ android_gfx_ctx_get_metrics, NULL, - android_gfx_ctx_update_title, + NULL, /* update_title */ android_gfx_ctx_check_window, android_gfx_ctx_set_resize, android_gfx_ctx_has_focus, diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 771aa48f96..87d6ffafab 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -108,10 +108,6 @@ static bool gfx_ctx_cgl_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_cgl_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool gfx_ctx_cgl_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -352,7 +348,7 @@ 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, gfx_ctx_cgl_has_focus, diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index ba71512fb0..0f27d2e0c7 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -416,9 +416,9 @@ static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned *height = CGRectGetHeight(size) * screenscale; } +#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 = ui_companion_driver_get_window_ptr(); @@ -426,8 +426,8 @@ static void cocoagl_gfx_ctx_update_title(void *data, video_frame_info_t *video_i if (window && video_info->monitor_fps_enable) window->set_title(&view, video_info->window_text); -#endif } +#endif static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types type, float *value) @@ -620,7 +620,11 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { NULL, /* get_video_output_next */ cocoagl_gfx_ctx_get_metrics, NULL, +#if defined(HAVE_COCOA) cocoagl_gfx_ctx_update_title, +#else + NULL, /* update_title */ +#endif cocoagl_gfx_ctx_check_window, cocoagl_gfx_ctx_set_resize, cocoagl_gfx_ctx_has_focus, diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 4e1a42409b..ca957eca3f 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -268,10 +268,6 @@ static bool gfx_ctx_drm_set_resize(void *data, return false; } -static void gfx_ctx_drm_update_window_title(void *data, video_frame_info_t *video_info) -{ -} - static void gfx_ctx_drm_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -877,7 +873,7 @@ 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, gfx_ctx_drm_has_focus, diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index bb6b9dfd10..5266cf4493 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -89,10 +89,6 @@ static bool gfx_ctx_emscripten_set_resize(void *data, return false; } -static void gfx_ctx_emscripten_update_title(void *data, video_frame_info_t *video_info) -{ -} - static void gfx_ctx_emscripten_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -320,7 +316,7 @@ 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_title, + NULL, /* update_title */ gfx_ctx_emscripten_check_window, gfx_ctx_emscripten_set_resize, gfx_ctx_emscripten_has_focus, diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 2198ffb46c..ca62a41210 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -47,10 +47,6 @@ static bool gfx_ctx_null_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_null_update_window_title(void *data, video_frame_info_t *video_info) -{ -} - static void gfx_ctx_null_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; @@ -158,7 +154,7 @@ 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, gfx_ctx_null_has_focus, diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index f25d66a541..2fed13ec96 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -109,10 +109,6 @@ 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) -{ -} - static bool gfx_ctx_khr_display_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -233,7 +229,7 @@ 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, diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index cd6ae9403f..bee9f9d30a 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -156,10 +156,6 @@ static bool gfx_ctx_mali_fbdev_set_resize(void *data, return false; } -static void gfx_ctx_mali_fbdev_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -308,7 +304,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_mali_fbdev_update_title, + NULL, /* update_title */ gfx_ctx_mali_fbdev_check_window, gfx_ctx_mali_fbdev_set_resize, gfx_ctx_mali_fbdev_has_focus, diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 8ce9f91120..95874fffc3 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -140,10 +140,6 @@ static bool gfx_ctx_opendingux_set_resize(void *data, return false; } -static void gfx_ctx_opendingux_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool gfx_ctx_opendingux_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -282,7 +278,7 @@ 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, gfx_ctx_opendingux_has_focus, diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 27465247b5..65fd769055 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -305,10 +305,6 @@ static void osmesa_ctx_get_video_size(void *data, *height = osmesa->height; } -static void osmesa_ctx_update_title(void *data, video_frame_info_t *video_info) -{ -} - static void osmesa_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *width, unsigned *height) @@ -404,7 +400,7 @@ const gfx_ctx_driver_t gfx_ctx_osmesa = NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, /* translate_aspect */ - osmesa_ctx_update_title, + NULL, /* update_title */ osmesa_ctx_check_window, osmesa_ctx_set_resize, osmesa_ctx_has_focus, diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index ff8cc1e030..a4d949057d 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -198,10 +198,6 @@ static bool gfx_ctx_ps3_set_resize(void *data, return false; } -static void gfx_ctx_ps3_update_title(void *data, video_frame_info_t *video_info) -{ -} - static void gfx_ctx_ps3_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -421,7 +417,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_ps3_get_video_output_next, NULL, /* get_metrics */ NULL, - gfx_ctx_ps3_update_title, + NULL, /* update_title */ gfx_ctx_ps3_check_window, gfx_ctx_ps3_set_resize, gfx_ctx_ps3_has_focus, diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index c2e4c15114..41c8e37b4a 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -316,10 +316,6 @@ static bool gfx_ctx_qnx_set_resize(void *data, return false; } -static void gfx_ctx_qnx_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool gfx_ctx_qnx_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -481,7 +477,7 @@ const gfx_ctx_driver_t gfx_ctx_qnx = { NULL, /* get_video_output_next */ gfx_ctx_qnx__get_metrics, NULL, - gfx_ctx_qnx_update_title, + NULL, /* update_title */ gfx_ctx_qnx_check_window, gfx_ctx_qnx_set_resize, gfx_ctx_qnx_has_focus, diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 581fd8919d..d348e56c9b 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -104,10 +104,6 @@ static bool gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) return false; } -static void gfx_ctx_vc_update_title(void *data, video_frame_info_t *video_info) -{ -} - static void gfx_ctx_vc_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -649,7 +645,7 @@ 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_title, + NULL, /* update_title */ gfx_ctx_vc_check_window, gfx_ctx_vc_set_resize, gfx_ctx_vc_has_focus, diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 6a555db596..b3d89795a3 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -144,10 +144,6 @@ static bool gfx_ctx_vivante_set_resize(void *data, return false; } -static void gfx_ctx_vivante_update_title(void *data, video_frame_info_t *video_info) -{ -} - static bool gfx_ctx_vivante_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -287,7 +283,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, /* get_video_output_next */ NULL, /* get_metrics */ NULL, - gfx_ctx_vivante_update_title, + NULL, /* update_title */ gfx_ctx_vivante_check_window, gfx_ctx_vivante_set_resize, gfx_ctx_vivante_has_focus, diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 01ebe904eb..08a6e64170 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -660,7 +660,6 @@ static bool gfx_ctx_x_set_video_mode(void *data, break; } - x11_set_window_attr(g_x11_dpy, g_x11_win); x11_update_title(NULL, video_info); From 19cc8176137d6c2d5401ec2888d380fb474c7a86 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 02:25:45 +0100 Subject: [PATCH 27/35] This needs to be set this way --- gfx/video_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 547f13d6fc..ed55a6f79c 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2046,12 +2046,11 @@ static bool video_monitor_get_fps(video_frame_info_t *video_info) if (video_info->fps_show) { - char fps_text[64]; snprintf(video_info->fps_text, sizeof(video_info->fps_text), " FPS: %6.1f || ", last_fps); strlcat(video_info->window_text, - fps_text, + video_info->fps_text, sizeof(video_info->window_text)); } From 3761b5bdf6a2140d66431bc23e0386fb8d97a075 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 02:34:35 +0100 Subject: [PATCH 28/35] Unroll video_driver_cached_frame_set --- gfx/video_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index ed55a6f79c..50e6bc0126 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2134,7 +2134,11 @@ 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); From 7fbd3fcfb67a8ed73d95b6061e6a3e937f0f7189 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 02:50:56 +0100 Subject: [PATCH 29/35] Simplify has_windowed --- gfx/drivers_context/android_ctx.c | 8 +------- gfx/drivers_context/cgl_ctx.c | 8 +------- gfx/drivers_context/cocoa_gl_ctx.m | 12 ++++++------ gfx/drivers_context/d3d_ctx.cpp | 10 ++++++---- gfx/drivers_context/drm_ctx.c | 8 +------- gfx/drivers_context/gfx_null_ctx.c | 8 +------- gfx/drivers_context/khr_display_ctx.c | 8 +------- gfx/drivers_context/mali_fbdev_ctx.c | 8 +------- gfx/drivers_context/opendingux_fbdev_ctx.c | 8 +------- gfx/drivers_context/ps3_ctx.c | 8 +------- gfx/drivers_context/qnx_ctx.c | 8 +------- gfx/drivers_context/vc_egl_ctx.c | 8 +------- gfx/drivers_context/vivante_fbdev_ctx.c | 8 +------- gfx/video_context_driver.h | 2 +- gfx/video_driver.h | 2 +- 15 files changed, 25 insertions(+), 89 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 353117e977..9c7a4e7b3c 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -421,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); @@ -608,7 +602,7 @@ const gfx_ctx_driver_t gfx_ctx_android = { 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 87d6ffafab..a7bc1bc2a8 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -179,12 +179,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) { @@ -353,7 +347,7 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { gfx_ctx_cgl_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 0f27d2e0c7..d2a276b74a 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -516,16 +516,12 @@ 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) { @@ -629,7 +625,11 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { cocoagl_gfx_ctx_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 9136096e49..1d2b9ae948 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -131,16 +131,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) @@ -337,7 +335,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 ca957eca3f..f0bb839ab8 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -749,12 +749,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) { @@ -878,7 +872,7 @@ const gfx_ctx_driver_t gfx_ctx_drm = { gfx_ctx_drm_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/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index ca62a41210..448289f1ef 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -94,12 +94,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; @@ -159,7 +153,7 @@ const gfx_ctx_driver_t gfx_ctx_null = { gfx_ctx_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 2fed13ec96..a8cdc5ae1b 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -170,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; @@ -234,7 +228,7 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = { 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 bee9f9d30a..842f970fa7 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -239,12 +239,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; @@ -309,7 +303,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { gfx_ctx_mali_fbdev_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 95874fffc3..f6672ef937 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -212,12 +212,6 @@ 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) { opendingux_ctx_data_t *viv = (opendingux_ctx_data_t*)data; @@ -283,7 +277,7 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { gfx_ctx_opendingux_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/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index a4d949057d..e427fcb2ea 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -172,12 +172,6 @@ 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) { (void)data; @@ -422,7 +416,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_ps3_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 41c8e37b4a..4126740754 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -359,12 +359,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]; @@ -482,7 +476,7 @@ const gfx_ctx_driver_t gfx_ctx_qnx = { gfx_ctx_qnx_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/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index d348e56c9b..007e26b1c8 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -457,12 +457,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) { @@ -650,7 +644,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_vc_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 b3d89795a3..7c6f4662c9 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -217,12 +217,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; @@ -288,7 +282,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { gfx_ctx_vivante_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/video_context_driver.h b/gfx/video_context_driver.h index f033471ece..20f52a1cc7 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -334,7 +334,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.h b/gfx/video_driver.h index 5bd08e8d1f..4bf0344ff8 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -249,7 +249,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) From b44c8c99959d0942fe1e00e613fee464380c14a8 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 19 Jan 2017 00:33:52 -0500 Subject: [PATCH 30/35] store buffer for window title, only update actual title when it changes --- gfx/common/x11_common.c | 10 ++++++-- gfx/drivers/sdl2_gfx.c | 11 ++++++++- gfx/drivers/xvideo.c | 11 ++++++++- gfx/drivers_context/cocoa_gl_ctx.m | 11 ++++++++- gfx/drivers_context/d3d_ctx.cpp | 11 ++++++++- gfx/drivers_context/gdi_ctx.cpp | 13 +++++++++-- gfx/drivers_context/sdl_gl_ctx.c | 13 ++++++++--- gfx/drivers_context/wayland_ctx.c | 9 ++++++-- gfx/drivers_context/wgl_ctx.cpp | 11 ++++++++- gfx/video_driver.c | 37 +++++++++++++++++++++--------- gfx/video_driver.h | 3 ++- 11 files changed, 114 insertions(+), 26 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 196f73ae75..2ed94fc1d7 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -716,8 +716,14 @@ bool x11_connect(void) void x11_update_title(void *data, video_frame_info_t *video_info) { - if (video_info->monitor_fps_enable) - XStoreName(g_x11_dpy, g_x11_win, video_info->window_text); + char title[128]; + + title[0] = '\0'; + + 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/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 8dd22ccdcd..6cc61b0a8c 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -534,7 +534,16 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, SDL_RenderPresent(vid->renderer); if (video_info->monitor_fps_enable) - SDL_SetWindowTitle(vid->window, video_info->window_text); + { + 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/xvideo.c b/gfx/drivers/xvideo.c index 6ee19f84e8..463e1f28c2 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -539,7 +539,16 @@ static void *xv_init(const video_info_t *video, video_driver_build_info(&video_info); if (video_info.monitor_fps_enable) - XStoreName(g_x11_dpy, g_x11_win, video_info.window_text); + { + 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); diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index d2a276b74a..aa91c64738 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -425,7 +425,16 @@ static void cocoagl_gfx_ctx_update_title(void *data, video_frame_info_t *video_i view.data = (CocoaView*)nsview_get_ptr(); if (window && video_info->monitor_fps_enable) - window->set_title(&view, video_info->window_text); + { + char title[128]; + + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + window->set_title(&view, title); + } } #endif diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 1d2b9ae948..98f65be158 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -102,7 +102,16 @@ static void gfx_ctx_d3d_update_title(void *data, video_frame_info_t *video_info) const ui_window_t *window = ui_companion_driver_get_window_ptr(); if (window && video_info->monitor_fps_enable) - window->set_title(&main_window, video_info->window_text); + { + char title[128]; + + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (title[0]) + window->set_title(&main_window, title); + } #endif } diff --git a/gfx/drivers_context/gdi_ctx.cpp b/gfx/drivers_context/gdi_ctx.cpp index 190f0532be..dea9050840 100644 --- a/gfx/drivers_context/gdi_ctx.cpp +++ b/gfx/drivers_context/gdi_ctx.cpp @@ -86,12 +86,21 @@ static bool gfx_ctx_gdi_set_resize(void *data, return false; } -static void gfx_ctx_gdi_update_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) { const ui_window_t *window = ui_companion_driver_get_window_ptr(); if (window && video_info->monitor_fps_enable) - window->set_title(&main_window, video_info->window_text); + { + char title[128]; + + 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, diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 3a38de6a0b..c4f6ff3e57 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -268,14 +268,21 @@ static void sdl_ctx_get_video_size(void *data, static void sdl_ctx_update_title(void *data, video_frame_info_t *video_info) { + char title[128]; + + title[0] = '\0'; + + 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, video_info->window_text); + + if (sdl && title[0]) + SDL_SetWindowTitle(sdl->g_win, title); #else - SDL_WM_SetCaption(video_info->window_text, NULL); + SDL_WM_SetCaption(title, NULL); #endif } } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index ddcbb55ce3..70100b88a3 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -719,9 +719,14 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_wl_update_title(void *data, video_frame_info_t *video_info) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + char title[128]; - if (wl && video_info->monitor_fps_enable) - wl_shell_surface_set_title(wl->shell_surf, video_info->window_text); + title[0] = '\0'; + + video_driver_get_window_title(title, sizeof(title)); + + if (wl && title[0] && video_info->monitor_fps_enable) + wl_shell_surface_set_title(wl->shell_surf, title); } diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index ee7e48a75b..18b83ba5c0 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -390,7 +390,16 @@ static void gfx_ctx_wgl_update_title(void *data, video_frame_info_t *video_info) const ui_window_t *window = ui_companion_driver_get_window_ptr(); if (window && video_info->monitor_fps_enable) - window->set_title(&main_window, video_info->window_text); + { + char title[128]; + + 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, diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 50e6bc0126..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; @@ -2039,34 +2041,36 @@ static bool video_monitor_get_fps(video_frame_info_t *video_info) last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); curr_time = new_time; - fill_pathname_noext(video_info->window_text, + fill_pathname_noext(video_driver_window_title, video_driver_title_buf, " || ", - sizeof(video_info->window_text)); + 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_info->window_text, + strlcat(video_driver_window_title, video_info->fps_text, - sizeof(video_info->window_text)); + sizeof(video_driver_window_title)); } - strlcat(video_info->window_text, + strlcat(video_driver_window_title, "Frames: ", - sizeof(video_info->window_text)); + sizeof(video_driver_window_title)); snprintf(frames_text, sizeof(frames_text), STRING_REP_UINT64, (unsigned long long)video_info->frame_count); - strlcat(video_info->window_text, + strlcat(video_driver_window_title, frames_text, - sizeof(video_info->window_text)); + sizeof(video_driver_window_title)); ret = true; + + video_driver_window_title_update = true; } if (video_info->fps_show) @@ -2082,14 +2086,16 @@ static bool video_monitor_get_fps(video_frame_info_t *video_info) } curr_time = fps_time = new_time; - strlcpy(video_info->window_text, + strlcpy(video_driver_window_title, video_driver_title_buf, - sizeof(video_info->window_text)); + 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; } @@ -2264,11 +2270,11 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->font_enable = settings->video.font_enable; video_info->frame_count = 0; - video_info->window_text[0] = '\0'; video_info->fps_text[0] = '\0'; video_info->width = video_driver_width; video_info->height = video_driver_height; + video_driver_threaded_unlock(); } @@ -2325,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 4bf0344ff8..479cb77cf7 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -102,7 +102,6 @@ typedef struct video_frame_info unsigned monitor_index; bool font_enable; bool monitor_fps_enable; - char window_text[128]; char fps_text[128]; uint64_t frame_count; @@ -531,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; From 009c1a45b7cd8b9d980789f2545392a18cac6ed8 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 19 Jan 2017 00:36:29 -0500 Subject: [PATCH 31/35] forgot check for SDL1 --- gfx/drivers_context/sdl_gl_ctx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index c4f6ff3e57..ad6dbff509 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -282,7 +282,8 @@ static void sdl_ctx_update_title(void *data, video_frame_info_t *video_info) if (sdl && title[0]) SDL_SetWindowTitle(sdl->g_win, title); #else - SDL_WM_SetCaption(title, NULL); + if (title[0]) + SDL_WM_SetCaption(title, NULL); #endif } } From 6208d037fc4c3752c19895799b9928d8772f60f7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 11:16:53 +0100 Subject: [PATCH 32/35] (MaterialUI) Cleanups --- menu/drivers/materialui.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 583997847d..42150a8ffa 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -333,8 +333,8 @@ static int mui_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned { int ptr_width, ptr_height; unsigned i; - mui_handle_t *mui = (mui_handle_t*)data; + if (!mui) return -1; @@ -364,7 +364,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 +395,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; } @@ -524,21 +525,22 @@ 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++) { @@ -553,7 +555,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(); @@ -578,7 +580,7 @@ static void mui_render(void *data) 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); From b93046f8671c648972531ccf0016bbba140b630c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 11:20:02 +0100 Subject: [PATCH 33/35] Cleanup mui_draw_scrollbar --- menu/drivers/materialui.c | 54 +++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 42150a8ffa..cc0a7897c9 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -329,10 +329,11 @@ static void mui_render_keyboard(mui_handle_t *mui, } /* Returns the OSK key at a given position */ -static int mui_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) +static int mui_osk_ptr_at_pos(void *data, int x, int y, + unsigned width, unsigned height) { - int ptr_width, ptr_height; unsigned i; + int ptr_width, ptr_height; mui_handle_t *mui = (mui_handle_t*)data; if (!mui) @@ -413,38 +414,31 @@ static float mui_content_height(void) 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) From 9d1de5c9746c2ef08422cc72a98ca850a8125243 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 14:31:57 +0100 Subject: [PATCH 34/35] Rewrite video_context_driver_set_resize --- gfx/drivers/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/vulkan.c | 2 +- gfx/drivers_context/cgl_ctx.c | 10 +--------- gfx/drivers_context/cocoa_gl_ctx.m | 10 +--------- gfx/drivers_context/drm_ctx.c | 12 +----------- gfx/drivers_context/emscriptenegl_ctx.c | 11 +---------- gfx/drivers_context/gfx_null_ctx.c | 10 +--------- gfx/drivers_context/mali_fbdev_ctx.c | 11 +---------- gfx/drivers_context/opendingux_fbdev_ctx.c | 11 +---------- gfx/drivers_context/osmesa_ctx.c | 10 +--------- gfx/drivers_context/ps3_ctx.c | 8 +------- gfx/drivers_context/qnx_ctx.c | 11 +---------- gfx/drivers_context/sdl_gl_ctx.c | 10 +--------- gfx/drivers_context/vc_egl_ctx.c | 10 +--------- gfx/drivers_context/vivante_fbdev_ctx.c | 11 +---------- gfx/drivers_context/xegl_ctx.c | 11 +---------- gfx/video_context_driver.c | 10 ---------- gfx/video_context_driver.h | 6 ++++-- 19 files changed, 21 insertions(+), 147 deletions(-) diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 43f1f429b8..1ada4f5dd4 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -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); } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 7cab60b1e3..55a89ff0a8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1143,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) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index dcdd4429fa..5be806a7c9 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1921,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; } diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index a7bc1bc2a8..68229bc89a 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -100,14 +100,6 @@ static void gfx_ctx_cgl_swap_buffers(void *data, video_frame_info_t *video_info) 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 bool gfx_ctx_cgl_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -344,7 +336,7 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index aa91c64738..e3a49f8ab3 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -574,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,7 +623,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { 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) diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index f0bb839ab8..4c68edc575 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -258,16 +258,6 @@ static void gfx_ctx_drm_swap_buffers(void *data, video_frame_info_t *video_info) 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_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -869,7 +859,7 @@ const gfx_ctx_driver_t gfx_ctx_drm = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 5266cf4493..cb8e45e93d 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -80,15 +80,6 @@ static void gfx_ctx_emscripten_swap_buffers(void *data, video_frame_info_t *vide /* 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_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -318,7 +309,7 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { gfx_ctx_emscripten_translate_aspect, 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/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 448289f1ef..18c81a60df 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -39,14 +39,6 @@ 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_get_video_size(void *data, unsigned *width, unsigned *height) { (void)data; @@ -150,7 +142,7 @@ const gfx_ctx_driver_t gfx_ctx_null = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 842f970fa7..cb1561ee9d 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -147,15 +147,6 @@ 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 bool gfx_ctx_mali_fbdev_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -300,7 +291,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index f6672ef937..411221e5b4 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -131,15 +131,6 @@ 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 bool gfx_ctx_opendingux_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -274,7 +265,7 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 65fd769055..da8009229e 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -317,14 +317,6 @@ static void osmesa_ctx_check_window(void *data, bool *quit, *quit = false; } -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) { (void)data; @@ -402,7 +394,7 @@ const gfx_ctx_driver_t gfx_ctx_osmesa = NULL, /* translate_aspect */ 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 e427fcb2ea..7f35f60daa 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -186,12 +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_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -413,7 +407,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 4126740754..252f89808d 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -307,15 +307,6 @@ 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 bool gfx_ctx_qnx_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -473,7 +464,7 @@ const gfx_ctx_driver_t gfx_ctx_qnx = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index ad6dbff509..8b1847e44c 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -339,14 +339,6 @@ static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned * } } -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) { unsigned flags; @@ -432,7 +424,7 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = NULL, /* translate_aspect */ 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 007e26b1c8..c2b98d5ebd 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -96,14 +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_get_video_size(void *data, unsigned *width, unsigned *height) { @@ -641,7 +633,7 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_vc_translate_aspect, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 7c6f4662c9..c59e5dd577 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -135,15 +135,6 @@ 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 bool gfx_ctx_vivante_set_video_mode(void *data, video_frame_info_t *video_info, unsigned width, unsigned height, @@ -279,7 +270,7 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, 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, NULL, /* has_windowed */ diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index c375a68615..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 @@ -593,7 +584,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = NULL, 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/video_context_driver.c b/gfx/video_context_driver.c index e66066cfe3..a8cc52e78d 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -462,16 +462,6 @@ bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info) 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 20f52a1cc7..52baf831d9 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -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); From 4a8cb5687a73dd3f544f7095634e2f9ea3f5f344 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Jan 2017 15:55:42 +0100 Subject: [PATCH 35/35] (ctr_font.c) use #if 0 blocks --- gfx/drivers_font/ctr_font.c | 78 ++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 32 deletions(-) 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; }