From 88044dcc720f15523b76e0b05b9682d9308610ea Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 14 Aug 2017 15:12:23 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Added a prepared flag to match prepare and read/cancel pairs. - Some problem occurs when gsource calls several prepare functions in one loop sequence. - prepared flag can prevent that problem. Change-Id: Idf715b43af37fab527b996c8c52d62f1b28367ee Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index bd2f7ad..2e09c08 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -54,6 +54,7 @@ struct _twe_wl_disp_source { struct wl_event_queue *ev_queue; struct wayland_tbm_client *wl_tbm_client; struct tizen_surface_shm *tss; /* used for surface buffer_flush */ + tpl_bool_t prepared; twe_thread *thread; tpl_object_t obj; /* TODO : surface list */ @@ -321,12 +322,18 @@ _twe_thread_wl_disp_prepare(GSource *source, gint *time) { twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source; + /* If disp_source is already prepared, do nothing in this function. */ + if (disp_source->prepared) + return FALSE; + while (wl_display_prepare_read_queue(disp_source->disp, disp_source->ev_queue) != 0) { if (wl_display_dispatch_queue_pending(disp_source->disp, disp_source->ev_queue) == -1) { _twe_display_print_err(disp_source, "dispatch_queue_pending"); } + + disp_source->prepared = TPL_TRUE; } wl_display_flush(disp_source->disp); @@ -339,22 +346,25 @@ static gboolean _twe_thread_wl_disp_check(GSource *source) { twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source; + gboolean ret = FALSE; if (g_source_is_destroyed(source)) { TPL_ERR("display source(%p) already destroyed.", source); - return FALSE; + return ret; } if (disp_source->gfd.revents & G_IO_IN) { if (wl_display_read_events(disp_source->disp) == -1) _twe_display_print_err(disp_source, "read_event."); - - return TRUE; + ret = TRUE; } else { wl_display_cancel_read(disp_source->disp); + ret = FALSE; } - return FALSE; + disp_source->prepared = TPL_FALSE; + + return ret; } static gboolean @@ -387,6 +397,10 @@ _twe_thread_wl_disp_finalize(GSource *source) twe_wl_disp_source *disp_source = (twe_wl_disp_source *)source; TPL_OBJECT_LOCK(&disp_source->obj); + /* If disp_source is in prepared state, cancel it */ + if (disp_source->prepared) + wl_display_cancel_read(disp_source->disp); + if (wl_display_dispatch_queue_pending(disp_source->disp, disp_source->ev_queue) == -1) { _twe_display_print_err(disp_source, "dispatch_queue_pending"); @@ -562,6 +576,7 @@ twe_display_add(twe_thread* thread, struct wl_display *display) source->disp = display; source->ev_queue = ev_queue; source->wl_tbm_client = wl_tbm_client; + source->prepared = TPL_FALSE; source->gfd.fd = wl_display_get_fd(display); source->gfd.events = G_IO_IN | G_IO_ERR; source->gfd.revents = 0; @@ -863,6 +878,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, surf_source->latest_transform = wl_egl_window->transform; buf_info->rotated = TPL_TRUE; } + buf_info->transform = wl_egl_window->transform; buf_info->dx = wl_egl_window->dx; buf_info->dy = wl_egl_window->dy; -- 2.7.4