ecore_wl2_surface: Flush surfaces for offscreen windows
authorDerek Foreman <derekf@osg.samsung.com>
Tue, 30 Jan 2018 22:32:45 +0000 (16:32 -0600)
committerJiyoun Park <jy0703.park@samsung.com>
Tue, 3 Apr 2018 14:30:05 +0000 (23:30 +0900)
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
src/lib/ecore_wl2/ecore_wl2_surface.c

index a58d71d..64ddd90 100755 (executable)
@@ -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;
index e98b2b8..6dae2c9 100644 (file)
@@ -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;
           }
      }