From f7c850d9bd3d443d72c08b5832acad99d3fae3c8 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Wed, 13 Sep 2017 14:29:25 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Modified twe_surface_destroy to unref the tbm_surface in in_user_buffers. - When eglSurfaceDestroy is called on the main thread, the function twe_surface_del() waits for the worker thread to finish rendering the buffer no longer Change-Id: Ieb3921eedd990b8621122cb1db9d42cb5933c2c1 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 5912b91..4fc7976 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1043,7 +1043,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, if (surf_source->in_use_buffers) { TPL_OBJECT_LOCK(&surf_source->obj); __tpl_list_push_back(surf_source->in_use_buffers, - (void *)buf_info); + (void *)tbm_surface); TPL_OBJECT_UNLOCK(&surf_source->obj); } @@ -1106,7 +1106,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, if (surf_source->in_use_buffers) { TPL_OBJECT_LOCK(&surf_source->obj); __tpl_list_push_back(surf_source->in_use_buffers, - (void *)buf_info); + (void *)tbm_surface); TPL_OBJECT_UNLOCK(&surf_source->obj); } @@ -1144,7 +1144,7 @@ _twe_surface_cancel_dequeued_buffer(twe_wl_surf_source *surf_source, TPL_OBJECT_LOCK(&surf_source->obj); /* Stop tracking of this canceled tbm_surface */ __tpl_list_remove_data(surf_source->in_use_buffers, - (void *)buf_info, TPL_FIRST, NULL); + (void *)tbm_surface, TPL_FIRST, NULL); TPL_OBJECT_UNLOCK(&surf_source->obj); } } @@ -1323,7 +1323,7 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, __tpl_list_push_back(surf_source->committed_buffers, tbm_surface); /* Stop tracking of this released tbm_surface. */ __tpl_list_remove_data(surf_source->in_use_buffers, - (void *)buf_info, TPL_FIRST, NULL); + (void *)tbm_surface, TPL_FIRST, NULL); TPL_OBJECT_UNLOCK(&surf_source->obj); } } @@ -1670,12 +1670,14 @@ twe_surface_del(twe_surface_h twe_surface) return TPL_ERROR_INVALID_PARAMETER; } - /* Should be waited until all in_use_buffers has been retrieved. */ + TPL_OBJECT_LOCK(&surf_source->obj); while (!__tpl_list_is_empty(surf_source->in_use_buffers)) { - sched_yield(); + tbm_surface_h tbm_surface = (tbm_surface_h)__tpl_list_pop_front( + surf_source->in_use_buffers, + NULL); + tbm_surface_internal_unref(tbm_surface); } - TPL_OBJECT_LOCK(&surf_source->obj); __tpl_list_free(surf_source->in_use_buffers, NULL); TPL_OBJECT_UNLOCK(&surf_source->obj); -- 2.7.4