struct tizen_surface_shm_flusher *tss_flusher;
tbm_surface_queue_h tbm_queue;
twe_wl_disp_source *disp_source;
+ twe_del_source *surf_del_source;
};
struct _twe_wl_buffer_info {
{
twe_wl_surf_source *surf_source = (twe_wl_surf_source *)source;
- __tpl_object_fini(&surf_source->obj);
+ TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
+ source, surf_source->event_fd);
g_source_remove_unix_fd(source, surf_source->tag);
close(surf_source->event_fd);
+ surf_source->event_fd = -1;
+
+ __tpl_object_fini(&surf_source->obj);
- TPL_LOG_T("WL_EGL", "gsource(%p) event_fd(%d)",
- source, surf_source->event_fd);
return;
}
return source->tbm_queue;
}
+static void
+_twe_thread_wl_surf_source_destroy(void *source)
+{
+ twe_wl_surf_source *surf_source = (twe_wl_surf_source *)source;
+ twe_wl_disp_source *disp_source = NULL;
+ gboolean is_destroyed = FALSE;
+
+ if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+ TPL_ERR("twe_surface(%p) is already destroyed.", surf_source);
+ return;
+ }
+
+ disp_source = surf_source->disp_source;
+ if (!disp_source ||
+ (is_destroyed = g_source_is_destroyed(&disp_source->gsource))) {
+ TPL_ERR("twe_display(%p) is invalid. | is_destroyed(%s)",
+ disp_source, (is_destroyed ? "TRUE" : "FALSE"));
+ return;
+ }
+
+ g_mutex_lock(&_twe_ctx->thread_mutex);
+
+ TPL_OBJECT_LOCK(&disp_source->obj);
+
+ while (!__tpl_list_is_empty(surf_source->in_use_buffers)) {
+ 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_list_free(surf_source->in_use_buffers, NULL);
+
+ surf_source->in_use_buffers = NULL;
+
+ 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;
+ }
+
+ _twe_surface_buffer_flusher_fini(surf_source);
+
+ if (surf_source->tbm_queue) {
+ tbm_surface_queue_destroy(surf_source->tbm_queue);
+ surf_source->tbm_queue = NULL;
+ }
+
+ if (surf_source->vblank) {
+ TPL_LOG_T("WL_EGL", "[VBLANK FINI] twe_wl_surf_source(%p) vblank(%p)",
+ surf_source, surf_source->vblank);
+ tdm_client_vblank_destroy(surf_source->vblank);
+ }
+
+ surf_source->cb_data = NULL;
+ surf_source->rotate_cb = NULL;
+
+ if (surf_source->wl_egl_window) {
+ TPL_LOG_T("WL_EGL", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)",
+ surf_source, surf_source->wl_egl_window, surf_source->surf);
+ surf_source->wl_egl_window->private = NULL;
+ surf_source->wl_egl_window = NULL;
+ surf_source->surf = NULL;
+ } else {
+ TPL_LOG_T("WL_EGL", "twe_surface(%p) native window is already destroyed");
+ }
+
+ TPL_OBJECT_UNLOCK(&disp_source->obj);
+
+ g_source_destroy(&surf_source->gsource);
+ g_source_unref(&surf_source->gsource);
+
+ g_cond_signal(&_twe_ctx->thread_cond);
+ g_mutex_unlock(&_twe_ctx->thread_mutex);
+}
twe_surface_h
twe_surface_add(twe_thread* thread,
wl_egl_window->get_rotation_capability = (void *)
__cb_get_rotation_capability;
+ source->surf_del_source = _twe_del_source_init(ctx, source);
+ if (source->surf_del_source) {
+ source->surf_del_source->destroy_target_source_func
+ = _twe_thread_wl_surf_source_destroy;
+ }
+
g_source_set_callback(&source->gsource, NULL, surface, NULL);
g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
{
twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
twe_wl_disp_source *disp_source = NULL;
+ twe_del_source *surf_del_source = NULL;
gboolean is_destroyed = FALSE;
if (!surf_source ||
return TPL_ERROR_INVALID_PARAMETER;
}
- TPL_OBJECT_LOCK(&surf_source->obj);
- while (!__tpl_list_is_empty(surf_source->in_use_buffers)) {
- 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_list_free(surf_source->in_use_buffers, NULL);
- TPL_OBJECT_UNLOCK(&surf_source->obj);
-
- surf_source->in_use_buffers = NULL;
-
- TPL_OBJECT_LOCK(&disp_source->obj);
- if (surf_source->committed_buffers) {
- TPL_OBJECT_LOCK(&surf_source->obj);
- 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_LOG_T("WL_EGL", "twe_surface(%p) will be destroyed in thread",
+ twe_surface);
+ surf_del_source = surf_source->surf_del_source;
- __tpl_list_free(surf_source->committed_buffers, NULL);
- surf_source->committed_buffers = NULL;
- TPL_OBJECT_UNLOCK(&surf_source->obj);
- }
-
- _twe_surface_buffer_flusher_fini(surf_source);
-
- if (surf_source->tbm_queue) {
- tbm_surface_queue_destroy(surf_source->tbm_queue);
- surf_source->tbm_queue = NULL;
- }
-
- if (surf_source->vblank) {
- TPL_LOG_T("WL_EGL", "[VBLANK FINI] twe_wl_surf_source(%p) vblank(%p)",
- surf_source, surf_source->vblank);
- tdm_client_vblank_destroy(surf_source->vblank);
- }
-
- /* TODO : surf_source will be removed from surfaces list in disp_source */
-
- surf_source->cb_data = NULL;
- surf_source->rotate_cb = NULL;
-
- if (surf_source->wl_egl_window) {
- TPL_LOG_T("WL_EGL", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)",
- surf_source, surf_source->wl_egl_window, surf_source->surf);
- surf_source->wl_egl_window->private = NULL;
- surf_source->wl_egl_window = NULL;
- surf_source->surf = NULL;
- } else {
- TPL_LOG_T("WL_EGL", "twe_surface(%p) native window is already destroyed");
- }
-
- TPL_OBJECT_UNLOCK(&disp_source->obj);
+ g_mutex_lock(&_twe_ctx->thread_mutex);
+ _twe_thread_del_source_trigger(surf_del_source);
+ g_cond_wait(&_twe_ctx->thread_cond,
+ &_twe_ctx->thread_mutex);
+ g_mutex_unlock(&_twe_ctx->thread_mutex);
- g_source_destroy(&surf_source->gsource);
- g_source_unref(&surf_source->gsource);
+ _twe_del_source_fini(surf_del_source);
return TPL_ERROR_NONE;
}