menu widgets: cleanup fix and draw above overlay for gl and vulkan (#8732)

* menu_widgets: cleanup properly all widgets when loading or closing content

* gl: draw menu widgets above overlay

* vulkan: draw menu widgets above overlay

* vulkan: draw OSD above overlay

* menu_widgets: better cleanup
This commit is contained in:
Nathan S 2019-05-11 06:26:40 +02:00 committed by Twinaphex
parent 1a3f16ded1
commit edb37ccf70
3 changed files with 43 additions and 19 deletions

View File

@ -2746,10 +2746,6 @@ static bool gl2_frame(void *data, const void *frame,
#endif #endif
} }
} }
#ifdef HAVE_MENU_WIDGETS
menu_widgets_frame(video_info);
#endif
#endif #endif
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
@ -2757,6 +2753,10 @@ static bool gl2_frame(void *data, const void *frame,
gl2_render_overlay(gl, video_info); gl2_render_overlay(gl, video_info);
#endif #endif
#ifdef HAVE_MENU_WIDGETS
menu_widgets_frame(video_info);
#endif
if (!string_is_empty(msg)) if (!string_is_empty(msg))
{ {
if (video_info->msg_bgcolor_enable) if (video_info->msg_bgcolor_enable)

View File

@ -1928,18 +1928,18 @@ static bool vulkan_frame(void *data, const void *frame,
(const struct font_params*)&video_info->osd_stat_params); (const struct font_params*)&video_info->osd_stat_params);
} }
} }
#ifdef HAVE_MENU_WIDGETS
menu_widgets_frame(video_info);
#endif #endif
#ifdef HAVE_OVERLAY
if (vk->overlay.enable)
vulkan_render_overlay(vk, video_info);
#endif #endif
if (!string_is_empty(msg)) if (!string_is_empty(msg))
font_driver_render_msg(video_info, NULL, msg, NULL); font_driver_render_msg(video_info, NULL, msg, NULL);
#ifdef HAVE_OVERLAY #ifdef HAVE_MENU_WIDGETS
if (vk->overlay.enable) menu_widgets_frame(video_info);
vulkan_render_overlay(vk, video_info);
#endif #endif
/* End the render pass. We're done rendering to backbuffer now. */ /* End the render pass. We're done rendering to backbuffer now. */

View File

@ -463,7 +463,10 @@ static bool menu_widgets_msg_queue_push_internal(retro_task_t *task, const char
unsigned new_width = font_driver_get_message_width(font_regular, task->title, len, msg_queue_text_scale_factor); unsigned new_width = font_driver_get_message_width(font_regular, task->title, len, msg_queue_text_scale_factor);
if (msg_widget->msg_new) if (msg_widget->msg_new)
{
free(msg_widget->msg_new); free(msg_widget->msg_new);
msg_widget->msg_new = NULL;
}
msg_widget->msg_new = strdup(task->title); msg_widget->msg_new = strdup(task->title);
msg_widget->msg_len = len; msg_widget->msg_len = len;
@ -606,9 +609,17 @@ static void menu_widgets_msg_queue_free(menu_widget_msg_t *msg, bool touch_list)
size_t i; size_t i;
menu_animation_ctx_tag tag = (uintptr_t) msg; menu_animation_ctx_tag tag = (uintptr_t) msg;
/* Update tasks count */
if (msg->task_ptr) if (msg->task_ptr)
{
/* remove the reference the task has of ourself
only if the task is not finished already
(finished tasks are freed before the widget) */
if (!msg->task_finished && !msg->task_error && !msg->task_cancelled)
msg->task_ptr->frontend_userdata = NULL;
/* update tasks count */
msg_queue_tasks_count--; msg_queue_tasks_count--;
}
/* Kill all animations */ /* Kill all animations */
menu_timer_kill(&msg->hourglass_timer); menu_timer_kill(&msg->hourglass_timer);
@ -1553,7 +1564,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_widgets_draw_icon(video_info, menu_widgets_draw_icon(video_info,
icon_size, icon_size, icon_size, icon_size,
volume_icon, volume_icon,
0, 0, 0, 0,
video_info->width, video_info->height, video_info->width, video_info->height,
0, 1, menu_widgets_pure_white 0, 1, menu_widgets_pure_white
); );
@ -1602,7 +1613,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
(int)(volume_percent * 100.0f)); (int)(volume_percent * 100.0f));
menu_display_draw_text(font_regular, menu_display_draw_text(font_regular,
msg, msg,
volume_width - simple_widget_padding, settings->floats.video_font_size * 2, volume_width - simple_widget_padding, settings->floats.video_font_size * 2,
video_info->width, video_info->height, video_info->width, video_info->height,
text_color_db, text_color_db,
@ -1716,8 +1727,6 @@ void menu_widgets_init(bool video_is_threaded)
if (menu_widgets_inited) if (menu_widgets_inited)
return; return;
menu_widgets_inited = true;
if (!menu_display_init_first_driver(video_is_threaded)) if (!menu_display_init_first_driver(video_is_threaded))
goto err; goto err;
@ -1735,7 +1744,10 @@ void menu_widgets_init(bool video_is_threaded)
if (!current_msgs) if (!current_msgs)
goto err; goto err;
file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX); if (!file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX))
goto err;
menu_widgets_inited = true;
return; return;
err: err:
@ -1948,6 +1960,7 @@ void menu_widgets_free(void)
} }
fifo_free(msg_queue); fifo_free(msg_queue);
msg_queue = NULL;
} }
/* Purge everything from the list */ /* Purge everything from the list */
@ -1961,19 +1974,30 @@ void menu_widgets_free(void)
menu_widgets_msg_queue_free(msg, false); menu_widgets_msg_queue_free(msg, false);
} }
file_list_free(current_msgs); file_list_free(current_msgs);
current_msgs = NULL;
} }
msg_queue_tasks_count = 0;
/* Achievement notification */ /* Achievement notification */
menu_widgets_achievement_free(NULL); menu_widgets_achievement_free(NULL);
/* Screenshot texture */
video_driver_texture_unload(&screenshot_texture);
/* Font */ /* Font */
video_coord_array_free(&font_raster_regular.carr); video_coord_array_free(&font_raster_regular.carr);
video_coord_array_free(&font_raster_bold.carr); video_coord_array_free(&font_raster_bold.carr);
font_driver_bind_block(NULL, NULL); font_driver_bind_block(NULL, NULL);
/* Reset state of all other widgets */
/* Generic message*/
generic_message[0] = '\0';
/* Volume */
volume_alpha = 0.0f;
/* Screenshot */
screenshot_alpha = 0.0f;
menu_widgets_screenshot_dispose(NULL);
} }
static void menu_widgets_volume_timer_end(void *userdata) static void menu_widgets_volume_timer_end(void *userdata)