tpl_wayland_egl_thread: Added a list to track committed buffers. 02/135002/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 11 May 2017 07:28:17 +0000 (16:28 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 21 Jun 2017 07:04:26 +0000 (16:04 +0900)
 - This list exists to do unref tbm_surfaces, which were committed but not released yet, without waiting for further events(after surface destroyed)
  by emptying at surface_finialize.

Change-Id: Ieece90193e678ab9afce2279b9d6e04c0443723f
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 4229b1e..661fb09 100644 (file)
@@ -59,6 +59,7 @@ struct _twe_wl_surf_source {
        int rotation;
        tpl_bool_t rotation_capability;
        tpl_bool_t vblank_done;
+       tpl_list_t *committed_buffers;
        tdm_client_vblank *vblank;
        tbm_surface_queue_h tbm_queue;
        twe_wl_disp_source *disp_source;
@@ -541,6 +542,9 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source,
                else
                        TPL_ERR("Failed to tdm_client_vblank_wait. tdm_err(%d)", tdm_err);
        }
+
+       if (surf_source->committed_buffers)
+               __tpl_list_push_back(surf_source->committed_buffers, tbm_surface);
 }
 
 static void
@@ -608,14 +612,27 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer date)
 static void
 _twe_thread_wl_surface_finalize(GSource *source)
 {
-       twe_wl_surf_source *wl_surf_source = (twe_wl_surf_source *)source;
+       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)source;
+
+       if (surf_source->committed_buffers) {
+               while (!__tpl_list_is_empty(surf_source->committed_buffers)) {
+                       tbm_surface_h tbm_surface =
+                               (tbm_surface_h)__tpl_list_pop_front(
+                                               surf_source->committed_buffers,
+                                               NULL);
+                       tbm_surface_internal_unref(tbm_surface);
+               }
+
+               __tpl_list_free(surf_source->committed_buffers, NULL);
+               surf_source->committed_buffers = NULL;
+       }
 
-       g_source_remove_unix_fd(source, wl_surf_source->tag);
+       g_source_remove_unix_fd(source, surf_source->tag);
 
-       TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
-                         source, wl_surf_source->event_fd);
-       close(wl_surf_source->event_fd);
+       close(surf_source->event_fd);
 
+       TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
+                         source, surf_source->event_fd);
        return;
 }
 
@@ -781,6 +798,7 @@ twe_surface_add(twe_thread* thread,
        source->rotation_capability = TPL_FALSE;
        source->vblank = _twe_surface_create_vblank(_twe_ctx->tdm_client);
        source->vblank_done = TPL_TRUE;
+       source->committed_buffers = __tpl_list_alloc();
 
        wl_egl_window->private = (void *)source;
        wl_egl_window->resize_callback = (void *)__cb_resize_callback;
@@ -909,6 +927,12 @@ __cb_buffer_release_callback(void *data, struct wl_proxy *wl_buffer)
                        if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE)
                                TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err);
 
+                       if (surf_source->committed_buffers) {
+                               __tpl_list_remove_data(surf_source->committed_buffers,
+                                                                          (void *)tbm_surface,
+                                                                          TPL_FIRST, NULL);
+                       }
+
                        TPL_LOG_T("WL_EGL", "[REL] wl_buffer(%p) tbm_surface(%p) bo(%d)",
                                          buf_info->wl_buffer, tbm_surface,
                                          tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));