summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoram Park <boram1288.park@samsung.com>2015-06-08 13:08:59 +0900
committerBoram Park <boram1288.park@samsung.com>2015-06-08 14:10:58 +0900
commit100a2af54c9f862b26ea6fe8f197a827b7040c88 (patch)
treebe7c9634e50b645534635f3a3f2f2a43c28c5add
parent6107d86a8d98b21f53f0e9f7c9b1c5e332d01f39 (diff)
downloadefl-100a2af54c9f862b26ea6fe8f197a827b7040c88.tar.gz
gl_drm: support evas_render_copy
Change-Id: Iec1dac4cd10e9f4dbe2e2fcefd988b6019279431
-rw-r--r--src/modules/evas/engines/gl_drm/evas_drm.c6
-rw-r--r--src/modules/evas/engines/gl_drm/evas_drm_main.c39
-rw-r--r--src/modules/evas/engines/gl_drm/evas_engine.c15
-rw-r--r--src/modules/evas/engines/gl_drm/evas_engine.h2
4 files changed, 59 insertions, 3 deletions
diff --git a/src/modules/evas/engines/gl_drm/evas_drm.c b/src/modules/evas/engines/gl_drm/evas_drm.c
index 19d8594592..3180c34b25 100644
--- a/src/modules/evas/engines/gl_drm/evas_drm.c
+++ b/src/modules/evas/engines/gl_drm/evas_drm.c
@@ -23,8 +23,8 @@ _evas_drm_crtc_buffer_get(int fd, int crtc_id)
return id;
}
-static Ecore_Drm_Output*
-_evas_drm_output_find(unsigned int crtc_id)
+Ecore_Drm_Output*
+evas_drm_output_find(unsigned int crtc_id)
{
Ecore_Drm_Device *dev;
Ecore_Drm_Output *output;
@@ -341,7 +341,7 @@ evas_drm_framebuffer_send(Outbuf *ob, Buffer *buffer)
if (!ob->output)
{
- ob->output = _evas_drm_output_find(ob->priv.crtc);
+ ob->output = evas_drm_output_find(ob->priv.crtc);
EINA_SAFETY_ON_NULL_RETURN_VAL(ob->output, EINA_FALSE);
}
diff --git a/src/modules/evas/engines/gl_drm/evas_drm_main.c b/src/modules/evas/engines/gl_drm/evas_drm_main.c
index 0649341cf7..fe75b6d913 100644
--- a/src/modules/evas/engines/gl_drm/evas_drm_main.c
+++ b/src/modules/evas/engines/gl_drm/evas_drm_main.c
@@ -1,5 +1,8 @@
#include "evas_engine.h"
+#include <sys/mman.h>
+#include <fcntl.h>
+
/* local variables */
static Outbuf *_evas_gl_drm_window = NULL;
static EGLContext context = EGL_NO_CONTEXT;
@@ -678,3 +681,39 @@ eng_outbuf_egl_display_get(Outbuf *ob)
{
return ob->egl_disp;
}
+
+void
+eng_outbuf_copy(Outbuf *ob, void *buffer, int stride, int width EINA_UNUSED, int height, uint format EINA_UNUSED,
+ int sx EINA_UNUSED, int sy EINA_UNUSED, int sw EINA_UNUSED, int sh EINA_UNUSED,
+ int dx EINA_UNUSED, int dy EINA_UNUSED, int dw EINA_UNUSED, int dh EINA_UNUSED)
+{
+ Ecore_Drm_Output *output;
+ uint fb_handle, fb_fmt;
+ int fb_w, fb_h;
+ void *data;
+ struct drm_mode_map_dumb arg = {0,};
+
+ output = evas_drm_output_find(ob->priv.crtc);
+
+ /* TODO: should find the better way to find current framebuffer */
+ ecore_drm_output_current_fb_info_get(output, &fb_handle, &fb_w, &fb_h, &fb_fmt);
+
+ arg.handle = fb_handle;
+ if (drmIoctl(ob->priv.fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))
+ {
+ DBG("dump map failed");
+ return;
+ }
+
+ data = mmap(NULL, fb_w * fb_h * 4, PROT_READ|PROT_WRITE, MAP_SHARED,
+ ob->priv.fd, arg.offset);
+ if (data == MAP_FAILED)
+ {
+ DBG("mmap failed");
+ return;
+ }
+
+ memcpy(buffer, data, stride * height);
+
+ munmap(data, fb_w * fb_h * 4);
+}
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c
index a54b237b30..b5283eeb20 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.c
+++ b/src/modules/evas/engines/gl_drm/evas_engine.c
@@ -868,6 +868,20 @@ eng_output_dump(void *data)
}
static void
+eng_output_copy(void *data, void *buffer, int stride, int width, int height, uint format, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
+{
+ Render_Engine *re;
+ Outbuf *ob;
+
+ if (!(re = (Render_Engine *)data)) return;
+
+ ob = eng_get_ob(re);
+ EINA_SAFETY_ON_NULL_RETURN(ob);
+
+ eng_outbuf_copy(ob, buffer, stride, width, height, format, sx, sy, sw, sh, dx, dy, dw, dh);
+}
+
+static void
_native_cb_bind(void *data EINA_UNUSED, void *image)
{
Evas_GL_Image *img;
@@ -1213,6 +1227,7 @@ module_open(Evas_Module *em)
ORD(output_free);
ORD(output_dump);
ORD(image_native_set);
+ ORD(output_copy);
/* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() )
* implicit env set (EGL_PLATFORM=drm) prevent that. */
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h b/src/modules/evas/engines/gl_drm/evas_engine.h
index 2d306828bb..31b0c53a55 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.h
+++ b/src/modules/evas/engines/gl_drm/evas_engine.h
@@ -192,6 +192,8 @@ void evas_drm_outbuf_framebuffer_set(Outbuf *ob, Buffer *buffer);
Eina_Bool evas_drm_framebuffer_send(Outbuf *ob, Buffer *buffer);
void evas_drm_outbuf_event_flip(int fd, unsigned int seq, unsigned int sec, unsigned int usec, void *data);
void evas_drm_outbuf_event_vblank(int fd, unsigned int seq, unsigned int sec, unsigned int usec, void *data);
+Ecore_Drm_Output* evas_drm_output_find(unsigned int crtc_id);
+void eng_outbuf_copy(Outbuf *ob, void *buffer, int stride, int width, int height, uint format, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh);
static inline Outbuf *
eng_get_ob(Render_Engine *re)