From 79cca758391b55e4ca6a8c73b661ac11a261c327 Mon Sep 17 00:00:00 2001 From: MinJeong Kim Date: Tue, 21 Apr 2015 22:01:46 +0900 Subject: [PATCH] Add wl_display_roundtrip to wait for being done pending job by server Change-Id: Iacc372c96633c69c9af97bfe93ea2fec73a1ccf0 --- .../engines/wayland/ecore_evas_wayland_shm.c | 1 + .../engines/wayland_shm/Evas_Engine_Wayland_Shm.h | 1 + src/modules/evas/engines/wayland_shm/evas_engine.c | 10 +++++---- src/modules/evas/engines/wayland_shm/evas_engine.h | 5 +++-- src/modules/evas/engines/wayland_shm/evas_outbuf.c | 4 ++-- src/modules/evas/engines/wayland_shm/evas_shm.c | 24 ++++++++++++++++++++-- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c index 9355e50..28b08de 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c @@ -207,6 +207,7 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent, if ((einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas))) { einfo->info.wl_shm = ecore_wl_shm_get(); + einfo->info.wl_display = ecore_wl_display_get(); einfo->info.destination_alpha = EINA_TRUE; einfo->info.rotation = ee->rotation; einfo->info.wl_surface = ecore_wl_window_surface_create(wdata->win); diff --git a/src/modules/evas/engines/wayland_shm/Evas_Engine_Wayland_Shm.h b/src/modules/evas/engines/wayland_shm/Evas_Engine_Wayland_Shm.h index b1cb310..1584284 100644 --- a/src/modules/evas/engines/wayland_shm/Evas_Engine_Wayland_Shm.h +++ b/src/modules/evas/engines/wayland_shm/Evas_Engine_Wayland_Shm.h @@ -13,6 +13,7 @@ struct _Evas_Engine_Info_Wayland_Shm struct { /* the wayland shm object used to create new shm pool */ + struct wl_display *wl_display; struct wl_shm *wl_shm; struct wl_surface *wl_surface; diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.c b/src/modules/evas/engines/wayland_shm/evas_engine.c index ff7486b..0a2bfc4 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.c +++ b/src/modules/evas/engines/wayland_shm/evas_engine.c @@ -23,7 +23,7 @@ struct _Render_Engine /* LOCAL FUNCTIONS */ Render_Engine * -_render_engine_swapbuf_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface) +_render_engine_swapbuf_setup(int w, int h, unsigned int rotation, unsigned int depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface, struct wl_display *display) { Render_Engine *re; Outbuf *ob; @@ -33,7 +33,7 @@ _render_engine_swapbuf_setup(int w, int h, unsigned int rotation, unsigned int d /* try to allocate space for new render engine */ if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL; - ob = _evas_outbuf_setup(w, h, rotation, depth, alpha, shm, surface); + ob = _evas_outbuf_setup(w, h, rotation, depth, alpha, shm, surface, display); if (!ob) goto err; if (!evas_render_engine_software_generic_init(&re->generic, ob, @@ -131,7 +131,8 @@ eng_setup(Evas *eo_evas, void *info) einfo->info.depth, einfo->info.destination_alpha, einfo->info.wl_shm, - einfo->info.wl_surface); + einfo->info.wl_surface, + einfo->info.wl_display); if (re) re->generic.ob->info = einfo; @@ -146,7 +147,8 @@ eng_setup(Evas *eo_evas, void *info) einfo->info.rotation, einfo->info.depth, einfo->info.destination_alpha, einfo->info.wl_shm, - einfo->info.wl_surface); + einfo->info.wl_surface, + einfo->info.wl_display); if (ob) { ob->info = einfo; diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.h b/src/modules/evas/engines/wayland_shm/evas_engine.h index c98fb0b..6a597b6 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.h +++ b/src/modules/evas/engines/wayland_shm/evas_engine.h @@ -75,6 +75,7 @@ struct _Shm_Surface { struct wl_shm *shm; struct wl_surface *surface; + struct wl_display *display; struct wl_callback *frame_cb; uint32_t flags; int w, h; @@ -119,14 +120,14 @@ struct _Outbuf } priv; }; -Shm_Surface *_evas_shm_surface_create(struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha); +Shm_Surface *_evas_shm_surface_create(struct wl_shm *shm, struct wl_surface *surface, struct wl_display *display, int w, int h, int num_buff, Eina_Bool alpha); void _evas_shm_surface_destroy(Shm_Surface *surface); void _evas_shm_surface_reconfigure(Shm_Surface *surface, int dx, int dy, int w, int h, int num_buff, uint32_t flags); void _evas_shm_surface_swap(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int count); void *_evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h); void _evas_shm_surface_redraw(Shm_Surface *surface); -Outbuf *_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface); +Outbuf *_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface, struct wl_display *display); void _evas_outbuf_free(Outbuf *ob); void _evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode); void _evas_outbuf_idle_flush(Outbuf *ob); diff --git a/src/modules/evas/engines/wayland_shm/evas_outbuf.c b/src/modules/evas/engines/wayland_shm/evas_outbuf.c index 5725663..44df4f9 100644 --- a/src/modules/evas/engines/wayland_shm/evas_outbuf.c +++ b/src/modules/evas/engines/wayland_shm/evas_outbuf.c @@ -10,7 +10,7 @@ #define BLUE_MASK 0x0000ff Outbuf * -_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface) +_evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, struct wl_shm *shm, struct wl_surface *surface, struct wl_display *display) { Outbuf *ob = NULL; char *num; @@ -44,7 +44,7 @@ _evas_outbuf_setup(int w, int h, int rot, Outbuf_Depth depth, Eina_Bool alpha, s /* try to create the outbuf surface */ if (!(ob->surface = - _evas_shm_surface_create(shm, surface, w, h, ob->num_buff, alpha))) + _evas_shm_surface_create(shm, surface, display, w, h, ob->num_buff, alpha))) goto surf_err; eina_array_step_set(&ob->priv.onebuf_regions, sizeof(Eina_Array), 8); diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index 9c16702..3cade9a 100644 --- a/src/modules/evas/engines/wayland_shm/evas_shm.c +++ b/src/modules/evas/engines/wayland_shm/evas_shm.c @@ -308,7 +308,7 @@ _shm_leaf_release(Shm_Leaf *leaf) } Shm_Surface * -_evas_shm_surface_create(struct wl_shm *shm, struct wl_surface *surface, int w, int h, int num_buff, Eina_Bool alpha) +_evas_shm_surface_create(struct wl_shm *shm, struct wl_surface *surface, struct wl_display *display, int w, int h, int num_buff, Eina_Bool alpha) { Shm_Surface *surf; int i = 0; @@ -323,6 +323,7 @@ _evas_shm_surface_create(struct wl_shm *shm, struct wl_surface *surface, int w, surf->h = h; surf->shm = shm; surf->surface = surface; + surf->display = display; surf->num_buff = num_buff; surf->alpha = alpha; surf->flags = 0; @@ -477,8 +478,27 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h) if (!leaf) { - /* WRN("All buffers held by server"); */ + if (surface->display) + { + if (wl_display_roundtrip(surface->display) != -1) + { + for (i = 0; i < surface->num_buff; i++) + { + if (surface->leaf[i].busy) continue; + if ((!leaf) || (leaf->valid)) + { + leaf = &surface->leaf[i]; + break; + } + } + } + + } + if (!leaf) + { + /* WRN("All buffers held by server"); */ return NULL; + } } /* DBG("Leaf Data Get %d", (int)(leaf - &surface->leaf[0])); */ -- 2.7.4