From a347a47e7502542115412efc4f2ddcd78c610193 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 20 Oct 2015 16:41:28 -0400 Subject: [PATCH] ee-wayland: use frame callbacks exclusively to determine render timing when running in a wayland compositor, the ideal mode of operation is to only prepare/send frames when the compositor has finished with the previous frame to achieve this, manual rendering can be toggled upon creating and completing a frame callback, ensuring that a canvas never has multiple pending buffers at any given time fix T2784 --- .../engines/wayland/ecore_evas_wayland_common.c | 27 ++++++++++++++-------- .../engines/wayland/ecore_evas_wayland_egl.c | 3 +++ .../engines/wayland/ecore_evas_wayland_private.h | 1 + .../engines/wayland/ecore_evas_wayland_shm.c | 3 +++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c index 41b0112..2ba972f 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c @@ -1263,12 +1263,13 @@ _ecore_evas_wl_common_pre_render(Ecore_Evas *ee) static void _anim_cb_animate(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED) { - Ecore_Evas_Engine_Wl_Data *wdata = data; - - if ((wdata->anim_callback) && (callback != wdata->anim_callback)) return; + Ecore_Evas *ee = data; + Ecore_Evas_Engine_Wl_Data *wdata; + wdata = ee->engine.data; wl_callback_destroy(callback); wdata->anim_callback = NULL; + ecore_evas_manual_render_set(ee, 0); } static const struct wl_callback_listener _anim_listener = @@ -1276,6 +1277,18 @@ static const struct wl_callback_listener _anim_listener = _anim_cb_animate }; +void +_ecore_evas_wl_common_render_pre(void *data, Evas *evas EINA_UNUSED, void *event EINA_UNUSED) +{ + Ecore_Evas *ee = data; + Ecore_Evas_Engine_Wl_Data *wdata; + + wdata = ee->engine.data; + wdata->anim_callback = wl_surface_frame(ecore_wl_window_surface_get(wdata->win)); + wl_callback_add_listener(wdata->anim_callback, &_anim_listener, ee); + ecore_evas_manual_render_set(ee, 1); +} + void _ecore_evas_wl_common_render_updates(void *data, Evas *evas EINA_UNUSED, void *event) { @@ -1286,13 +1299,7 @@ _ecore_evas_wl_common_render_updates(void *data, Evas *evas EINA_UNUSED, void *e ee->in_async_render = EINA_FALSE; - if (_ecore_evas_wl_common_render_updates_process(ee, ev->updated_area)) - { - Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data; - - wdata->anim_callback = wl_surface_frame(ecore_wl_window_surface_get(wdata->win)); - wl_callback_add_listener(wdata->anim_callback, &_anim_listener, wdata); - } + _ecore_evas_wl_common_render_updates_process(ee, ev->updated_area); if (ee->delayed.alpha_changed) { diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c index 367546d..4871283 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c @@ -227,6 +227,9 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent, evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST, _ecore_evas_wl_common_render_updates, ee); + evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_PRE, + _ecore_evas_wl_common_render_pre, ee); + /* FIXME: This needs to be set based on theme & scale */ if (ee->prop.draw_frame) evas_output_framespace_set(ee->evas, fx, fy, fw, fh); diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h index 48e9a3f..7929ab3 100644 --- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h +++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_private.h @@ -74,6 +74,7 @@ void _ecore_evas_wl_common_post_render(Ecore_Evas *ee); int _ecore_evas_wl_common_render(Ecore_Evas *ee); void _ecore_evas_wl_common_screen_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h); void _ecore_evas_wl_common_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int *ydpi); +void _ecore_evas_wl_common_render_pre(void *data, Evas *evas EINA_UNUSED, void *event); void _ecore_evas_wl_common_render_updates(void *data, Evas *evas, void *event); void _ecore_evas_wl_common_rotation_set(Ecore_Evas *ee, int rotation, int resize); void _ecore_evas_wl_common_borderless_set(Ecore_Evas *ee, Eina_Bool on); 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 4d3af44..530b3ce 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 @@ -222,6 +222,9 @@ ecore_evas_wayland_shm_new_internal(const char *disp_name, unsigned int parent, evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST, _ecore_evas_wl_common_render_updates, ee); + evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_PRE, + _ecore_evas_wl_common_render_pre, ee); + /* FIXME: This needs to be set based on theme & scale */ if (ee->prop.draw_frame) evas_output_framespace_set(ee->evas, fx, fy, fw, fh); -- 2.7.4