From e6f94d91e82d4c45bb8e2f2cc4e37bf5f26e7991 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Thu, 23 Mar 2017 11:28:08 +0900 Subject: [PATCH 01/16] Use %license macro to copy license file This patch applies %license macro to libtpl-egl, libwayland-egl. For tpl-test which use googletest, %license macro is not applied, but the path where license be copied is changed to Tizen licenses folder. Change-Id: I048158c1cdc9ce59f0ca86e91ff61a721652ff2c Signed-off-by: Hoyub Lee --- packaging/libtpl-egl.spec | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 286cbf6..f0998a5 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -215,15 +215,11 @@ ln -sf libtpl-egl.so.%{TPL_VER_MAJOR} %{buildroot}%{_libdir}/libtpl-egl.so cp -a src/tpl.h %{buildroot}%{_includedir}/ cp -a pkgconfig/tpl-egl.pc %{buildroot}%{_libdir}/pkgconfig/ -mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/%{name} - %if "%{TPL_WINSYS}" == "WL" cd src/wayland-egl cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1 cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1.0 -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/libwayland-egl export WLD_EGL_SO_VER=%{WL_EGL_VERSION} %makeinstall cd - @@ -239,8 +235,8 @@ mkdir -p %{buildroot}/opt/usr/tpl-test cp -arp ./tc/tpl-test %{buildroot}/opt/usr/tpl-test # License of Google Test which is BSD-3-Clause -mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license -cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/license/googletest +mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/licenses/googletest +cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/licenses/googletest/LICENSE %endif %post -p /sbin/ldconfig @@ -253,7 +249,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ %files %manifest packaging/libtpl-egl.manifest -%{TZ_SYS_RO_SHARE}/license/%{name} +%license COPYING %defattr(-,root,root,-) %{_libdir}/libtpl-egl.so %{_libdir}/libtpl-egl.so.%{TPL_VER_MAJOR} @@ -266,7 +262,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ /opt/usr/tpl-test/tpl-test # License of Google Test which is BSD-3-Clause -%{TZ_SYS_RO_SHARE}/license/googletest +%{TZ_SYS_RO_SHARE}/licenses/googletest/LICENSE %endif %files devel @@ -277,7 +273,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ %if "%{TPL_WINSYS}" == "WL" %files -n libwayland-egl %manifest packaging/libwayland-egl.manifest -%{TZ_SYS_RO_SHARE}/license/libwayland-egl +%license COPYING %defattr(-,root,root,-) %{_libdir}/libwayland-egl.so %{_libdir}/libwayland-egl.so.1 -- 2.7.4 From b0619c3e1348571365f31d752c8b0b012595cfe1 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Tue, 4 Apr 2017 14:47:10 +0900 Subject: [PATCH 02/16] tpl_tbm: Fix uninitialized local variable problem Change-Id: Ie8594d2d59c2e7c1094dbc742d074659f1082c41 Signed-off-by: Hoyub Lee --- src/tpl_tbm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index e8cc626..b5c022e 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -519,7 +519,7 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, { tpl_tbm_surface_t *tpl_tbm_surface = NULL; tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; - tbm_surface_queue_h tbm_queue; + tbm_surface_queue_h tbm_queue = NULL; TPL_ASSERT(surface); TPL_ASSERT(surface->display); -- 2.7.4 From ef4ef42c6e7ba2faacfa9f6d40557ea9e1432eb3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 14 Apr 2017 10:39:41 +0900 Subject: [PATCH 03/16] add BSD-3-Clause License to COPYING for gtest The license of the gtest is BSD-3-Cluase. Change-Id: If2e16415464ae155ac06aa5b7dddf0be4a1697ef --- COPYING | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/COPYING b/COPYING index 9036173..ade2193 100644 --- a/COPYING +++ b/COPYING @@ -17,3 +17,32 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. +* Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- 2.7.4 From 90e32de400d1d5ebe9aec757c8e5b677197f2349 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Fri, 17 Feb 2017 17:43:28 +0900 Subject: [PATCH 04/16] tpl_gbm: Register reset callback of gbm's tbm_surface_queue - Server(E20) will be able to reset buffer_age of their buffers. - In order to work well with partial updates, server need to reset the buffer_age at the time of ACTIVE and DEACTIVE switching. Change-Id: I79ff9702fe7d0d14fb8a8d1204b87db1e1318736 Signed-off-by: joonbum.ko --- src/tpl_gbm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/tpl_gbm.c b/src/tpl_gbm.c index 42f1a90..f45ba99 100644 --- a/src/tpl_gbm.c +++ b/src/tpl_gbm.c @@ -39,6 +39,7 @@ struct _tpl_gbm_display { struct _tpl_gbm_surface { tbm_surface_queue_h tbm_queue; tbm_surface_h current_buffer; + tpl_bool_t reset; /* TRUE if queue was reset by external */ }; struct _tpl_gbm_buffer { @@ -254,6 +255,27 @@ __tpl_gbm_display_get_buffer_from_native_pixmap(tpl_handle_t pixmap) return tbm_surface; } +static void +__cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h surface_queue, + void *data) +{ + tpl_surface_t *surface = NULL; + tpl_gbm_surface_t *tpl_gbm_surface = NULL; + + surface = (tpl_surface_t *)data; + TPL_CHECK_ON_NULL_RETURN(surface); + + tpl_gbm_surface = (tpl_gbm_surface_t *)surface->backend.data; + TPL_CHECK_ON_NULL_RETURN(tpl_gbm_surface); + + TPL_LOG_B("GBM", + "[QUEUE_RESET_CB] tpl_gbm_surface_t(%p) surface_queue(%p)", + data, surface_queue); + + if (surface->reset_cb) + surface->reset_cb(surface->reset_data); +} + static tpl_result_t __tpl_gbm_surface_init(tpl_surface_t *surface) { @@ -279,6 +301,14 @@ __tpl_gbm_surface_init(tpl_surface_t *surface) goto error; } + /* Set reset_callback to tbm_queue */ + if (tbm_surface_queue_add_reset_cb(tpl_gbm_surface->tbm_queue, + __cb_tbm_surface_queue_reset_callback, + (void *)surface)) { + TPL_ERR("TBM surface queue add reset cb failed!"); + goto error; + } + if (__tpl_gbm_display_get_window_info(surface->display, surface->native_handle, &surface->width, &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) { -- 2.7.4 From 2cd1da010e4ed140030183582a7d807050d5051d Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 20 Feb 2017 16:54:17 +0900 Subject: [PATCH 05/16] tpl_wayland_egl: Set event queue by using new API of wayland-tbm. - Use new API to set event_queue in order to do roundtrip in wl_tbm. - platform/core/uifw/wayland-tbm commit_id : 21c96897bbcde143eff825e2d59fe820e99e5e16 commit_message : client: added function wayland_tbm_client_set_event_queue Change-Id: Idcd7d24912fd8fe655ecdf2d834e8cc10a92a3d0 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 4f4ad44..f24bdc4 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -162,14 +162,6 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) goto free_wl_display; } - wayland_egl_display->wl_tbm = - (struct wl_proxy *)wayland_tbm_client_get_wl_tbm( - wayland_egl_display->wl_tbm_client); - if (!wayland_egl_display->wl_tbm) { - TPL_ERR("Failed to get wl_tbm from wayland_tbm_client."); - goto free_wl_display; - } - wayland_egl_display->wl_tbm_event_queue = wl_display_create_queue(wl_dpy); if (!wayland_egl_display->wl_tbm_event_queue) { @@ -177,8 +169,12 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) goto free_wl_display; } - wl_proxy_set_queue(wayland_egl_display->wl_tbm, - wayland_egl_display->wl_tbm_event_queue); + if (!wayland_tbm_client_set_event_queue( + wayland_egl_display->wl_tbm_client, + wayland_egl_display->wl_tbm_event_queue)) { + TPL_ERR("Failed to set event_queue to wl_tbm."); + goto free_wl_display; + } if (env == NULL || atoi(env)) { TPL_LOG_B("WL_EGL", "[INIT] ENABLE wait vblank."); @@ -208,8 +204,8 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) free_wl_display: if (wayland_egl_display->tdm_client) tdm_client_destroy(wayland_egl_display->tdm_client); - if ((wayland_egl_display->wl_tbm) && (wayland_egl_display->wl_tbm_event_queue)) - wl_proxy_set_queue(wayland_egl_display->wl_tbm, NULL); + if (wayland_egl_display->wl_tbm_client) + wayland_tbm_client_set_event_queue(wayland_egl_display->wl_tbm_client, NULL); if (wayland_egl_display->wl_tbm_event_queue) wl_event_queue_destroy(wayland_egl_display->wl_tbm_event_queue); if (wayland_egl_display->wl_tbm_client) @@ -218,7 +214,6 @@ free_wl_display: wayland_egl_display->wl_tbm_event_queue = NULL; wayland_egl_display->wl_tbm_client = NULL; wayland_egl_display->tdm_client = NULL; - wayland_egl_display->wl_tbm = NULL; wayland_egl_display->wl_dpy = NULL; free(wayland_egl_display); @@ -243,8 +238,8 @@ __tpl_wayland_egl_display_fini(tpl_display_t *display) if (wayland_egl_display->tdm_client) tdm_client_destroy(wayland_egl_display->tdm_client); - if ((wayland_egl_display->wl_tbm) && (wayland_egl_display->wl_tbm_event_queue)) - wl_proxy_set_queue(wayland_egl_display->wl_tbm, NULL); + if (wayland_egl_display->wl_tbm_client) + wayland_tbm_client_set_event_queue(wayland_egl_display->wl_tbm_client, NULL); if (wayland_egl_display->wl_tbm_event_queue) wl_event_queue_destroy(wayland_egl_display->wl_tbm_event_queue); @@ -255,7 +250,6 @@ __tpl_wayland_egl_display_fini(tpl_display_t *display) wayland_egl_display->wl_tbm_event_queue = NULL; wayland_egl_display->wl_tbm_client = NULL; wayland_egl_display->tdm_client = NULL; - wayland_egl_display->wl_tbm = NULL; wayland_egl_display->wl_dpy = NULL; free(wayland_egl_display); } -- 2.7.4 From d62f62e47c0840719e8efd88db9f565caaf93e15 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 14 Mar 2017 17:15:29 +0900 Subject: [PATCH 06/16] tpl_gbm, tpl_tbm: Revised exception checking syntax of the dequeue error situation. - This patch will be able to resolve SVACE issue about below error situation. 1. tbm_surface_queue_dequeue return (tbm_surface == NULL) 2. tbm_surface_queue_can_dequeue return 0, because of internal error. 3. cannot enter the if syntax and cannot call tbm_surface_queue_dequeue. 4. tbm_surface is still NULL but try to call tbm_surface_internal_ref. <- error case. Change-Id: I4dbdb51bf3682a1acadde4d7c07d899de6fe01cd Signed-off-by: joonbum.ko --- src/tpl_gbm.c | 19 +++++++++---------- src/tpl_tbm.c | 15 +++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/tpl_gbm.c b/src/tpl_gbm.c index f45ba99..06596a2 100644 --- a/src/tpl_gbm.c +++ b/src/tpl_gbm.c @@ -442,7 +442,7 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, { tbm_bo bo; tbm_surface_h tbm_surface = NULL; - tbm_surface_queue_error_e tsq_err = 0; + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE; tpl_gbm_buffer_t *gbm_buffer = NULL; tpl_gbm_surface_t *gbm_surface = NULL; @@ -458,18 +458,17 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, gbm_surface = (tpl_gbm_surface_t *)surface->backend.data; TRACE_BEGIN("WAITING FOR DEQUEUEABLE"); - tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface); - if (!tbm_surface - && tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) { + if (tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface); - if (!tbm_surface) { - TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", - tsq_err); - TRACE_END(); - return NULL; - } + + if (!tbm_surface) { + TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", + tsq_err); + TRACE_END(); + return NULL; } TRACE_END(); + /* Inc ref count about tbm_surface */ /* It will be dec when before tbm_surface_queue_enqueue called */ tbm_surface_internal_ref(tbm_surface); diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index b5c022e..50154e5 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -594,7 +594,7 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, { tbm_surface_h tbm_surface = NULL; tbm_surface_queue_h tbm_queue = NULL; - tbm_surface_queue_error_e tsq_err = 0; + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE; tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; TPL_ASSERT(surface); @@ -607,14 +607,13 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_queue = (tbm_surface_queue_h)surface->native_handle; - tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface); - if (!tbm_surface && tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) { + if (tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface); - if (!tbm_surface) { - TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", - tsq_err); - return NULL; - } + + if (!tbm_surface) { + TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", + tsq_err); + return NULL; } if (surface->backend.type == TPL_BACKEND_TBM_VULKAN_WSI) { -- 2.7.4 From 115ebb65c80ebce7ea47f5d2363e47c4907300ba Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Thu, 16 Mar 2017 09:13:32 +0900 Subject: [PATCH 07/16] tpl_wayland_egl: Added geometry information of the client window to tpl_wayland_egl_buffer_t. - Store the native window information when the wayland client do dequeue buffer in tpl_wayland_egl_buffer_t. - By using the information remaining in the tpl_wayland_egl_buffer_t which rendering job end, do commit to server. - This change will be able to inform accurate information of client window to server. Change-Id: I4a7c4646cfc8ab3f39c8755f7c1193b33992a1ed Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index f24bdc4..4f9cb12 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -57,6 +57,9 @@ struct _tpl_wayland_egl_surface { struct _tpl_wayland_egl_buffer { tpl_wayland_egl_display_t *display; tpl_wayland_egl_surface_t *wayland_egl_surface; + int dx, dy; + int width, height; + int rotation; tbm_bo bo; tpl_bool_t reset; /* TRUE if queue reseted by external */ struct wl_proxy *wl_proxy; /* wl_buffer proxy */ @@ -723,15 +726,15 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, TPL_IMAGE_DUMP(tbm_surface, surface->width, surface->height); wl_surface_attach(wl_egl_window->surface, (void *)wayland_egl_buffer->wl_proxy, - wl_egl_window->dx, wl_egl_window->dy); + wayland_egl_buffer->dx, wayland_egl_buffer->dy); - wl_egl_window->attached_width = wl_egl_window->width; - wl_egl_window->attached_height = wl_egl_window->height; + wl_egl_window->attached_width = wayland_egl_buffer->width; + wl_egl_window->attached_height = wayland_egl_buffer->height; if (num_rects < 1 || rects == NULL) { wl_surface_damage(wl_egl_window->surface, - wl_egl_window->dx, wl_egl_window->dy, - wl_egl_window->width, wl_egl_window->height); + wayland_egl_buffer->dx, wayland_egl_buffer->dy, + wayland_egl_buffer->width, wayland_egl_buffer->height); } else { int i; @@ -741,7 +744,7 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, * WINDOW(Top-left) coord like below. * y = [WINDOW.HEIGHT] - (RECT.Y + RECT.HEIGHT) */ int inverted_y = - wl_egl_window->height - (rects[i * 4 + 1] + rects[i * 4 + 3]); + wayland_egl_buffer->height - (rects[i * 4 + 1] + rects[i * 4 + 3]); wl_surface_damage(wl_egl_window->surface, rects[i * 4 + 0], inverted_y, rects[i * 4 + 2], rects[i * 4 + 3]); @@ -753,9 +756,10 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, wl_display_flush(wayland_egl_display->wl_dpy); TPL_LOG_B("WL_EGL", - "[COMMIT] wl_surface(%p) wl_egl_window(%p)(%dx%d) wl_buffer(%p)", + "[COMMIT] wl_surface(%p) wl_egl_window(%p) wl_buffer(%p)(%dx%d)", wl_egl_window->surface, wl_egl_window, - wl_egl_window->width, wl_egl_window->height, wayland_egl_buffer->wl_proxy); + wayland_egl_buffer->wl_proxy, + wayland_egl_buffer->width, wayland_egl_buffer->height); if (wayland_egl_surface->attached_buffers) { TPL_OBJECT_LOCK(&wayland_egl_surface->base); @@ -999,6 +1003,8 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou tpl_wayland_egl_display_t *wayland_egl_display = (tpl_wayland_egl_display_t *)surface->display->backend.data; struct wl_proxy *wl_proxy = NULL; + struct wl_egl_window *wl_egl_window = + (struct wl_egl_window *)surface->native_handle; tbm_surface_queue_error_e tsq_err = 0; if (sync_fence) @@ -1006,8 +1012,6 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou /* Check whether the surface was resized by wayland_egl */ if (wayland_egl_surface->resized == TPL_TRUE) { - struct wl_egl_window *wl_egl_window = - (struct wl_egl_window *)surface->native_handle; int width, height, format; width = wl_egl_window->width; height = wl_egl_window->height; @@ -1047,6 +1051,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->wl_proxy, tbm_surface, tbm_bo_export(wayland_egl_buffer->bo)); + wayland_egl_buffer->dx = wl_egl_window->dx; + wayland_egl_buffer->dy = wl_egl_window->dy; + wayland_egl_buffer->width = wl_egl_window->width; + wayland_egl_buffer->height = wl_egl_window->height; + wayland_egl_buffer->rotation = wl_egl_window->rotation; + wayland_egl_buffer->reset = TPL_FALSE; wayland_egl_surface->reset = TPL_FALSE; @@ -1084,6 +1094,11 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wl_display_flush(wayland_egl_display->wl_dpy); + wayland_egl_buffer->dx = wl_egl_window->dx; + wayland_egl_buffer->dy = wl_egl_window->dy; + wayland_egl_buffer->width = wl_egl_window->width; + wayland_egl_buffer->height = wl_egl_window->height; + wayland_egl_buffer->rotation = wl_egl_window->rotation; wayland_egl_buffer->display = wayland_egl_display; wayland_egl_buffer->wl_proxy = wl_proxy; wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0); -- 2.7.4 From a7d8b298449ddef34062cdb933115b8eaec02bf4 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Thu, 2 Mar 2017 15:29:14 +0900 Subject: [PATCH 08/16] wayland-egl: Prerotation need not to do window resize. Change-Id: I1b12350e01862317358f7ac29a1274cab6812ae8 Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl.c | 83 ++++++------------------------------------- 1 file changed, 11 insertions(+), 72 deletions(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 8ed649f..46d47a0 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -15,17 +15,14 @@ unsigned int wl_egl_log_level; /* WL-EGL Log Level - 0:unintialized, 1:initialized(no logging), 2:min log, 3:more log */ -#define WL_EGL_LOG(lvl, f, x...) \ - { \ - if(wl_egl_log_level == 1) \ - {} \ - else if(wl_egl_log_level > 1) \ - { \ +#define WL_EGL_LOG(lvl, f, x...) { \ + if(wl_egl_log_level == 1) { \ + } \ + else if(wl_egl_log_level > 1) { \ if(wl_egl_log_level <= lvl) \ WL_EGL_LOG_PRINT(f, ##x) \ } \ - else \ - { \ + else { \ char *env = getenv("WL_EGL_LOG_LEVEL"); \ if(env == NULL) \ wl_egl_log_level = 1; \ @@ -37,14 +34,12 @@ unsigned int wl_egl_log_level; } \ } -#define WL_EGL_LOG_PRINT(fmt, args...) \ - { \ +#define WL_EGL_LOG_PRINT(fmt, args...) { \ printf("[\x1b[32mWL-EGL\x1b[0m %d:%d|\x1b[32m%s\x1b[0m|%d] " fmt "\n", \ getpid(), (int)syscall(SYS_gettid), __func__,__LINE__, ##args); \ } -#define WL_EGL_ERR(f, x...) \ - { \ +#define WL_EGL_ERR(f, x...) { \ printf("[\x1b[31mWL-EGL_ERR\x1b[0m %d:%d|\x1b[31m%s\x1b[0m|%d] " f "\n",\ getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##x); \ } @@ -58,7 +53,6 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, int width, int height, int dx, int dy) { - int prev_width, prev_height; wl_egl_window_rotation rotation; if (egl_window == NULL) { @@ -69,35 +63,10 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, egl_window->dx = dx; egl_window->dy = dy; - rotation = egl_window->rotation; - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - default: - prev_width = egl_window->width; - prev_height = egl_window->height; - break; - case ROTATION_90: - case ROTATION_270: - prev_width = egl_window->height; - prev_height = egl_window->width; - break; - } - if ((prev_width == width) && (prev_height == height)) return; - - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - default: - egl_window->width = width; - egl_window->height = height; - break; - case ROTATION_90: - case ROTATION_270: - egl_window->width = height; - egl_window->height = width; - break; - } + if ((egl_window->width == width) && (egl_window->height == height)) return; + + egl_window->width = width; + egl_window->height = height; if (egl_window->resize_callback) egl_window->resize_callback(egl_window, egl_window->private); @@ -175,9 +144,6 @@ WL_EGL_EXPORT void wl_egl_window_set_rotation(struct wl_egl_window *egl_window, wl_egl_window_rotation rotation) { - int resize = 0; - wl_egl_window_rotation prev_rotation; - if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); return; @@ -188,37 +154,10 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, return; } - prev_rotation = egl_window->rotation; - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - if (prev_rotation == ROTATION_90 || prev_rotation == ROTATION_270) - resize = 1; - break; - case ROTATION_90: - case ROTATION_270: - if (prev_rotation == ROTATION_0 || prev_rotation == ROTATION_180) - resize = 1; - break; - default: - WL_EGL_ERR("Invalid rotation value"); - return; - } - - WL_EGL_LOG(2, "egl_win:%10p prev_rotation:%d curr_rotation: %d", - egl_window, egl_window->rotation, rotation); - egl_window->rotation = rotation; if (egl_window->rotate_callback) egl_window->rotate_callback(egl_window, egl_window->private); - - if ((resize == 1) && (egl_window->resize_callback != NULL)) { - int temp = egl_window->width; - egl_window->width = egl_window->height; - egl_window->height = temp; - egl_window->resize_callback(egl_window, egl_window->private); - } } WL_EGL_EXPORT int -- 2.7.4 From 27275e57af0bf648079b9ec3c0a8d73e0dc83ace Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 10 Apr 2017 13:21:52 +0900 Subject: [PATCH 09/16] wayland-egl: Changed an ERR_LOG to normal log when wl_egl_window already has been rotated. Change-Id: I10f8fe00be29cdfb24c0c3a6962091d87dbca4c6 Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 46d47a0..475bf7c 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -150,7 +150,7 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, } if (egl_window->rotation == rotation) { - WL_EGL_ERR("rotation value is same"); + WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated"); return; } -- 2.7.4 From 632bc065beec9e09625f5b8d1e3f987efad5475c Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 15 May 2017 18:58:44 +0900 Subject: [PATCH 10/16] tpl_surface, tpl_wayland_egl: Refactored the procedue related with frontbuffer mode. - There was a problem with HWC in the existing procedure related with frontbuffer_mode. The existing procedure was difficult to use eglFrontBufferSetSEC because the client did not know exactly when to use the frontbuffer. - Solved this problem through wayland_tbm_client API. - platform/core/uifw/wayland-tbm commit_id : 0de11f336d666d7b8cc171deeb404ec3b287cde8 commit_message : client: added wayland_tbm_client_queue_check_activate - See comments of the codes related with frontbuffer_mode for details. Change-Id: I5d024284d65ae65277fe67a4cd000a78f592665f Signed-off-by: joonbum.ko --- src/tpl_surface.c | 25 ++-------------- src/tpl_wayland_egl.c | 80 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 75 insertions(+), 30 deletions(-) diff --git a/src/tpl_surface.c b/src/tpl_surface.c index c991868..a595ef4 100644 --- a/src/tpl_surface.c +++ b/src/tpl_surface.c @@ -214,16 +214,7 @@ tpl_surface_dequeue_buffer_with_sync(tpl_surface_t *surface, TRACE_BEGIN("TPL:DEQUEUE_BUFFER"); TPL_OBJECT_LOCK(surface); - if (surface->is_frontbuffer_mode && surface->frontbuffer) { - if (TPL_TRUE == surface->backend.validate(surface)) { - tbm_surface = surface->frontbuffer; - } else { - surface->frontbuffer = NULL; - } - } - - if (!tbm_surface) - tbm_surface = surface->backend.dequeue_buffer(surface, timeout_ns, sync_fence); + tbm_surface = surface->backend.dequeue_buffer(surface, timeout_ns, sync_fence); if (tbm_surface) { /* Update size of the surface. */ @@ -277,15 +268,6 @@ tpl_surface_enqueue_buffer_with_damage_and_sync(tpl_surface_t *surface, TRACE_BEGIN("TPL:ENQUEUE_BUFFER_WITH_DAMAGE"); TPL_OBJECT_LOCK(surface); - if (surface->is_frontbuffer_mode) { - if (surface->frontbuffer == tbm_surface) { - TPL_OBJECT_UNLOCK(surface); - TRACE_END(); - return ret; - } - surface->frontbuffer = tbm_surface; - } - TPL_LOG_F("tpl_surface_t(%p) tbm_surface(%p) (%dx%d)", surface, tbm_surface, tbm_surface_get_width(tbm_surface), tbm_surface_get_height(tbm_surface)); @@ -341,7 +323,7 @@ tpl_surface_create_swapchain(tpl_surface_t *surface, tbm_format format, return TPL_ERROR_INVALID_PARAMETER; } - if ((width <= 0) || (height <= 0) ) { + if ((width <= 0) || (height <= 0)) { TPL_ERR("Invalid width or height!"); return TPL_ERROR_INVALID_PARAMETER; } @@ -422,8 +404,7 @@ tpl_surface_set_reset_cb(tpl_surface_t *surface, void *data, tpl_surface_cb_func { tpl_result_t ret = TPL_ERROR_NONE; - if (!surface) - { + if (!surface) { TPL_ERR("Invalid surface!"); return TPL_ERROR_INVALID_PARAMETER; } diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 4f9cb12..fe8c4d8 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -62,6 +62,7 @@ struct _tpl_wayland_egl_buffer { int rotation; tbm_bo bo; tpl_bool_t reset; /* TRUE if queue reseted by external */ + tpl_bool_t is_new; /* for frontbuffer mode */ struct wl_proxy *wl_proxy; /* wl_buffer proxy */ }; @@ -817,6 +818,33 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, wayland_egl_surface, wayland_egl_surface->tbm_queue, tbm_surface, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + wayland_egl_buffer = + __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface); + + if (!wayland_egl_buffer) return TPL_ERROR_INVALID_PARAMETER; + + /* In frontbuffer mode, will skip tbm_surface_queue_enqueue, acquire, and + * commit if surface->frontbuffer that is already set and the tbm_surface + * client want to enqueue are the same. + */ + if (surface->is_frontbuffer_mode && surface->frontbuffer == tbm_surface) { + TPL_LOG_B("WL_EGL", + "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", + surface->frontbuffer); + + /* The first buffer to be activated in frontbuffer mode muse be + * committed. Subsequence frames do not need to be committed because + * the buffer is already displayed. + */ + if (wayland_egl_buffer->is_new) { + __tpl_wayland_egl_surface_commit(surface, tbm_surface, + num_rects, rects); + wayland_egl_buffer->is_new = TPL_FALSE; + } + + return TPL_ERROR_NONE; + } + if (wayland_egl_surface->vblank_done == TPL_FALSE) __tpl_wayland_egl_surface_wait_vblank(surface); @@ -833,11 +861,6 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, TPL_OBJECT_UNLOCK(&wayland_egl_surface->base); } - wayland_egl_buffer = - __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface); - - if (!wayland_egl_buffer) return TPL_ERROR_INVALID_PARAMETER; - if (wayland_egl_buffer->reset) { /* * When tbm_surface_queue being reset for receiving @@ -1006,6 +1029,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)surface->native_handle; tbm_surface_queue_error_e tsq_err = 0; + int is_activated = 0; if (sync_fence) *sync_fence = -1; @@ -1026,10 +1050,41 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou } if (__tpl_wayland_egl_surface_wait_dequeuable(surface)) { - TPL_ERR("Failed to wait dequeeable buffer"); + TPL_ERR("Failed to wait dequeueable buffer"); return NULL; } + /* wayland client can check their states (ACTIVATED or DEACTIVATED) with + * below function [wayland_tbm_client_queue_check_activate()]. + * This function has to be called between + * __tpl_wayland_egl_surface_wait_dequeuable and tbm_surface_queue_dequeue() + * in order to know what state the buffer will be dequeued next. + * + * ACTIVATED state means non-composite mode. Client can get buffers which + can be displayed directly(without compositing). + * DEACTIVATED state means composite mode. Client's buffer will be displayed + by compositor(E20) with compositing. + */ + is_activated = wayland_tbm_client_queue_check_activate( + wayland_egl_display->wl_tbm_client, + wayland_egl_surface->tbm_queue); + + if (surface->is_frontbuffer_mode && surface->frontbuffer != NULL) { + /* If surface->frontbuffer is already set in frontbuffer mode, + * it will return that frontbuffer if it is still activated, + * otherwise dequeue the new buffer after initializing + * surface->frontbuffer to NULL. */ + if (is_activated) { + TPL_LOG_B("WL_EGL", + "[DEQ][F] surface->frontbuffer(%p) BO_NAME(%d)", + surface->frontbuffer, + tbm_bo_export(tbm_surface_internal_get_bo( + surface->frontbuffer, 0))); + return surface->frontbuffer; + } else + surface->frontbuffer = NULL; + } + tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue, &tbm_surface); if (!tbm_surface) { @@ -1040,6 +1095,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou tbm_surface_internal_ref(tbm_surface); + if (surface->is_frontbuffer_mode && is_activated) + surface->frontbuffer = tbm_surface; + if ((wayland_egl_buffer = __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL) { TRACE_MARK("[DEQ][REUSED]BO_NAME:%d", tbm_bo_export(wayland_egl_buffer->bo)); @@ -1056,8 +1114,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->width = wl_egl_window->width; wayland_egl_buffer->height = wl_egl_window->height; wayland_egl_buffer->rotation = wl_egl_window->rotation; - wayland_egl_buffer->reset = TPL_FALSE; + wayland_egl_buffer->is_new = TPL_FALSE; + wayland_egl_surface->reset = TPL_FALSE; if (wayland_egl_surface->dequeued_buffers) { @@ -1104,9 +1163,14 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0); wayland_egl_buffer->wayland_egl_surface = wayland_egl_surface; - /* reset flag is to check whether it is the buffer before tbm_surface_queue is reset or not. */ + /* reset flag is to check whether it is the buffer before + * tbm_surface_queue is reset or not. */ wayland_egl_buffer->reset = TPL_FALSE; + /* 'is_new' flag is to check wheter it is a new buffer need to commit + * in frontbuffer mode. */ + wayland_egl_buffer->is_new = TPL_TRUE; + wayland_egl_surface->current_buffer = tbm_surface; wayland_egl_surface->reset = TPL_FALSE; -- 2.7.4 From 52babccab63b757c16cfba32caf26de9b8aa7953 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 16 May 2017 18:17:54 +0900 Subject: [PATCH 11/16] tpl_wayland_egl: Fixed case of non-pixed buffer in frontbuffer mode. Change-Id: Ie5b6a7bc29bca359aa01092d4b9c86c79d8b0713 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index fe8c4d8..262183a 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -49,6 +49,7 @@ struct _tpl_wayland_egl_surface { tpl_bool_t reset; /* TRUE if queue reseted by external */ tdm_client_vblank *tdm_vblank; /* vblank object for each wl_surface */ tpl_bool_t vblank_done; + tpl_bool_t is_activated; tpl_list_t *attached_buffers; /* list for tracking [ACQ]~[REL] buffers */ tpl_list_t *dequeued_buffers; /* list for tracking [DEQ]~[ENQ] buffers */ struct tizen_surface_shm_flusher *tizen_surface_shm_flusher; /* wl_proxy for buffer flush */ @@ -500,6 +501,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface->resized = TPL_FALSE; wayland_egl_surface->reset = TPL_FALSE; wayland_egl_surface->vblank_done = TPL_TRUE; + wayland_egl_surface->is_activated = TPL_FALSE; wayland_egl_surface->current_buffer = NULL; wayland_egl_surface->attached_buffers = __tpl_list_alloc(); @@ -1115,9 +1117,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->height = wl_egl_window->height; wayland_egl_buffer->rotation = wl_egl_window->rotation; wayland_egl_buffer->reset = TPL_FALSE; - wayland_egl_buffer->is_new = TPL_FALSE; + + if (wayland_egl_surface->is_activated != is_activated) + wayland_egl_buffer->is_new = TPL_TRUE; wayland_egl_surface->reset = TPL_FALSE; + wayland_egl_surface->is_activated = is_activated; if (wayland_egl_surface->dequeued_buffers) { TPL_OBJECT_LOCK(&wayland_egl_surface->base); @@ -1170,6 +1175,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou /* 'is_new' flag is to check wheter it is a new buffer need to commit * in frontbuffer mode. */ wayland_egl_buffer->is_new = TPL_TRUE; + wayland_egl_surface->is_activated = is_activated; wayland_egl_surface->current_buffer = tbm_surface; wayland_egl_surface->reset = TPL_FALSE; -- 2.7.4 From 62256d3d39b892520d7fa20ce64a2fe57239fbea Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 16 May 2017 18:51:59 +0900 Subject: [PATCH 12/16] wayland_egl: Fixed build warning. Change-Id: I21132792d3606114dc3cb96192a9703d7836d8e1 Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 475bf7c..423de31 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -16,27 +16,27 @@ unsigned int wl_egl_log_level; /* WL-EGL Log Level - 0:unintialized, 1:initialized(no logging), 2:min log, 3:more log */ #define WL_EGL_LOG(lvl, f, x...) { \ - if(wl_egl_log_level == 1) { \ + if (wl_egl_log_level == 1) { \ } \ - else if(wl_egl_log_level > 1) { \ - if(wl_egl_log_level <= lvl) \ + else if (wl_egl_log_level > 1) { \ + if (wl_egl_log_level <= lvl) \ WL_EGL_LOG_PRINT(f, ##x) \ } \ else { \ char *env = getenv("WL_EGL_LOG_LEVEL"); \ - if(env == NULL) \ + if (env == NULL) \ wl_egl_log_level = 1; \ else \ wl_egl_log_level = atoi(env); \ \ - if(wl_egl_log_level > 1 && wl_egl_log_level <= lvl) \ + if (wl_egl_log_level > 1 && wl_egl_log_level <= lvl)\ WL_EGL_LOG_PRINT(f, ##x) \ } \ } #define WL_EGL_LOG_PRINT(fmt, args...) { \ printf("[\x1b[32mWL-EGL\x1b[0m %d:%d|\x1b[32m%s\x1b[0m|%d] " fmt "\n", \ - getpid(), (int)syscall(SYS_gettid), __func__,__LINE__, ##args); \ + getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ } #define WL_EGL_ERR(f, x...) { \ @@ -53,8 +53,6 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, int width, int height, int dx, int dy) { - wl_egl_window_rotation rotation; - if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); return; @@ -150,7 +148,8 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, } if (egl_window->rotation == rotation) { - WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated"); + WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated", + rotation, egl_window->rotation); return; } -- 2.7.4 From 682d1002a2440e65c9af593b058460b7ca8e6549 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 16 May 2017 20:04:17 +0900 Subject: [PATCH 13/16] tpl_wayland_egl: Added async trace points to track frontbuffer. Change-Id: I61f9a665ffaf492ecd5b465f7f2786f764572f1c Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 262183a..e05c845 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -842,6 +842,9 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, __tpl_wayland_egl_surface_commit(surface, tbm_surface, num_rects, rects); wayland_egl_buffer->is_new = TPL_FALSE; + } else { + TRACE_ASYNC_END((int)wayland_egl_buffer, "[DEQ]~[ENQ] BO_NAME:%d", + tbm_bo_export(wayland_egl_buffer->bo)); } return TPL_ERROR_NONE; @@ -1082,6 +1085,13 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou surface->frontbuffer, tbm_bo_export(tbm_surface_internal_get_bo( surface->frontbuffer, 0))); + wayland_egl_buffer = + __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface( + surface->frontbuffer); + if (wayland_egl_buffer) + TRACE_ASYNC_BEGIN((int)wayland_egl_buffer, + "[DEQ]~[ENQ] BO_NAME:%d", + tbm_bo_export(wayland_egl_buffer->bo)); return surface->frontbuffer; } else surface->frontbuffer = NULL; -- 2.7.4 From eaf23ddd76f8ff718763decb447fe5509ff37bce Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Wed, 17 May 2017 15:25:58 +0900 Subject: [PATCH 14/16] tpl: Add missed mutex lock / unlock on __tpl_runtime_fini() If race condition occures on __tpl_hashlist_destroy() of __tpl_runtime_fini(), then __tpl_hashlist_destroy() can raise double free. This patch fixes it. Change-Id: Ib438e7e9b3a69d330fbda05d8090d76a80a19222 Signed-off-by: joonbum.ko --- src/tpl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index 23cf39b..afde8d8 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -2,7 +2,7 @@ unsigned int tpl_log_lvl = 0; unsigned int tpl_log_initialized = 0; -unsigned int tpl_dump_lvl; +unsigned int tpl_dump_lvl = 0; struct _tpl_runtime { tpl_hlist_t *displays[TPL_BACKEND_COUNT]; @@ -40,9 +40,12 @@ __tpl_runtime_fini(void) if (runtime != NULL) { int i; - for (i = 0; i < TPL_BACKEND_COUNT; i++) { - if (runtime->displays[i] != NULL) - __tpl_hashlist_destroy(&(runtime->displays[i])); + if (!pthread_mutex_lock(&runtime_mutex)) { + for (i = 0; i < TPL_BACKEND_COUNT; i++) { + if (runtime->displays[i] != NULL) + __tpl_hashlist_destroy(&(runtime->displays[i])); + } + pthread_mutex_unlock(&runtime_mutex); } free(runtime); @@ -71,7 +74,7 @@ __tpl_util_sys_yield(void) int __tpl_util_clz(int val) { - return __builtin_clz( val ); + return __builtin_clz(val); } int @@ -99,7 +102,7 @@ __tpl_util_atomic_set(tpl_util_atomic_uint *const atom, unsigned int val) } unsigned int -__tpl_util_atomic_inc(tpl_util_atomic_uint *const atom ) +__tpl_util_atomic_inc(tpl_util_atomic_uint *const atom) { TPL_ASSERT(atom); @@ -107,7 +110,7 @@ __tpl_util_atomic_inc(tpl_util_atomic_uint *const atom ) } unsigned int -__tpl_util_atomic_dec( tpl_util_atomic_uint *const atom ) +__tpl_util_atomic_dec(tpl_util_atomic_uint *const atom) { TPL_ASSERT(atom); -- 2.7.4 From 8ba144e4e516e8c528ab0c63470c6b0b07aa6e8e Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 22 May 2017 16:36:18 +0900 Subject: [PATCH 15/16] wayland-egl: Added an API to set frontbuffer mode. Change-Id: Id8f52c83ae4a110ce00c9c1271babcfaf242f9bd Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl-priv.h | 3 +++ src/wayland-egl/wayland-egl.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/wayland-egl/wayland-egl-priv.h b/src/wayland-egl/wayland-egl-priv.h index 3c284fc..619fa99 100644 --- a/src/wayland-egl/wayland-egl-priv.h +++ b/src/wayland-egl/wayland-egl-priv.h @@ -28,10 +28,13 @@ struct wl_egl_window { wl_egl_window_rotation rotation; + int frontbuffer_mode; + void *private; void (*resize_callback)(struct wl_egl_window *, void *); void (*rotate_callback)(struct wl_egl_window *, void *); int (*get_rotation_capability)(struct wl_egl_window *, void *); + void (*set_frontbuffer_callback)(struct wl_egl_window *, void *, int); }; #ifdef __cplusplus diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 423de31..8c03f04 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -175,3 +175,19 @@ wl_egl_window_get_capabilities(struct wl_egl_window *egl_window) return capabilities; } + +WL_EGL_EXPORT void +wl_egl_window_set_frontbuffer_mode(struct wl_egl_window *egl_window, + int set) +{ + if (egl_window == NULL) { + WL_EGL_ERR("egl_window is NULL"); + return; + } + + egl_window->frontbuffer_mode = set; + + if (egl_window->set_frontbuffer_callback) + egl_window->set_frontbuffer_callback(egl_window, egl_window->private, + set); +} -- 2.7.4 From 8713ce9bcf0e284ec70d59f040cad1f65c850a80 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 22 May 2017 16:40:09 +0900 Subject: [PATCH 16/16] tpl_wayland_egl: Registered a callback function to set frontbuffer mode. Change-Id: I03267086c07b258b6453dd9fe1fcd42bcbf503cc Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index e05c845..5e83345 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -379,6 +379,10 @@ static int __cb_client_window_get_rotation_capability(struct wl_egl_window *wl_egl_window, void *private); +static void +__cb_client_window_set_frontbuffer_mode(struct wl_egl_window *wl_egl_window, + void *private, int set); + static TPL_INLINE void __tpl_wayland_egl_buffer_set_reset_flag(tpl_list_t *tracking_list) { @@ -556,6 +560,8 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wl_egl_window->rotate_callback = (void *)__cb_client_window_rotate_callback; wl_egl_window->get_rotation_capability = (void *) __cb_client_window_get_rotation_capability; + wl_egl_window->set_frontbuffer_callback = (void *) + __cb_client_window_set_frontbuffer_mode; /* tdm_vblank object decide to be maintained every tpl_wayland_egl_surface for the case where the several surfaces is created in one display connection. */ @@ -1095,6 +1101,8 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou return surface->frontbuffer; } else surface->frontbuffer = NULL; + } else { + surface->frontbuffer = NULL; } tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue, @@ -1397,6 +1405,19 @@ __cb_client_window_get_rotation_capability(struct wl_egl_window *wl_egl_window, return rotation_capability; } +static void +__cb_client_window_set_frontbuffer_mode(struct wl_egl_window *wl_egl_window, + void *private, int set) +{ + TPL_ASSERT(private); + TPL_ASSERT(wl_egl_window); + tpl_surface_t *surface = (tpl_surface_t *)private; + + if (set) + surface->is_frontbuffer_mode = TPL_TRUE; + else + surface->is_frontbuffer_mode = TPL_FALSE; +} void __cb_resistry_global_callback(void *data, struct wl_registry *wl_registry, -- 2.7.4