From: joonbum.ko Date: Thu, 10 Aug 2017 07:31:24 +0000 (+0900) Subject: tpl_wayland_egl_thread: Added window rotate callback for prerotation. X-Git-Tag: accepted/tizen/unified/20170811.133048~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F16%2F143516%2F1;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git tpl_wayland_egl_thread: Added window rotate callback for prerotation. - Before this patch, there was no way to update the tpl_surface->rotation value. - So added an internal function to register rotation callback to know rotation value. - Added New internal API : tpl_result_t twe_surface_set_rotate_callback(twe_surface_h, void *data, tpl_surface_cb_func_t) - By registering a callback with above internal API at the time of wayland_egl_surface init, tpl_surface can know whether window is rotating or not and can update the value of rotation. Change-Id: I32de635145d434e822423202e5311c5024cca16c Signed-off-by: joonbum.ko --- diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 1274d6f..bd2f7ad 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -67,6 +67,8 @@ struct _twe_wl_surf_source { struct wl_egl_window *wl_egl_window; int latest_transform; int rotation; + void *cb_data; + tpl_surface_cb_func_t rotate_cb; tpl_bool_t rotation_capability; tpl_object_t obj; /* for mutex lock */ tpl_list_t *committed_buffers; @@ -666,6 +668,9 @@ __cb_rotate_callback(struct wl_egl_window *wl_egl_window, void *private) wl_egl_window, source->rotation, rotation); source->rotation = rotation; + + if (source->rotate_cb) + source->rotate_cb(source->cb_data); } static int @@ -1447,6 +1452,8 @@ twe_surface_add(twe_thread* thread, source->vblank_done = TPL_TRUE; source->committed_buffers = __tpl_list_alloc(); source->in_use_buffers = __tpl_list_alloc(); + source->cb_data = NULL; + source->rotate_cb = NULL; __tpl_object_init(&source->obj, TPL_OBJECT_SURFACE, NULL); _twe_surface_buffer_flusher_init(source); @@ -1529,6 +1536,9 @@ twe_surface_del(twe_surface_h twe_surface) /* TODO : surf_source will be removed from surfaces list in disp_source */ + surf_source->cb_data = NULL; + surf_source->rotate_cb = NULL; + TPL_LOG_T("WL_EGL", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", surf_source, surf_source->wl_egl_window, surf_source->surf); @@ -1543,6 +1553,28 @@ twe_surface_del(twe_surface_h twe_surface) return TPL_ERROR_NONE; } +tpl_result_t +twe_surface_set_rotate_callback(twe_surface_h twe_surface, + void *data, tpl_surface_cb_func_t rotate_cb) +{ + twe_wl_surf_source *source = (twe_wl_surf_source *)twe_surface; + if (!source) { + TPL_ERR("Invalid parameter. twe_surface is NULL."); + return TPL_ERROR_INVALID_PARAMETER; + } + + if (!data || !rotate_cb) { + TPL_ERR("Invalid parameter. data(%p) rotate_cb(%p)", + data, rotate_cb); + return TPL_ERROR_INVALID_PARAMETER; + } + + source->cb_data = data; + source->rotate_cb = rotate_cb; + + return TPL_ERROR_NONE; +} + int twe_surface_get_rotation(twe_surface_h twe_surface) { diff --git a/src/tpl_wayland_egl_thread.h b/src/tpl_wayland_egl_thread.h index 424a539..904fde0 100644 --- a/src/tpl_wayland_egl_thread.h +++ b/src/tpl_wayland_egl_thread.h @@ -39,6 +39,10 @@ twe_surface_del(twe_surface_h twe_surface); tbm_surface_queue_h twe_surface_get_tbm_queue(twe_surface_h twe_surface); +tpl_result_t +twe_surface_set_rotate_callback(twe_surface_h twe_surface, + void *data, tpl_surface_cb_func_t rotate_cb); + int twe_surface_get_rotation(twe_surface_h twe_surface); diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index b45e28a..4c2e8a6 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -284,6 +284,28 @@ __cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h surface_queue, surface->reset_cb(surface->reset_data); } +void __cb_window_rotate_callback(void *data) +{ + tpl_surface_t *surface = (tpl_surface_t *)data; + tpl_wayland_egl_surface_t *wayland_egl_surface = NULL; + int rotation; + + if (!surface) { + TPL_ERR("Inavlid parameter. surface is NULL."); + return; + } + + wayland_egl_surface = (tpl_wayland_egl_surface_t *)surface->backend.data; + if (!wayland_egl_surface) { + TPL_ERR("Invalid parameter. surface->backend.data is NULL"); + return; + } + + rotation = twe_surface_get_rotation(wayland_egl_surface->twe_surface); + + surface->rotation = rotation; +} + static tpl_result_t __tpl_wl_egl_surface_init(tpl_surface_t *surface) { @@ -291,6 +313,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) tpl_wayland_egl_surface_t *wayland_egl_surface = NULL; tbm_surface_queue_h tbm_queue = NULL; twe_surface_h twe_surface = NULL; + tpl_result_t ret = TPL_ERROR_NONE; TPL_ASSERT(surface); TPL_ASSERT(surface->display); @@ -346,6 +369,12 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) surface->height = tbm_surface_queue_get_height(tbm_queue); surface->rotation = twe_surface_get_rotation(twe_surface); + ret = twe_surface_set_rotate_callback(twe_surface, (void *)surface, + (tpl_surface_cb_func_t)__cb_window_rotate_callback); + if (ret != TPL_ERROR_NONE) { + TPL_WARN("Failed to register rotate callback."); + } + TPL_LOG_T("WL_EGL", "[INIT1/2]tpl_surface(%p) tpl_wayland_egl_surface(%p) twe_surface(%p)", surface, wayland_egl_surface, twe_surface);