From d9ea671fd253b9c6782eb37e4b61d9d044d9574b Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Wed, 3 Jan 2018 15:16:05 +0900 Subject: [PATCH] tpl_wayland_egl: Add necessity check for buffer release On buffer release cb, there was no checking mechanism to check if this buffer needs to be released or not. This patch will add checking if this buffer has to be released or not. Therefore, unnecessary buffer release cb will be detected and handled correctly. Change-Id: I08224b2eeca1cc97b685c95ce5fb06981f37909c Signed-off-by: Hoyub Lee --- src/tpl_wayland_egl.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 35cb53f..ab534a7 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -64,6 +64,7 @@ struct _tpl_wayland_egl_buffer { tpl_bool_t rotated; /* TRUE if need to call wl_surface_set_buffer_transform */ tpl_bool_t reset; /* TRUE if queue reseted by external */ tpl_bool_t is_new; /* for frontbuffer mode */ + tpl_bool_t need_to_release; /* for checking need release */ struct wl_proxy *wl_proxy; /* wl_buffer proxy */ }; @@ -795,6 +796,8 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, wl_surface_commit(wl_egl_window->surface); + wayland_egl_buffer->need_to_release = TPL_TRUE; + wl_display_flush(wayland_egl_display->wl_dpy); TPL_LOG_B("WL_EGL", @@ -1416,22 +1419,31 @@ __cb_client_buffer_release_callback(void *data, struct wl_proxy *proxy) __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface); if (wayland_egl_buffer) { - wayland_egl_surface = wayland_egl_buffer->wayland_egl_surface; - - if (wayland_egl_surface->attached_buffers) { - TPL_OBJECT_LOCK(&wayland_egl_surface->base); - /* Stop tracking of this released tbm_surface. */ - __tpl_list_remove_data(wayland_egl_surface->attached_buffers, - (void *)tbm_surface, TPL_FIRST, NULL); - TPL_OBJECT_UNLOCK(&wayland_egl_surface->base); + if (wayland_egl_buffer->need_to_release) { + wayland_egl_surface = wayland_egl_buffer->wayland_egl_surface; + + if (wayland_egl_surface->attached_buffers) { + TPL_OBJECT_LOCK(&wayland_egl_surface->base); + /* Stop tracking of this released tbm_surface. */ + __tpl_list_remove_data(wayland_egl_surface->attached_buffers, + (void *)tbm_surface, TPL_FIRST, NULL); + TPL_OBJECT_UNLOCK(&wayland_egl_surface->base); + } + /* If tbm_surface_queue was reset before release_cb called out, + * tbm_surface_queue_release doesn't have to be done. */ + if (wayland_egl_buffer->reset == TPL_FALSE) + tbm_surface_queue_release(wayland_egl_surface->tbm_queue, + tbm_surface); + + wayland_egl_buffer->need_to_release = TPL_FALSE; + + tbm_surface_internal_unref(tbm_surface); + } else { + TPL_WARN("No need to release buffer | wl_buffer(%p) tbm_surface(%p) bo(%d)", + proxy, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); } - /* If tbm_surface_queue was reset before release_cb called out, - * tbm_surface_queue_release doesn't have to be done. */ - if (wayland_egl_buffer->reset == TPL_FALSE) - tbm_surface_queue_release(wayland_egl_surface->tbm_queue, tbm_surface); } - - tbm_surface_internal_unref(tbm_surface); } } -- 2.7.4