From: joonbum.ko Date: Mon, 13 Nov 2017 05:03:32 +0000 (+0900) Subject: tpl_wl_vk_thread: Added reset callback to tbm_queue for HWC. X-Git-Tag: accepted/tizen/unified/20171206.063114~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87c82236b07d38e978157453953a801a6812b405;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git tpl_wl_vk_thread: Added reset callback to tbm_queue for HWC. - Modified the tbm_queue to create from wayland_tbm_client to enable HWC. - Added reset callback and flag so that the client knows the reset via the tpl_surface_validate() function. Change-Id: I03dca08bb0c8618ec658dc4ebc226465167361ec Signed-off-by: joonbum.ko --- diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 661b64b..2e345ab 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2383,14 +2383,22 @@ twe_surface_create_swapchain(twe_surface_h twe_surface, } } - /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */ - present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX; - - surf_source->tbm_queue = tbm_surface_queue_create(buffer_count, - width, - height, - TBM_FORMAT_ARGB8888, - 0); + surf_source->tbm_queue = wayland_tbm_client_create_surface_queue( + disp_source->wl_tbm_client, + surf_source->surf, + buffer_count, + width, height, + TBM_FORMAT_ARGB8888); + + if (tbm_surface_queue_add_reset_cb(surf_source->tbm_queue, + __cb_tbm_queue_reset_callback, + NULL) != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("Failed to register reset callback to tbm_surface_queue(%p)", + surf_source->tbm_queue); + tbm_surface_queue_destroy(surf_source->tbm_queue); + return TPL_ERROR_INVALID_OPERATION; + } + if (!surf_source->tbm_queue) { TPL_ERR("TBM surface queue creation failed!"); return TPL_ERROR_OUT_OF_MEMORY; diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index fd518bf..1b8f448 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -24,6 +24,8 @@ struct _tpl_wayland_vk_wsi_surface { twe_surface_h twe_surface; tbm_surface_queue_h tbm_queue; int buffer_count; + tpl_bool_t is_activated; + tpl_bool_t reset; }; static tpl_result_t __tpl_wl_vk_wsi_surface_destroy_swapchain( @@ -382,7 +384,10 @@ __tpl_wl_vk_wsi_surface_validate(tpl_surface_t *surface) TPL_ASSERT(surface); TPL_ASSERT(surface->backend.data); - return TPL_TRUE; + tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = + (tpl_wayland_vk_wsi_surface_t *)surface->backend.data; + + return !(wayland_vk_wsi_surface->reset); } static tbm_surface_h @@ -508,6 +513,41 @@ release_buffer_fail: return ret; } +static void +__cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h surface_queue, + void *data) +{ + tpl_surface_t *surface = NULL; + tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; + tpl_bool_t is_activated = TPL_FALSE; + + surface = (tpl_surface_t *)data; + TPL_CHECK_ON_NULL_RETURN(surface); + + wayland_vk_wsi_surface = (tpl_wayland_vk_wsi_surface_t *)surface->backend.data; + TPL_CHECK_ON_NULL_RETURN(wayland_vk_wsi_surface); + + /* When queue_reset_callback is called, if is_activated is different from + * its previous state change the reset flag to TPL_TRUE to get a new buffer + * with the changed state(ACTIVATED/DEACTIVATED) at the next frame. */ + is_activated = twe_surface_check_activated(wayland_vk_wsi_surface->twe_surface); + if (wayland_vk_wsi_surface->is_activated != is_activated) { + if (is_activated) { + TPL_LOG_T("WL_EGL", + "[ACTIVATED_CB] wayland_vk_wsi_surface(%p) tbm_queue(%p)", + wayland_vk_wsi_surface, surface_queue); + } else { + TPL_LOG_T("WL_EGL", + "[DEACTIVATED_CB] wayland_vk_wsi_surface(%p) tbm_queue(%p)", + wayland_vk_wsi_surface, surface_queue); + } + wayland_vk_wsi_surface->reset = TPL_TRUE; + } + + if (surface->reset_cb) + surface->reset_cb(surface->reset_data); +} + static tpl_result_t __tpl_wl_vk_wsi_surface_create_swapchain(tpl_surface_t *surface, tbm_format format, int width, @@ -539,7 +579,19 @@ __tpl_wl_vk_wsi_surface_create_swapchain(tpl_surface_t *surface, wayland_vk_wsi_surface->tbm_queue = twe_surface_get_tbm_queue( wayland_vk_wsi_surface->twe_surface); + + /* Set reset_callback to tbm_queue */ + if (tbm_surface_queue_add_reset_cb(wayland_vk_wsi_surface->tbm_queue, + __cb_tbm_surface_queue_reset_callback, + (void *)surface)) { + TPL_ERR("TBM surface queue add reset cb failed!"); + twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); + wayland_vk_wsi_surface->tbm_queue = NULL; + return TPL_ERROR_INVALID_OPERATION; + } + wayland_vk_wsi_surface->buffer_count = buffer_count; + wayland_vk_wsi_surface->reset = TPL_FALSE; return TPL_ERROR_NONE; }