tpl_wl_egl_thread: Fixed a bug related to frontbuffer mode. 88/198888/2
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 29 Jan 2019 06:59:17 +0000 (15:59 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 31 Jan 2019 00:38:01 +0000 (09:38 +0900)
Change-Id: I160d5c6002fef08d9e66e6b030dba87ab7d1016f
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index faf8d13..40f1f28 100644 (file)
@@ -32,6 +32,7 @@ struct _tpl_wayland_egl_surface {
        tbm_surface_queue_h tbm_queue;
        tpl_bool_t is_activated;
        tpl_bool_t reset; /* TRUE if queue reseted by external  */
+       tpl_bool_t need_to_enqueue;
 };
 
 static tpl_result_t
@@ -374,6 +375,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface)
        wayland_egl_surface->twe_surface = twe_surface;
        wayland_egl_surface->tbm_queue = tbm_queue;
        wayland_egl_surface->is_activated = TPL_FALSE;
+       wayland_egl_surface->need_to_enqueue = TPL_TRUE;
 
        surface->width = tbm_surface_queue_get_width(tbm_queue);
        surface->height = tbm_surface_queue_get_height(tbm_queue);
@@ -537,21 +539,26 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface,
         * 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_T("WL_EGL",
-                                 "[ENQ_SKIP][F] Client already uses frontbuffer(%p)",
-                                 surface->frontbuffer);
-
+       if (surface->is_frontbuffer_mode) {
                /* The first buffer to be activated in frontbuffer mode must be
                 * committed. Subsequence frames do not need to be committed because
                 * the buffer is already displayed.
                 */
-               if (!twe_surface_check_commit_needed(wayland_egl_surface->twe_surface,
-                                                                                        surface->frontbuffer)) {
+
+               if (!wayland_egl_surface->need_to_enqueue ||
+                       (surface->frontbuffer == tbm_surface &&
+                               !twe_surface_check_commit_needed(wayland_egl_surface->twe_surface,
+                                                                                                surface->frontbuffer))) {
+                       TPL_LOG_T("WL_EGL",
+                                         "[ENQ_SKIP][F] Client already uses frontbuffer(%p)",
+                                         surface->frontbuffer);
                        TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name);
                        TPL_OBJECT_UNLOCK(wayland_egl_surface);
                        return TPL_ERROR_NONE;
                }
+
+               if (surface->frontbuffer == tbm_surface)
+                       wayland_egl_surface->need_to_enqueue = TPL_FALSE;
        }
 
        if (sync_fence != -1) {
@@ -724,8 +731,10 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                        if (lock_ret == TPL_ERROR_NONE)
                                twe_display_unlock(wayland_egl_display->twe_display);
                        return surface->frontbuffer;
-               } else
+               } else {
                        surface->frontbuffer = NULL;
+                       wayland_egl_surface->need_to_enqueue = TPL_TRUE;
+               }
        } else {
                surface->frontbuffer = NULL;
        }