devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=3088f2315c547fb7bc3ee48adcfd769fe735d5c4

commit 3088f2315c547fb7bc3ee48adcfd769fe735d5c4
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Wed Jul 8 15:06:09 2015 -0400

    wl-drm: Add function to readback pixels for compositor screenshots
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/modules/wl_drm/e_mod_main.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c
index ce588c2..c2c8416 100644
--- a/src/modules/wl_drm/e_mod_main.c
+++ b/src/modules/wl_drm/e_mod_main.c
@@ -617,6 +617,36 @@ static E_Comp_Screen_Iface drmiface =
    .apply = _drm_randr_apply
 };
 
+static void
+_drm_read_pixels(E_Comp_Wl_Output *output, void *pixels)
+{
+   Ecore_Drm_Device *dev;
+   Ecore_Drm_Fb *fb;
+   const Eina_List *drm_devs, *l;
+   int i = 0, bstride;
+   void *s;
+
+   drm_devs = ecore_drm_devices_get();
+   EINA_LIST_FOREACH(drm_devs, l, dev)
+     {
+        fb = dev->next;
+        if (!fb) fb = dev->current;
+        if (fb) break;
+     }
+
+   if (!fb) return;
+
+   bstride = output->w * sizeof(int);
+   s = fb->mmap;
+
+   for (i = output->y; i < output->y + output->h; i++)
+     {
+        s = fb->mmap + (fb->stride * i) + (output->x * sizeof(int));
+        memcpy(pixels, s, (output->w * sizeof(int)));
+        pixels += bstride;
+     }
+}
+
 E_API void *
 e_modapi_init(E_Module *m)
 {
@@ -667,6 +697,8 @@ e_modapi_init(E_Module *m)
    if (!e_comp_wl_init()) return NULL;
    if (!e_comp_canvas_init(w, h)) return NULL;
 
+   e_comp->wl_comp_data->screenshooter.read_pixels = _drm_read_pixels;
+
    ecore_evas_pointer_xy_get(e_comp->ee, &e_comp->wl_comp_data->ptr.x,
                              &e_comp->wl_comp_data->ptr.y);
    evas_event_feed_mouse_in(e_comp->evas, 0, NULL);

-- 


Reply via email to