derekf pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=11d3bf7939fa2f2934efd0cf73172a3c6075f3af
commit 11d3bf7939fa2f2934efd0cf73172a3c6075f3af Author: Derek Foreman <der...@osg.samsung.com> Date: Mon Aug 14 17:44:13 2017 -0500 ecore_wl2: Add API ecore_wl2_window_commit() Abstract wl_surface commits in ecore_wl2_window. --- src/lib/ecore_wl2/Ecore_Wl2.h | 18 ++++++++++++++++++ src/lib/ecore_wl2/ecore_wl2_private.h | 3 +++ src/lib/ecore_wl2/ecore_wl2_window.c | 15 +++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 06e5c84ac7..1a558a2bdb 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -1873,6 +1873,24 @@ EAPI void ecore_wl2_offer_finish(Ecore_Wl2_Offer *offer); */ EAPI void ecore_wl2_session_recovery_disable(void); +/** + * Commit the surface of a wayland window. + * + * If flush is set this generates a wl_surface_commit(), otherwise it is + * expected that some other call in the very near future (such as + * eglSwapBuffers) will cause an implicit flush. + * + * A surface that has been commit will be in the "pending" state until + * the compositor tells us it's time to draw again via a frame callback. + * + * @surface surface to commit + * @flush EINA_TRUE if we need to flush immediately. + * + * @since 1.20 + */ +EAPI void ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush); + +/** # endif # undef EAPI diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 431d40880e..4ee29752e6 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -155,6 +155,7 @@ struct _Ecore_Wl2_Window const char *role; struct wl_surface *surface; + struct wl_callback *callback; struct www_surface *www_surface; struct zxdg_surface_v6 *zxdg_surface; struct zxdg_toplevel_v6 *zxdg_toplevel; @@ -199,6 +200,8 @@ struct _Ecore_Wl2_Window Eina_Bool focus_skip : 1; Eina_Bool floating : 1; + Eina_Bool commit_pending : 1; + struct { Eina_Bool configure : 1; diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 6ee7af6af8..422b330443 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -535,6 +535,7 @@ ecore_wl2_window_hide(Ecore_Wl2_Window *window) { wl_surface_attach(window->surface, NULL, 0, 0); wl_surface_commit(window->surface); + window->commit_pending = EINA_FALSE; } window->configure_serial = 0; @@ -1342,3 +1343,17 @@ ecore_wl2_window_aspect_set(Ecore_Wl2_Window *window, int w, int h, unsigned int if (window->display->wl.efl_hints && window->zxdg_toplevel) efl_hints_set_aspect(window->display->wl.efl_hints, window->zxdg_toplevel, w, h, aspect); } + +EAPI void ecore_wl2_window_commit(Ecore_Wl2_Window *window, Eina_Bool flush) +{ + EINA_SAFETY_ON_NULL_RETURN(window); + EINA_SAFETY_ON_NULL_RETURN(window->surface); + + if (window->commit_pending) ERR("Commit before previous commit processed"); + + window->commit_pending = EINA_TRUE; + window->callback = wl_surface_frame(window->surface); + wl_callback_add_listener(window->callback, &_frame_listener, window); + + if (flush) wl_surface_commit(window->surface); +} --