diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index e4f243e2d4..dcfc4c5591 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -269,7 +269,7 @@ static void gfx_ctx_update_window_title(bool reset) char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) RARCH_LOG("%s.\n", buf); #endif } diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index ff328f957b..a55300bcde 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -244,7 +244,7 @@ static void gfx_ctx_update_window_title(bool reset) gfx_window_title_reset(); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) XStoreName(g_dpy, g_win, buf); } diff --git a/gfx/context/sdl_ctx.c b/gfx/context/sdl_ctx.c index 11d235579f..c52a55354d 100644 --- a/gfx/context/sdl_ctx.c +++ b/gfx/context/sdl_ctx.c @@ -94,7 +94,7 @@ static void gfx_ctx_update_window_title(bool reset) gfx_window_title_reset(); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) gfx_ctx_wm_set_caption(buf); } diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index b8d90efe6a..8aeead8d62 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -115,7 +115,7 @@ static void gfx_ctx_update_window_title(bool reset) char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) RARCH_LOG("%s.\n", buf); } diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 921d650228..47f56229d0 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -181,7 +181,7 @@ static void gfx_ctx_update_window_title(bool reset) gfx_window_title_reset(); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) SetWindowText(g_hwnd, buf); } diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 84249e4825..582ce188c6 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -138,7 +138,7 @@ static void gfx_ctx_update_window_title(bool reset) gfx_window_title_reset(); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) XStoreName(g_dpy, g_win, buf); } diff --git a/gfx/d3d9/d3d9.cpp b/gfx/d3d9/d3d9.cpp index 8918a70d2f..08ab8db68d 100644 --- a/gfx/d3d9/d3d9.cpp +++ b/gfx/d3d9/d3d9.cpp @@ -412,7 +412,7 @@ D3DVideo::D3DVideo(const video_info_t *info) : gfx_window_title_reset(); char buffer[128]; - gfx_window_title(buffer, sizeof(buffer)); + gfx_get_fps(buffer, sizeof(buffer), false); std::string title = buffer; title += " || Direct3D9"; @@ -1112,7 +1112,7 @@ void D3DVideo::deinit_font() void D3DVideo::update_title() { char buffer[128]; - if (gfx_window_title(buffer, sizeof(buffer))) + if (gfx_get_fps(buffer, sizeof(buffer), false)) { std::string title = buffer; title += " || Direct3D9"; diff --git a/gfx/ext_gfx.c b/gfx/ext_gfx.c index 4900d22072..2c8b07898c 100644 --- a/gfx/ext_gfx.c +++ b/gfx/ext_gfx.c @@ -282,7 +282,7 @@ static bool setup_video(ext_t *ext, const video_info_t *video, const input_drive char title_buf[128]; gfx_window_title_reset(); - gfx_window_title(title_buf, sizeof(title_buf)); + gfx_get_fps(title_buf, sizeof(title_buf), false); rarch_video_info_t info = {0}; info.width = video->width; diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 7a07783362..2531b754ac 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -79,7 +79,7 @@ static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, i return frames/time; } -static bool gfx_get_fps(char *buf, size_t size, bool always_write) +bool gfx_get_fps(char *buf, size_t size, bool always_write) { static struct timeval tv; static float last_fps; @@ -124,16 +124,6 @@ void gfx_window_title_reset(void) g_extern.frame_count = 0; } -bool gfx_window_title(char *buf, size_t size) -{ - return gfx_get_fps(buf, size, false); -} - -void gfx_fps_title(char *buf, size_t size) -{ - gfx_get_fps(buf, size, true); -} - #if defined(_WIN32) && !defined(_XBOX) #include #include "../dynamic.h" diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index b3532e57a9..56fbcfb09e 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -27,13 +27,11 @@ extern "C" { #include "../config.h" #endif -// Returns true if FPS value was updated. -bool gfx_window_title(char *buf, size_t size); +// If always_write is true, will always update FPS value +// If always_write is false, returns true if FPS value was updated. +bool gfx_get_fps(char *buf, size_t size, bool always_write); void gfx_window_title_reset(void); -// Like gfx_window_title, but always updates FPS value. -void gfx_fps_title(char *buf, size_t size); - #ifdef _WIN32 void gfx_set_dwm(void); #endif diff --git a/gfx/gl.c b/gfx/gl.c index 984c990927..8253099a75 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1172,7 +1172,8 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (fps_enable) { char fps_txt[128]; - gfx_fps_title(fps_txt, sizeof(fps_txt)); + gfx_get_fps(fps_txt, sizeof(fps_txt), true); + if (gl->font_ctx) gl->font_ctx->render_msg_place(gl, g_settings.video.msg_pos_x, 0.56f, 1.04f, WHITE, fps_txt); } diff --git a/gfx/sdl_gfx.c b/gfx/sdl_gfx.c index b5ad949f2d..7192d9e3d8 100644 --- a/gfx/sdl_gfx.c +++ b/gfx/sdl_gfx.c @@ -307,7 +307,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigne SDL_UnlockSurface(vid->screen); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) SDL_WM_SetCaption(buf, NULL); SDL_Flip(vid->screen); diff --git a/gfx/xvideo.c b/gfx/xvideo.c index 0eff5cc207..9a6dc22bd4 100644 --- a/gfx/xvideo.c +++ b/gfx/xvideo.c @@ -407,7 +407,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo XMapWindow(xv->display, xv->window); - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) XStoreName(xv->display, xv->window, buf); x11_set_window_attr(xv->display, xv->window); @@ -687,7 +687,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei XSync(xv->display, False); char buf[128]; - if (gfx_window_title(buf, sizeof(buf))) + if (gfx_get_fps(buf, sizeof(buf), false)) XStoreName(xv->display, xv->window, buf); return true; diff --git a/gx/gx_video.c b/gx/gx_video.c index c6074a4996..fe46d98999 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -853,7 +853,7 @@ static bool gx_frame(void *data, const void *frame, unsigned x = 15; unsigned y = 15; - gfx_fps_title(fps_txt, sizeof(fps_txt)); + gfx_get_fps(fps_txt, sizeof(fps_txt), true); gx_blit_line(x, y, fps_txt); y += FONT_HEIGHT * (gx->double_strike ? 1 : 2); snprintf(mem1_txt, sizeof(mem1_txt), "MEM1: %8d / %8d", SYSMEM1_SIZE - SYS_GetArena1Size(), SYSMEM1_SIZE); diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 0b32cd9196..27c36b1b7a 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -807,7 +807,7 @@ static bool xdk_d3d_frame(void *data, const void *frame, snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); - gfx_fps_title(fps_txt, sizeof(fps_txt)); + gfx_get_fps(fps_txt, sizeof(fps_txt), true); d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height + 30, 0, 0, fps_txt); }