Evas Software X11: Add a callback that informs the current screen content pixels.
authorGuilherme Iscaro <iscaro@profusion.mobi>
Wed, 21 Sep 2016 16:46:17 +0000 (13:46 -0300)
committerBruno Dilly <bdilly@profusion.mobi>
Tue, 27 Sep 2016 01:06:59 +0000 (22:06 -0300)
This is necessary in order to implement a VNC server. Using this
callback the VNC server will be able to draw the current screen to the
VNC clients.

src/modules/evas/engines/software_x11/Evas_Engine_Software_X11.h
src/modules/evas/engines/software_x11/evas_engine.c
src/modules/evas/engines/software_x11/evas_engine.h
src/modules/evas/engines/software_x11/evas_xcb_outbuf.c
src/modules/evas/engines/software_x11/evas_xlib_outbuf.c

index e42c10a..6600c5d 100644 (file)
@@ -41,6 +41,7 @@ struct _Evas_Engine_Info_Software_X11
         void *(*best_visual_get) (int backend, void *connection, int screen);
         unsigned int (*best_colormap_get) (int backend, void *connection, int screen);
         int (*best_depth_get) (int backend, void *connection, int screen);
+        void (*region_push_hook)(Evas *e, int x, int y, int w, int h, const void *pixels);
      } func;
 
    unsigned char mask_changed : 1;
index 6429a5a..7042e12 100644 (file)
@@ -32,6 +32,8 @@
 # include <dlfcn.h>
 #endif
 
+#include <Ecore.h>
+
 Evas_Native_Tbm_Surface_Image_Set_Call  glsym__evas_native_tbm_surface_image_set = NULL;
 Evas_Native_Tbm_Surface_Stride_Get_Call  glsym__evas_native_tbm_surface_stride_get = NULL;
 int _evas_engine_soft_x11_log_dom = -1;
@@ -133,6 +135,22 @@ _output_egl_setup(int w, int h, int rot, Display *disp, Drawable draw,
 }
 */
 
+
+void
+evas_software_x11_region_push_hook_call(Outbuf *buf, int x, int y, int w, int h,
+                                        const void *pixels)
+{
+   int err;
+
+   if (!buf->region_push_hook.cb)
+     return;
+
+   err = ecore_thread_main_loop_begin();
+   EINA_SAFETY_ON_TRUE_RETURN(err == -1);
+   buf->region_push_hook.cb(buf->region_push_hook.evas, x, y, w, h, pixels);
+   ecore_thread_main_loop_end();
+}
+
 static void
 _output_egl_shutdown(Render_Engine *re)
 {
@@ -526,6 +544,8 @@ eng_setup(Evas *eo_e, void *in)
                                           info->info.destination_alpha);
                   re->outbuf_alpha_get = evas_software_xlib_outbuf_alpha_get;
                }
+             re->generic.ob->region_push_hook.cb = info->func.region_push_hook;
+             re->generic.ob->region_push_hook.evas = eo_e;
           }
 #endif
 
@@ -621,6 +641,8 @@ eng_setup(Evas *eo_e, void *in)
         if (ob)
           {
              evas_render_engine_software_generic_update(&re->generic, ob, e->output.w, e->output.h);
+             ob->region_push_hook.cb = info->func.region_push_hook;
+             ob->region_push_hook.evas = eo_e;
           }
 
         /* if ((re) && (re->ob)) re->ob->onebuf = ponebuf; */
index 895e320..5999e68 100644 (file)
@@ -113,9 +113,16 @@ struct _Outbuf
         unsigned char debug : 1;
         unsigned char synced : 1;
      } priv;
+   struct
+     {
+        void (*cb)(Evas *e, int x, int y, int w, int h, const void *pixels);
+        Evas *evas;
+     } region_push_hook;
 };
 
 void evas_software_xlib_x_init(void);
 void evas_software_xcb_init(void);
 
+void evas_software_x11_region_push_hook_call(Outbuf *buf, int x, int y, int w, int h, const void *pixels);
+
 #endif
index b747f64..a65c9d8 100644 (file)
@@ -680,9 +680,14 @@ evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Eva
                                 pixman_region_n_rects(&tmpr), 
                                 (const xcb_rectangle_t *)pixman_region_rectangles(&tmpr, NULL));
         if (obr->xcbob)
