tpl_wl_egl_thread: Changed the procedure to dequeue buffer. 38/137338/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 4 Jul 2017 05:28:00 +0000 (14:28 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 19 Jul 2017 05:40:18 +0000 (14:40 +0900)
Change-Id: I5bdc7988e84dc25fb1cb479bfacc55f6d6f4b4fa
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 7c99b54..04ed3ee 100644 (file)
@@ -605,6 +605,17 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
        if (sync_fence)
                *sync_fence = -1;
 
+       TPL_OBJECT_UNLOCK(surface);
+       while (!tbm_surface_queue_can_dequeue(wayland_egl_surface->tbm_queue, 0)) {
+               /* waiting for dequeueable */
+       }
+       TPL_OBJECT_LOCK(surface);
+
+       /* After the can dequeue state, call twe_display_lock to prevent other
+        * events from being processed in wayland_egl_thread
+        * during below dequeue procedure. */
+       lock_ret = twe_display_lock(wayland_egl_display->twe_display);
+
        /* wayland client can check their states (ACTIVATED or DEACTIVATED) with
         * below function [wayland_tbm_client_queue_check_activate()].
         * This function has to be called before tbm_surface_queue_dequeue()
@@ -636,6 +647,8 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                                                          "[DEQ]~[ENQ] BO_NAME:%d",
                                                          tbm_bo_export(tbm_surface_internal_get_bo(
                                                                                                surface->frontbuffer, 0)));
+                       if (lock_ret == TPL_ERROR_NONE)
+                               twe_display_unlock(wayland_egl_display->twe_display);
                        return surface->frontbuffer;
                } else
                        surface->frontbuffer = NULL;
@@ -643,20 +656,13 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                surface->frontbuffer = NULL;
        }
 
-       TPL_OBJECT_UNLOCK(surface);
-       while (!tbm_surface_queue_can_dequeue(wayland_egl_surface->tbm_queue, 0)) {
-
-       }
-       TPL_OBJECT_LOCK(surface);
-
-       lock_ret = twe_display_lock(wayland_egl_display->twe_display);
-
        tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue,
                                                                                &tbm_surface);
        if (!tbm_surface) {
                TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d",
                                tsq_err);
-               if (lock_ret) twe_display_unlock(wayland_egl_display->twe_display);
+               if (lock_ret == TPL_ERROR_NONE)
+                       twe_display_unlock(wayland_egl_display->twe_display);
                return NULL;
        }