Merge changes Ibac91ed8,I7e6a6891,I779718fd into tizen
[platform/core/uifw/libtpl-egl.git] / src / tpl_wl_egl_thread.c
index 113a8a7..13b7404 100755 (executable)
@@ -152,6 +152,7 @@ struct _tpl_wl_egl_surface {
        tpl_bool_t                    vblank_done;
        tpl_bool_t                    set_serial_is_used;
        tpl_bool_t                    initialized_in_thread;
+       tpl_bool_t                    frontbuffer_activated;
 
        /* To make sure that tpl_gsource has been successfully finalized. */
        tpl_bool_t                    gsource_finalized;
@@ -1799,6 +1800,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface)
        wl_egl_surface->set_serial_is_used     = TPL_FALSE;
        wl_egl_surface->gsource_finalized      = TPL_FALSE;
        wl_egl_surface->initialized_in_thread  = TPL_FALSE;
+       wl_egl_surface->frontbuffer_activated  = TPL_FALSE;
 
        wl_egl_surface->latest_transform       = -1;
        wl_egl_surface->render_done_cnt        = 0;
@@ -2357,6 +2359,15 @@ __tpl_wl_egl_surface_get_size(tpl_surface_t *surface, int *width, int *height)
                *height = tbm_surface_queue_get_height(wl_egl_surface->tbm_queue);
 }
 
+static tpl_bool_t
+__tpl_wl_egl_surface_fence_sync_is_available(tpl_surface_t *surface)
+{
+       tpl_wl_egl_surface_t *wl_egl_surface =
+               (tpl_wl_egl_surface_t *)surface->backend.data;
+
+       return !wl_egl_surface->frontbuffer_activated;
+}
+
 #define CAN_DEQUEUE_TIMEOUT_MS 10000
 
 tpl_result_t
@@ -2650,6 +2661,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                        wl_egl_surface->reset) {
                        surface->frontbuffer = NULL;
                        wl_egl_surface->need_to_enqueue = TPL_TRUE;
+                       wl_egl_surface->frontbuffer_activated = TPL_FALSE;
                        TPL_INFO("[FRONTBUFFER RENDERING STOP]",
                                         "wl_egl_surface(%p) wl_egl_window(%p)",
                                         wl_egl_surface, wl_egl_surface->wl_egl_window);
@@ -2661,6 +2673,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                        TRACE_ASYNC_BEGIN((intptr_t)surface->frontbuffer,
                                                          "[DEQ]~[ENQ] BO_NAME:%d",
                                                          bo_name);
+                       wl_egl_surface->frontbuffer_activated = TPL_TRUE;
                        tpl_gmutex_unlock(&wl_egl_display->wl_event_mutex);
                        return surface->frontbuffer;
                }
@@ -3643,6 +3656,8 @@ __tpl_surface_init_backend_wl_egl_thread(tpl_surface_backend_t *backend)
                __tpl_wl_egl_surface_set_post_interval;
        backend->get_size =
                __tpl_wl_egl_surface_get_size;
+       backend->fence_sync_is_available =
+               __tpl_wl_egl_surface_fence_sync_is_available;
 }
 
 static void