diff options
author | Derek Foreman <derekf@osg.samsung.com> | 2018-01-30 16:32:45 -0600 |
---|---|---|
committer | Derek Foreman <derekf@osg.samsung.com> | 2018-01-30 17:09:52 -0600 |
commit | 879f248f0845be0163dbee0807a4eb859cf12786 (patch) | |
tree | 671af085304548ac4060c52238ffb652f7d444e5 | |
parent | 9632c7b56cc41cef3c1811b745e207599d427607 (diff) | |
download | efl-879f248f0845be0163dbee0807a4eb859cf12786.tar.gz |
ecore_wl2_surface: Flush surfaces for offscreen windows
When a surface leaves all outputs we can discard its buffers to save
memory.
Currently most compositors don't send leave events for iconify, so this
pretty much just saves us a cursor buffer under weston for now, but in
the future it could be used for freeing resources of offscreen (fully
occluded or iconified) windows.
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2_private.h | 3 | ||||
-rw-r--r-- | src/lib/ecore_wl2/ecore_wl2_surface.c | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 107bc6360b..47590552b6 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -562,8 +562,9 @@ typedef struct _Ecore_Wl2_Surface Ecore_Wl2_Window *wl2_win; int w, h; - Eina_Bool alpha : 1; Ecore_Wl2_Surface_Interface *funcs; + Ecore_Event_Handler *offscreen_handler; + Eina_Bool alpha : 1; } Ecore_Wl2_Surface; Ecore_Wl2_Window *_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface); diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c b/src/lib/ecore_wl2/ecore_wl2_surface.c index c3a791f7c8..1e101e8405 100644 --- a/src/lib/ecore_wl2/ecore_wl2_surface.c +++ b/src/lib/ecore_wl2/ecore_wl2_surface.c @@ -63,6 +63,18 @@ ecore_wl2_surface_flush(Ecore_Wl2_Surface *surface) surface->funcs->flush(surface, surface->private_data); } +static Eina_Bool +_ecore_wl2_surface_cb_offscreen(void *data, int type EINA_UNUSED, void *event) +{ + Ecore_Wl2_Event_Window_Offscreen *ev = event; + Ecore_Wl2_Surface *surf = data; + + if (surf->wl2_win->id == (int)ev->win) + ecore_wl2_surface_flush(surf); + + return ECORE_CALLBACK_RENEW; +} + EAPI Ecore_Wl2_Surface * ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) { @@ -90,6 +102,10 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) { out->funcs = intf; win->wl2_surface = out; + out->offscreen_handler = + ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_OFFSCREEN, + _ecore_wl2_surface_cb_offscreen, + out); return out; } } |