summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-01-30 16:32:45 -0600
committerDerek Foreman <derekf@osg.samsung.com>2018-01-30 17:09:52 -0600
commit879f248f0845be0163dbee0807a4eb859cf12786 (patch)
tree671af085304548ac4060c52238ffb652f7d444e5
parent9632c7b56cc41cef3c1811b745e207599d427607 (diff)
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.h3
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_surface.c16
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
562 Ecore_Wl2_Window *wl2_win; 562 Ecore_Wl2_Window *wl2_win;
563 563
564 int w, h; 564 int w, h;
565 Eina_Bool alpha : 1;
566 Ecore_Wl2_Surface_Interface *funcs; 565 Ecore_Wl2_Surface_Interface *funcs;
566 Ecore_Event_Handler *offscreen_handler;
567 Eina_Bool alpha : 1;
567} Ecore_Wl2_Surface; 568} Ecore_Wl2_Surface;
568 569
569Ecore_Wl2_Window *_ecore_wl2_display_window_surface_find(Ecore_Wl2_Display *display, struct wl_surface *wl_surface); 570Ecore_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)
63 surface->funcs->flush(surface, surface->private_data); 63 surface->funcs->flush(surface, surface->private_data);
64} 64}
65 65
66static Eina_Bool
67_ecore_wl2_surface_cb_offscreen(void *data, int type EINA_UNUSED, void *event)
68{
69 Ecore_Wl2_Event_Window_Offscreen *ev = event;
70 Ecore_Wl2_Surface *surf = data;
71
72 if (surf->wl2_win->id == (int)ev->win)
73 ecore_wl2_surface_flush(surf);
74
75 return ECORE_CALLBACK_RENEW;
76}
77
66EAPI Ecore_Wl2_Surface * 78EAPI Ecore_Wl2_Surface *
67ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha) 79ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
68{ 80{
@@ -90,6 +102,10 @@ ecore_wl2_surface_create(Ecore_Wl2_Window *win, Eina_Bool alpha)
90 { 102 {
91 out->funcs = intf; 103 out->funcs = intf;
92 win->wl2_surface = out; 104 win->wl2_surface = out;
105 out->offscreen_handler =
106 ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_OFFSCREEN,
107 _ecore_wl2_surface_cb_offscreen,
108 out);
93 return out; 109 return out;
94 } 110 }
95 } 111 }