From 9dac14dbc7922a3a61d5762dd3246fce0195a85c Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 30 Jan 2018 16:32:45 -0600 Subject: [PATCH] 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. --- src/lib/ecore_wl2/ecore_wl2_private.h | 8 +++++++- src/lib/ecore_wl2/ecore_wl2_surface.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index a58d71d..64ddd90 100755 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -756,8 +756,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; unsigned int frame_age; // TIZEN_ONLY(20171226) : evas tbm_buf backend } Ecore_Wl2_Surface; @@ -809,7 +810,9 @@ Eina_Hash *_ecore_wl2_keygrab_hash_get(void); // TIZEN_ONLY(20171109): support a tizen_input_device_manager interface void _ecore_wl2_input_device_manager_setup(Ecore_Wl2_Display *ewd, unsigned int id, unsigned int version); // +// TIZEN_ONLY(20180125): generate Ecore_Device_Add/Del events void _ecore_wl2_input_devices_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *win); +// //TIZEN_ONLY(20171115): support output transform void _ecore_wl2_window_ignore_output_transform_set(Ecore_Wl2_Window *window, Eina_Bool ignore); @@ -819,7 +822,10 @@ void _ecore_wl2_window_ignore_output_transform_set(Ecore_Wl2_Window *window, Ein void _ecore_wl2_window_init(void); void _ecore_wl2_window_shutdown(void); // + +// TIZEN_ONLY(20180125): generate Ecore_Device_Add/Del events Eina_Hash *_ecore_wl2_window_hash_get(void); +// EAPI extern int _ecore_wl2_event_window_www; EAPI extern int _ecore_wl2_event_window_www_drag; diff --git a/src/lib/ecore_wl2/ecore_wl2_surface.c b/src/lib/ecore_wl2/ecore_wl2_surface.c index e98b2b8..6dae2c9 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) { @@ -96,6 +108,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; } } -- 2.7.4