summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2013-08-03 16:52:00 -0300
committerRafael Antognolli <rafael.antognolli@intel.com>2013-08-03 17:51:42 -0300
commit6a53facca7028a4d8404c83b8ba5630393c5a615 (patch)
treeff5c6e9000575551154d9060c58ed081a17578a3
parent41142225627f38a037a447a8240a74d39730be1c (diff)
Backport 1210067fbeb21bdce34ec710e66749de981a1617.
ecore_evas/wayland_egl: Only render if last frame has been presented. This avoids blocking in eglSwapBuffers and has the side effect of avoiding doing unnecessary work - painting where a frame won't be presented. We do this by using the event that the wayland compositor will send us to tell us that the frame has been presented. Due to the fact that evas_render_updates() could do no work and not cause a eglSwapBuffers we must always have a frame callback listener setup. Original patch by: Rob Bradford <rob@linux.intel.com> (I just adjusted the patch to the single efl tree)
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_egl.c66
1 files changed, 53 insertions, 13 deletions
diff --git a/src/lib/ecore_evas/ecore_evas_wayland_egl.c b/src/lib/ecore_evas/ecore_evas_wayland_egl.c
index 504b5e21..36695d55 100644
--- a/src/lib/ecore_evas/ecore_evas_wayland_egl.c
+++ b/src/lib/ecore_evas/ecore_evas_wayland_egl.c
@@ -176,7 +176,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
176 NULL, 176 NULL,
177 NULL, 177 NULL,
178 NULL, 178 NULL,
179 _ecore_evas_wl_render, 179 _ecore_evas_wl_render,
180 _ecore_evas_wl_screen_geometry_get, 180 _ecore_evas_wl_screen_geometry_get,
181 _ecore_evas_wl_screen_dpi_get 181 _ecore_evas_wl_screen_dpi_get
182}; 182};
@@ -828,6 +828,30 @@ _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent)
828 } 828 }
829} 829}
830 830
831static void
832_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__);
833
834static const struct wl_callback_listener frame_listener = {
835 _ecore_evas_wl_frame_complete,
836};
837
838static void
839_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__)
840{
841 Ecore_Evas *ee = data;
842 Ecore_Wl_Window *win = ee->engine.wl.win;
843
844 win->frame_callback = NULL;
845 win->frame_pending = EINA_FALSE;
846 wl_callback_destroy(callback);
847
848 win->frame_callback =
849 wl_surface_frame(win->surface);
850
851 wl_callback_add_listener(win->frame_callback,
852 &frame_listener, ee);
853}
854
831static int 855static int
832_ecore_evas_wl_render(Ecore_Evas *ee) 856_ecore_evas_wl_render(Ecore_Evas *ee)
833{ 857{
@@ -840,6 +864,7 @@ _ecore_evas_wl_render(Ecore_Evas *ee)
840 { 864 {
841 Eina_List *ll = NULL, *updates = NULL; 865 Eina_List *ll = NULL, *updates = NULL;
842 Ecore_Evas *ee2 = NULL; 866 Ecore_Evas *ee2 = NULL;
867 Ecore_Wl_Window *win = NULL;
843 868
844 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); 869 if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
845 870
@@ -851,25 +876,40 @@ _ecore_evas_wl_render(Ecore_Evas *ee)
851 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); 876 if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
852 } 877 }
853 878
854 if ((updates = evas_render_updates(ee->evas))) 879 win = ee->engine.wl.win;
880
881 if (!win->frame_pending)
855 { 882 {
856 Eina_List *l = NULL; 883 if (!win->frame_callback)
857 Eina_Rectangle *r; 884 {
885 win->frame_callback = wl_surface_frame(win->surface);
886 wl_callback_add_listener(win->frame_callback,
887 &frame_listener, ee);
888 }
889
890 if ((updates = evas_render_updates(ee->evas)))
891 {
892 Eina_List *l = NULL;
893 Eina_Rectangle *r;
894
895 LOGFN(__FILE__, __LINE__, __FUNCTION__);
858 896
859 LOGFN(__FILE__, __LINE__, __FUNCTION__); 897 EINA_LIST_FOREACH(updates, l, r)
898 ecore_wl_window_damage(win,
899 r->x, r->y, r->w, r->h);
860 900
861 EINA_LIST_FOREACH(updates, l, r) 901 ecore_wl_flush();
862 ecore_wl_window_damage(ee->engine.wl.win,
863 r->x, r->y, r->w, r->h);
864 902
865 ecore_wl_flush(); 903 evas_render_updates_free(updates);
904 _ecore_evas_idle_timeout_update(ee);
905 rend = 1;
906
907 win->frame_pending = EINA_TRUE;
908 }
866 909
867 evas_render_updates_free(updates); 910 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
868 _ecore_evas_idle_timeout_update(ee);
869 rend = 1;
870 } 911 }
871 912
872 if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
873 } 913 }
874 return rend; 914 return rend;
875} 915}