tpl_wayland_egl_thread: Modified twe_surface_destroy to unref the tbm_surface in... 38/149838/4
authorjoonbum.ko <joonbum.ko@samsung.com>
Wed, 13 Sep 2017 05:29:25 +0000 (14:29 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 15 Sep 2017 11:40:28 +0000 (11:40 +0000)
 - When eglSurfaceDestroy is called on the main thread,
 the function twe_surface_del() waits for the worker thread
 to finish rendering the buffer no longer

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

index 5912b91..4fc7976 100644 (file)
@@ -1043,7 +1043,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
                if (surf_source->in_use_buffers) {
                        TPL_OBJECT_LOCK(&surf_source->obj);
                        __tpl_list_push_back(surf_source->in_use_buffers,
-                                                                (void *)buf_info);
+                                                                (void *)tbm_surface);
                        TPL_OBJECT_UNLOCK(&surf_source->obj);
                }
 
@@ -1106,7 +1106,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source,
        if (surf_source->in_use_buffers) {
                TPL_OBJECT_LOCK(&surf_source->obj);
                __tpl_list_push_back(surf_source->in_use_buffers,
-                                                        (void *)buf_info);
+                                                        (void *)tbm_surface);
                TPL_OBJECT_UNLOCK(&surf_source->obj);
        }
 
@@ -1144,7 +1144,7 @@ _twe_surface_cancel_dequeued_buffer(twe_wl_surf_source *surf_source,
                TPL_OBJECT_LOCK(&surf_source->obj);
                /* Stop tracking of this canceled tbm_surface */
                __tpl_list_remove_data(surf_source->in_use_buffers,
-                                                          (void *)buf_info, TPL_FIRST, NULL);
+                                                          (void *)tbm_surface, TPL_FIRST, NULL);
                TPL_OBJECT_UNLOCK(&surf_source->obj);
        }
 }
@@ -1323,7 +1323,7 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source,
                __tpl_list_push_back(surf_source->committed_buffers, tbm_surface);
                /* Stop tracking of this released tbm_surface. */
                __tpl_list_remove_data(surf_source->in_use_buffers,
-                                                          (void *)buf_info, TPL_FIRST, NULL);
+                                                          (void *)tbm_surface, TPL_FIRST, NULL);
                TPL_OBJECT_UNLOCK(&surf_source->obj);
        }
 }
@@ -1670,12 +1670,14 @@ twe_surface_del(twe_surface_h twe_surface)
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
-       /* Should be waited until all in_use_buffers has been retrieved. */
+       TPL_OBJECT_LOCK(&surf_source->obj);
        while (!__tpl_list_is_empty(surf_source->in_use_buffers)) {
-               sched_yield();
+               tbm_surface_h tbm_surface = (tbm_surface_h)__tpl_list_pop_front(
+                                                                                       surf_source->in_use_buffers,
+                                                                                       NULL);
+               tbm_surface_internal_unref(tbm_surface);
        }
 
-       TPL_OBJECT_LOCK(&surf_source->obj);
        __tpl_list_free(surf_source->in_use_buffers, NULL);
        TPL_OBJECT_UNLOCK(&surf_source->obj);