From: joonbum.ko Date: Thu, 19 Oct 2017 07:51:31 +0000 (+0900) Subject: tpl_wayland_egl_thread: Added free function to unref tbm_surface in the buffer list. X-Git-Tag: accepted/tizen/unified/20171206.063114~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49486873b7f5d82866ead1700b54bb4bc1eab93b;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git tpl_wayland_egl_thread: Added free function to unref tbm_surface in the buffer list. - The data, tbm_surface, will be freed with function below. void * __cb_buffer_remove_from_list(void *data) Change-Id: If70b0a9fc10545a41fdfff9dd8f07954ba62ee14 Signed-off-by: joonbum.ko --- diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 347c9ba..00b450a 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -159,6 +159,8 @@ void _twe_del_source_fini(twe_del_source *source); static void _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source); +static void +__cb_buffer_remove_from_list(void *data); static gpointer _twe_thread_loop(gpointer data) @@ -1189,11 +1191,8 @@ static void __cb_tss_flusher_flush_callback(void *data, */ if (surf_source->committed_buffers) { TPL_OBJECT_LOCK(&surf_source->obj); - while (!__tpl_list_is_empty(surf_source->committed_buffers)) { - tbm_surface_h tbm_surface = - __tpl_list_pop_front(surf_source->committed_buffers, NULL); - tbm_surface_internal_unref(tbm_surface); - } + __tpl_list_fini(surf_source->committed_buffers, + (tpl_free_func_t)__cb_buffer_remove_from_list); TPL_OBJECT_UNLOCK(&surf_source->obj); } @@ -2065,6 +2064,15 @@ twe_surface_get_tbm_queue(twe_surface_h twe_surface) } static void +__cb_buffer_remove_from_list(void *data) +{ + tbm_surface_h tbm_surface = (tbm_surface_h)data; + + if (tbm_surface && tbm_surface_internal_is_valid(tbm_surface)) + tbm_surface_internal_unref(tbm_surface); +} + +static void _twe_thread_wl_surf_source_destroy(void *source) { twe_wl_surf_source *surf_source = (twe_wl_surf_source *)source; @@ -2088,27 +2096,15 @@ _twe_thread_wl_surf_source_destroy(void *source) TPL_OBJECT_LOCK(&disp_source->obj); - while (!__tpl_list_is_empty(surf_source->in_use_buffers)) { - tbm_surface_h tbm_surface = (tbm_surface_h)__tpl_list_pop_front( - surf_source->in_use_buffers, - NULL); - tbm_surface_internal_unref(tbm_surface); + if (surf_source->in_use_buffers) { + __tpl_list_free(surf_source->in_use_buffers, + (tpl_free_func_t)__cb_buffer_remove_from_list); + surf_source->in_use_buffers = NULL; } - __tpl_list_free(surf_source->in_use_buffers, NULL); - - surf_source->in_use_buffers = NULL; - if (surf_source->committed_buffers) { - while (!__tpl_list_is_empty(surf_source->committed_buffers)) { - tbm_surface_h tbm_surface = - (tbm_surface_h)__tpl_list_pop_front( - surf_source->committed_buffers, - NULL); - tbm_surface_internal_unref(tbm_surface); - } - - __tpl_list_free(surf_source->committed_buffers, NULL); + __tpl_list_free(surf_source->committed_buffers, + (tpl_free_func_t)__cb_buffer_remove_from_list); surf_source->committed_buffers = NULL; }