tbm: Added reset callback for validate checking 37/210637/2
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 23 Jul 2019 08:15:46 +0000 (17:15 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 7 Aug 2019 04:46:12 +0000 (13:46 +0900)
Change-Id: If17acc9a41c589dadb4d15800d799380334c9ee7
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_tbm.c

index 33dd453..43dee96 100644 (file)
@@ -37,6 +37,8 @@ struct _tpl_tbm_surface {
 
        tpl_bool_t need_worker_clear;
        int present_mode;
+
+       tpl_bool_t need_reset;
 };
 
 struct _tpl_tbm_buffer {
@@ -429,6 +431,22 @@ __tpl_tbm_surface_destroy_swapchain(tpl_surface_t *surface)
        return TPL_ERROR_NONE;
 }
 
+static void
+__cb_tbm_queue_reset_callback(tbm_surface_queue_h tbm_queue,
+                                                         void *data)
+{
+       tpl_tbm_surface_t *tpl_tbm_surface = (tpl_tbm_surface_t *)data;
+
+       if (!tpl_tbm_surface) {
+               TPL_ERR("Invalid parameter. tpl_tbm_surface(%p)", tpl_tbm_surface);
+               return;
+       }
+
+       TPL_LOG_B("TBM", "tbm_queue(%p) has been reset!", tbm_queue);
+
+       tpl_tbm_surface->need_reset = TPL_TRUE;
+}
+
 static tpl_result_t
 __tpl_tbm_surface_init(tpl_surface_t *surface)
 {
@@ -443,6 +461,8 @@ __tpl_tbm_surface_init(tpl_surface_t *surface)
 
        surface->backend.data = (void *)tpl_tbm_surface;
 
+       tpl_tbm_surface->need_reset = TPL_FALSE;
+
        if (surface->type == TPL_SURFACE_TYPE_WINDOW) {
                if (__tpl_tbm_display_get_window_info(surface->display,
                                                                                          surface->native_handle, &surface->width,
@@ -456,6 +476,11 @@ __tpl_tbm_surface_init(tpl_surface_t *surface)
                                                                                 __tpl_tbm_surface_queue_notify_cb,
                                                                                 surface);
 
+               /* Set reset_callback to tbm_queue */
+               tbm_surface_queue_add_reset_cb((tbm_surface_queue_h)surface->native_handle,
+                                                                        __cb_tbm_queue_reset_callback,
+                                                                        (void *)tpl_tbm_surface);
+
                TPL_LOG_B("TBM", "[INIT] tpl_surface(%p) tpl_tbm_surface_t(%p) tbm_surface_queue(%p)",
                                  surface, tpl_tbm_surface, surface->native_handle);
 
@@ -633,9 +658,12 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface,
 static tpl_bool_t
 __tpl_tbm_surface_validate(tpl_surface_t *surface)
 {
-       TPL_IGNORE(surface);
+       tpl_tbm_surface_t *tpl_tbm_surface = (tpl_tbm_surface_t *)surface->backend.data;
+       tpl_bool_t ret = TPL_TRUE;
+
+       ret = !tpl_tbm_surface->need_reset;
 
-       return TPL_TRUE;
+       return ret;
 }
 
 static tbm_surface_h
@@ -646,6 +674,7 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
        tbm_surface_queue_h tbm_queue = NULL;
        tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE;
        tpl_tbm_buffer_t *tpl_tbm_buffer = NULL;
+       tpl_tbm_surface_t *tpl_tbm_surface = (tpl_tbm_surface_t *)surface->backend.data;
 
        TPL_ASSERT(surface);
        TPL_ASSERT(surface->native_handle);
@@ -684,6 +713,8 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
        /* It will be dec when before tbm_surface_queue_enqueue called */
        tbm_surface_internal_ref(tbm_surface);
 
+       tpl_tbm_surface->need_reset = TPL_FALSE;
+
        TPL_LOG_B("TBM", "[DEQ] tpl_surface(%p) tbm_queue(%p) tbm_surface(%p) bo(%d)",
                          surface, tbm_queue, tbm_surface,
                          tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));