From: Joonbum Ko Date: Mon, 9 Nov 2020 07:07:56 +0000 (+0900) Subject: Trace the presentation feedback and destroy it properly. X-Git-Tag: submit/tizen/20201109.081659~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f8a69b4a912f0d7bf292bfa0b16f3bcf92e5c4e;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Trace the presentation feedback and destroy it properly. Change-Id: I6d7656a20c47f9cd8047cec97610d28ec71b2902 Signed-off-by: Joonbum Ko --- diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 416ab35..cb62f4f 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -63,6 +63,11 @@ struct _twe_tdm_source { int tdm_fd; }; +struct feedback_info { + struct wp_presentation_feedback *feedback; + twe_wl_surf_source *surf_source; +}; + struct _twe_wl_disp_source { GSource gsource; GPollFD gfd; @@ -71,6 +76,7 @@ struct _twe_wl_disp_source { struct wayland_tbm_client *wl_tbm_client; struct tizen_surface_shm *tss; /* used for surface buffer_flush */ struct wp_presentation *presentation; + tpl_list_t *presentation_feedbacks; struct zwp_linux_explicit_synchronization_v1 *explicit_sync; tpl_bool_t use_explicit_sync; struct { @@ -1093,6 +1099,8 @@ _twe_thread_wl_disp_source_destroy(void *source) _twe_display_print_err(disp_source, "dispatch_queue_pending"); } + __tpl_list_free(disp_source->presentation_feedbacks, (tpl_free_func_t)free); + wl_event_queue_destroy(disp_source->ev_queue); g_mutex_unlock(&disp_source->wl_event_mutex); @@ -1165,6 +1173,9 @@ twe_display_add(twe_thread* thread, TPL_DISPLAY_PRESENT_MODE_FIFO; _twe_display_wayland_init(source); + if (source->presentation) + source->presentation_feedbacks = __tpl_list_alloc(); + source->disp_del_source = _twe_del_source_init(ctx, source); source->disp_del_source->destroy_target_source_func = _twe_thread_wl_disp_source_destroy; @@ -2319,7 +2330,9 @@ __cb_presentation_feedback_presented(void *data, TPL_IGNORE(seq_lo); TPL_IGNORE(flags); - twe_wl_surf_source *surf_source = (twe_wl_surf_source *)data; + struct feedback_info *feedback_info = (struct feedback_info *)data; + twe_wl_surf_source *surf_source = feedback_info->surf_source; + twe_wl_disp_source *disp_source = surf_source->disp_source; g_mutex_lock(&surf_source->pst_mutex); @@ -2346,6 +2359,9 @@ __cb_presentation_feedback_presented(void *data, if (presentation_feedback) wp_presentation_feedback_destroy(presentation_feedback); + __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, + TPL_FIRST, (tpl_free_func_t)free); + g_mutex_unlock(&surf_source->pst_mutex); } @@ -2353,7 +2369,9 @@ static void __cb_presentation_feedback_discarded(void *data, struct wp_presentation_feedback *presentation_feedback) { - twe_wl_surf_source *surf_source = (twe_wl_surf_source *)data; + struct feedback_info *feedback_info = (struct feedback_info *)data; + twe_wl_surf_source *surf_source = feedback_info->surf_source; + twe_wl_disp_source *disp_source = surf_source->disp_source; g_mutex_lock(&surf_source->pst_mutex); @@ -2380,6 +2398,9 @@ __cb_presentation_feedback_discarded(void *data, if (presentation_feedback) wp_presentation_feedback_destroy(presentation_feedback); + __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, + TPL_FIRST, (tpl_free_func_t)free); + g_mutex_unlock(&surf_source->pst_mutex); } @@ -2413,9 +2434,16 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, g_mutex_lock(&surf_source->pst_mutex); if (disp_source->presentation && surf_source->presentation_sync_req_cnt > 0) { - p_feedback = wp_presentation_feedback(disp_source->presentation, - wl_surface); - wp_presentation_feedback_add_listener(p_feedback, &feedback_listener, surf_source); + struct feedback_info *feedback_info = + (struct feedback_info *)calloc(1, sizeof(struct feedback_info)); + if (feedback_info) { + feedback_info->feedback = wp_presentation_feedback(disp_source->presentation, + wl_surface); + feedback_info->surf_source = surf_source; + wp_presentation_feedback_add_listener(feedback_info->feedback, + &feedback_listener, feedback_info); + __tpl_list_push_back(disp_source->presentation_feedbacks, (void *)feedback_info); + } } g_mutex_unlock(&surf_source->pst_mutex); @@ -2945,6 +2973,24 @@ _twe_thread_wl_surf_source_destroy(void *source) g_mutex_lock(&surf_source->surf_mutex); + if (disp_source->presentation && disp_source->presentation_feedbacks) { + int num_feedbacks = __tpl_list_get_count(disp_source->presentation_feedbacks); + while (num_feedbacks) { + struct feedback_info *feedback_info = __tpl_list_pop_front(disp_source->presentation_feedbacks, NULL); + if (feedback_info && surf_source == feedback_info->surf_source) { + wp_presentation_feedback_destroy(feedback_info->feedback); + feedback_info->feedback = NULL; + feedback_info->surf_source = NULL; + + free(feedback_info); + } else { + __tpl_list_push_back(disp_source->presentation_feedbacks, feedback_info); + } + + num_feedbacks--; + } + } + if (surf_source->in_use_buffers) { __tpl_list_free(surf_source->in_use_buffers, (tpl_free_func_t)__cb_buffer_remove_from_list);