Fix FPS text in threaded video mode

This commit is contained in:
twinaphex 2019-09-23 09:22:35 +02:00
parent 01dc71f598
commit 3307e65ad3
3 changed files with 17 additions and 2 deletions

View File

@ -80,6 +80,9 @@ static float menu_widgets_pure_white[16] = {
1.00, 1.00, 1.00, 1.00,
};
/* FPS */
static char menu_widgets_fps_text[255] = {0};
/* Achievement notification */
static char *cheevo_title = NULL;
static menu_texture_item cheevo_badge = 0;
@ -1625,7 +1628,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
|| video_info->memory_show
)
{
const char *text = *video_info->fps_text == '\0' ? "N/A" : video_info->fps_text;
const char *text = *menu_widgets_fps_text == '\0' ? "N/A" : menu_widgets_fps_text;
int text_width = font_driver_get_message_width(font_regular, text, (unsigned)strlen(text), 1.0f);
int total_width = text_width + simple_widget_padding * 2;
@ -2003,6 +2006,14 @@ void menu_widgets_volume_update_and_show(void)
menu_timer_start(&volume_timer, &entry);
}
bool menu_widgets_set_fps_text(const char *new_fps_text)
{
strlcpy(menu_widgets_fps_text,
new_fps_text, sizeof(menu_widgets_fps_text));
return true;
}
static void menu_widgets_screenshot_fadeout(void *userdata)
{
menu_animation_ctx_entry_t entry;

View File

@ -77,4 +77,6 @@ void menu_widgets_set_libretro_message(const char *message, unsigned duration);
* enable_menu_widgets to true for that driver */
void menu_widgets_frame(video_frame_info_t *video_info);
bool menu_widgets_set_fps_text(const char *new_fps_text);
#endif

View File

@ -19409,7 +19409,9 @@ static void video_driver_frame(const void *data, unsigned width,
)
{
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
if (!menu_widgets_inited)
if (menu_widgets_inited)
menu_widgets_set_fps_text(video_info.fps_text);
else
#endif
{
runloop_msg_queue_push(video_info.fps_text, 2, 1, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);