-          evas_software_xcb_output_buffer_paste(obr->xcbob, 
-                                                buf->priv.x11.xcb.win, 
-                                                buf->priv.x11.xcb.gc, 0, 0, 0);
+          {
+             evas_software_x11_region_push_hook_call(buf, 0, 0, obr->xcbob->xim->width,
+                                                     obr->xcbob->xim->height,
+                                                     evas_software_xcb_output_buffer_data(obr->xcbob, NULL));
+             evas_software_xcb_output_buffer_paste(obr->xcbob,
+                                                   buf->priv.x11.xcb.win,
+                                                   buf->priv.x11.xcb.gc, 0, 0, 0);
+          }
         if (obr->mask) 
           {
              xcb_set_clip_rectangles(buf->priv.x11.xcb.conn, 
@@ -709,10 +714,16 @@ evas_software_xcb_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Eva
                evas_software_xcb_outbuf_debug_show(buf, buf->priv.x11.xcb.win, 
                                                    obr->x, obr->y, obr->w, obr->h);
              if (obr->xcbob)
-               evas_software_xcb_output_buffer_paste(obr->xcbob, 
-                                                     buf->priv.x11.xcb.win, 
-                                                     buf->priv.x11.xcb.gc, 
-                                                     obr->x, obr->y, 0);
+               {
+                  evas_software_x11_region_push_hook_call(buf, obr->x, obr->y,
+                                                          obr->xcbob->xim->width,
+                                                          obr->xcbob->xim->height,
+                                                          evas_software_xcb_output_buffer_data(obr->xcbob, NULL));
+                  evas_software_xcb_output_buffer_paste(obr->xcbob,
+                                                        buf->priv.x11.xcb.win,
+                                                        buf->priv.x11.xcb.gc,
+                                                        obr->x, obr->y, 0);
+               }
              if (obr->mask)
                evas_software_xcb_output_buffer_paste(obr->mask, 
                                                      buf->priv.x11.xcb.mask, 
@@ -959,10 +970,16 @@ evas_software_xcb_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, in
           evas_software_xcb_outbuf_debug_show(buf, buf->priv.x11.xcb.win, 
                                               obr->x, obr->y, obr->w, obr->h);
         if (obr->xcbob)
-          evas_software_xcb_output_buffer_paste(obr->xcbob, 
-                                                buf->priv.x11.xcb.win, 
-                                                buf->priv.x11.xcb.gc, 
-                                                obr->x, obr->y, 0);
+          {
+             evas_software_x11_region_push_hook_call(buf, obr->x, obr->y,
+                                                     obr->xcbob->xim->width,
+                                                     obr->xcbob->xim->height,
+                                                     evas_software_xcb_output_buffer_data(obr->xcbob, NULL));
+             evas_software_xcb_output_buffer_paste(obr->xcbob,
+                                                   buf->priv.x11.xcb.win,
+                                                   buf->priv.x11.xcb.gc,
+                                                   obr->x, obr->y, 0);
+          }
      }
 #endif
    if (obr->mask) 
index 3827091..cfd2609 100644 (file)
@@ -818,9 +818,14 @@ evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Ev
         eina_array_clean(&buf->priv.onebuf_regions);
        XSetRegion(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc, tmpr);
         if (obr->xob)
-           evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
-                                                    buf->priv.x11.xlib.gc,
-                                                    0, 0, 0);
+          {
+             evas_software_x11_region_push_hook_call(buf, 0, 0, obr->xob->xim->width,
+                                                     obr->xob->xim->height,
+                                                     evas_software_xlib_x_output_buffer_data(obr->xob, NULL));
+             evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
+                                                      buf->priv.x11.xlib.gc,
+                                                      0, 0, 0);
+          }
        if (obr->mxob)
          {
             XSetRegion(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gcm, tmpr);
@@ -843,9 +848,15 @@ evas_software_xlib_outbuf_flush(Outbuf *buf, Tilebuf_Rect *rects EINA_UNUSED, Ev
               evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
                                                   obr->x, obr->y, obr->w, obr->h);
              if (obr->xob)
-                evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
-                                                         buf->priv.x11.xlib.gc,
-                                                         obr->x, obr->y, 0);
+               {
+                  evas_software_x11_region_push_hook_call(buf, obr->x, obr->y,
+                                                          obr->xob->xim->width,
+                                                          obr->xob->xim->height,
+                                                          evas_software_xlib_x_output_buffer_data(obr->xob, NULL));
+                  evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
+                                                           buf->priv.x11.xlib.gc,
+                                                           obr->x, obr->y, 0);
+               }
             if (obr->mxob)
               evas_software_xlib_x_output_buffer_paste(obr->mxob,
                                                       buf->priv.x11.xlib.mask,
@@ -1124,9 +1135,15 @@ evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, i
          evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
                                                obr->x, obr->y, obr->w, obr->h);
         if (obr->xob)
-           evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
-                                                    buf->priv.x11.xlib.gc,
-                                                    obr->x, obr->y, 0);
+          {
+             evas_software_x11_region_push_hook_call(buf, obr->x, obr->y,
+                                                     obr->xob->xim->width,
+                                                     obr->xob->xim->height,
+                                                     evas_software_xlib_x_output_buffer_data(obr->xob, NULL));
+             evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
+                                                      buf->priv.x11.xlib.gc,
+                                                      obr->x, obr->y, 0);
+          }
      }
 #endif
    if (obr->mxob)