From 6bf7166f2c8912f3bf392295bb47ae9035699664 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Sun, 24 Jan 2016 20:47:19 +0900 Subject: [PATCH] evas engine : Downstream tbm surface patchs Evas_Engine: add TBM surface and clean up Native Struct : 7db9613e8c95268acfa6d51ea6aa45418ee8e697 evas tbm: Fix compilation warnings : d7903e40b326de5323276cdf2869a608cd0c5a33 evas tbm: Fix compilation warnings : d7903e40b326de5323276cdf2869a608cd0c5a33 wayland: Add support for TBM buffers :3593186a60e5530871a252a4bd6b03d881a0ead4 waylang-egl: Remove trailing spaces :a7063973819c087a3a6e039e4cbeed13b29a1fd5 Evas: Fix compilation for GLX 8884ce59b33d4681a1f1bd60bc91d0d6adf9348f Change-Id: Ie709a5a610f8037907c99a57353995dfa20d99ba --- src/Makefile_Evas.am | 16 +- src/modules/evas/engines/gl_drm/evas_engine.c | 34 ++-- src/modules/evas/engines/gl_x11/evas_engine.c | 157 ++++++++---------- .../engines/software_generic/evas_native_common.h | 82 ++++++++++ .../evas_native_tbm.c | 80 +++++---- .../evas/engines/software_x11/evas_engine.c | 27 ++- .../evas/engines/software_x11/evas_engine.h | 1 - .../evas/engines/software_x11/evas_xcb_image.c | 22 +-- .../evas/engines/software_x11/evas_xcb_image.h | 12 +- .../engines/software_x11/evas_xlib_dri_image.c | 52 +++--- .../engines/software_x11/evas_xlib_dri_image.h | 2 +- .../evas/engines/software_x11/evas_xlib_image.c | 22 +-- .../evas/engines/software_x11/evas_xlib_image.h | 12 +- src/modules/evas/engines/wayland_egl/evas_engine.c | 181 +++++++++++++++++---- 14 files changed, 436 insertions(+), 264 deletions(-) create mode 100644 src/modules/evas/engines/software_generic/evas_native_common.h rename src/modules/evas/engines/{software_x11 => software_generic}/evas_native_tbm.c (87%) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index c39432b..c062f58 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -566,7 +566,12 @@ if EVAS_STATIC_BUILD_SOFTWARE_GENERIC BUILT_SOURCES += \ modules/evas/engines/software_generic/ector_cairo_software_surface.eo.c \ modules/evas/engines/software_generic/ector_cairo_software_surface.eo.h -lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/ector_surface.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h +lib_evas_libevas_la_SOURCES += \ +modules/evas/engines/software_generic/evas_engine.c \ +modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h \ +modules/evas/engines/software_generic/evas_native_tbm.c \ +modules/evas/engines/software_generic/ector_surface.c \ +modules/evas/engines/software_generic/evas_native_common.h lib_evas_libevas_la_LIBADD += else enginesoftwaregenericpkgdir = $(libdir)/evas/modules/engines/software_generic/$(MODULE_ARCH) @@ -577,7 +582,11 @@ enginesoftwaregenericpkg_LTLIBRARIES = modules/evas/engines/software_generic/mod install_enginesoftwaregenericpkgLTLIBRARIES = install-enginesoftwaregenericpkgLTLIBRARIES $(install_enginesoftwaregenericpkgLTLIBRARIES): install-libLTLIBRARIES -modules_evas_engines_software_generic_module_la_SOURCES = modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h +modules_evas_engines_software_generic_module_la_SOURCES = \ +modules/evas/engines/software_generic/evas_engine.c \ +modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h \ +modules/evas/engines/software_generic/evas_native_tbm.c \ +modules/evas/engines/software_generic/evas_native_common.h modules_evas_engines_software_generic_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ @@ -1040,8 +1049,7 @@ SOFTWARE_X11_SOURCES = \ modules/evas/engines/software_x11/evas_engine.c \ modules/evas/engines/software_x11/evas_engine.h \ modules/evas/engines/software_x11/evas_x_egl.c \ -modules/evas/engines/software_x11/evas_x_egl.h \ -modules/evas/engines/software_x11/evas_native_tbm.c +modules/evas/engines/software_x11/evas_x_egl.h SOFTWARE_X11_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c index 57f2edd..7981b58 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.c +++ b/src/modules/evas/engines/gl_drm/evas_engine.c @@ -1,6 +1,7 @@ #include "config.h" #include "evas_engine.h" #include "../gl_common/evas_gl_define.h" +#include "../software_generic/evas_native_common.h" #include @@ -27,15 +28,6 @@ int _extn_have_buffer_age = 1; static Eina_Bool initted = EINA_FALSE; static int gl_wins = 0; -/* local structures */ -typedef struct _Native Native; -struct _Native -{ - Evas_Native_Surface ns; - struct wl_buffer *wl_buf; - void *egl_surface; -}; - /* local function prototype types */ typedef void (*_eng_fn)(void); typedef _eng_fn (*glsym_func_eng_fn)(); @@ -636,11 +628,11 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_WL) { - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); + glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->ns_data.wl_surface.surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -653,10 +645,10 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - if (n->egl_surface) + if (n->ns_data.evasgl.surface) { Eina_Bool is_egl_image; - void *buffer = glsym_evgl_native_surface_buffer_get(n->egl_surface, &is_egl_image); + void *buffer = glsym_evgl_native_surface_buffer_get( n->ns_data.evasgl.surface, &is_egl_image); if (is_egl_image) { if (glsym_glEGLImageTargetTexture2DOES) @@ -720,13 +712,13 @@ _native_cb_free(void *data, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_WL) { - wlid = (void*)n->wl_buf; + wlid = (void*)n->ns_data.wl_surface.wl_buf; eina_hash_del(ob->gl_context->shared->native_wl_hash, &wlid, img); - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_eglDestroyImage) { - glsym_eglDestroyImage(ob->egl.disp, n->egl_surface); + glsym_eglDestroyImage(ob->egl.disp, n->ns_data.wl_surface.surface); if (eglGetError() != EGL_SUCCESS) ERR("eglDestroyImage() failed."); } @@ -1251,9 +1243,9 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(ob->gl_context->shared->native_wl_hash, &wlid, img); - n->wl_buf = wl_buf; + n->ns_data.wl_surface.wl_buf = wl_buf; if (glsym_eglCreateImage) - n->egl_surface = glsym_eglCreateImage(ob->egl.disp, + n->ns_data.wl_surface.surface = glsym_eglCreateImage(ob->egl.disp, NULL, EVAS_GL_WAYLAND_BUFFER_WL, wl_buf, @@ -1268,7 +1260,7 @@ eng_image_native_set(void *data, void *image, void *native) return NULL; } - if (!n->egl_surface) + if (!n->ns_data.wl_surface.surface) { ERR("eglCreatePixmapSurface() for %p failed", wl_buf); eina_hash_del(ob->gl_context->shared->native_wl_hash, @@ -1302,7 +1294,7 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(ob->gl_context->shared->native_tex_hash, &texid, img); - n->egl_surface = 0; + n->ns_data.opengl.surface = 0; img->native.yinvert = 0; img->native.loose = 0; @@ -1329,7 +1321,7 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(ob->gl_context->shared->native_evasgl_hash, &buffer, img); - n->egl_surface = ns->data.evasgl.surface; + n->ns_data.evasgl.surface = ns->data.evasgl.surface; img->native.yinvert = 0; img->native.loose = 0; diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index df3983e..43c2b73 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c @@ -1,6 +1,7 @@ #include "evas_common_private.h" /* Also includes international specific stuff */ #include "evas_engine.h" #include "../gl_common/evas_gl_define.h" +#include "../software_generic/evas_native_common.h" #ifdef HAVE_DLSYM # include /* dlopen,dlclose,etc */ @@ -1929,31 +1930,6 @@ end: ///////////////////////////////////////////////////////////////////////// // // -typedef struct _Native Native; - -struct _Native -{ - Evas_Native_Surface ns; - Pixmap pixmap; - Visual *visual; - void *buffer; - - void *config; - void *surface; -#ifdef GL_GLES -# ifdef HAVE_WAYLAND - void *wl_buf; - void *egl_surface; -# endif -#endif -/* -#ifndef GL_GLES - void *fbc; - XID glx_pixmap; -#endif -*/ -}; - // FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW // (i am sure this is the reason) not to mention seemingly superfluous. but // i need to enable it for it to work on fglrx at least. havent tried nvidia. @@ -1972,11 +1948,11 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_X11) { #ifdef GL_GLES - if (n->surface) + if (n->ns_data.x11.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(im->native.target, n->surface); + glsym_glEGLImageTargetTexture2DOES(im->native.target, n->ns_data.x11.surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -1988,7 +1964,7 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) if (glsym_glXBindTexImage) { - glsym_glXBindTexImage(eng_get_ob(re)->disp, (XID)n->surface, + glsym_glXBindTexImage(eng_get_ob(re)->disp, (XID)n->ns_data.x11.surface, GLX_FRONT_LEFT_EXT, NULL); GLERRV("glsym_glXBindTexImage"); } @@ -2004,11 +1980,11 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) { #ifdef GL_GLES - if (n->surface) + if (n->ns_data.tbm.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(im->native.target, n->surface); + glsym_glEGLImageTargetTexture2DOES(im->native.target, n->ns_data.tbm.surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -2018,16 +1994,19 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - if (n->surface) + if (n->ns_data.evasgl.surface) { - Eina_Bool is_egl_image; - void *buffer = glsym_evgl_native_surface_buffer_get(n->surface, &is_egl_image); + Eina_Bool is_egl_image = EINA_FALSE; + void *surface; + + if (glsym_evgl_native_surface_buffer_get) + surface = glsym_evgl_native_surface_buffer_get(n->ns_data.evasgl.surface, &is_egl_image); if (is_egl_image) { #ifdef GL_GLES if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(im->native.target, buffer); + glsym_glEGLImageTargetTexture2DOES(im->native.target, surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -2036,7 +2015,7 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) } else { - glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)buffer); + glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)surface); } } } @@ -2044,11 +2023,11 @@ _native_bind_cb(void *data EINA_UNUSED, void *image) { #ifdef GL_GLES # ifdef HAVE_WAYLAND - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); + glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->ns_data.wl_surface.surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -2075,7 +2054,7 @@ _native_unbind_cb(void *data EINA_UNUSED, void *image) if (glsym_glXReleaseTexImage) { - glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)n->surface, + glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)(n->ns_data.x11.surface), GLX_FRONT_LEFT_EXT); } else @@ -2116,16 +2095,16 @@ _native_free_cb(void *data, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_X11) { - pmid = n->pixmap; + pmid = n->ns_data.x11.pixmap; eina_hash_del(eng_get_ob(re)->gl_context->shared->native_pm_hash, &pmid, im); #ifdef GL_GLES - if (n->surface) + if (n->ns_data.x11.surface) { int err; if (glsym_eglDestroyImage) { glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, - n->surface); + n->ns_data.x11.surface); if ((err = eglGetError()) != EGL_SUCCESS) { ERR("eglDestroyImage() failed."); @@ -2137,13 +2116,13 @@ _native_free_cb(void *data, void *image) } #else # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT - if (n->surface) + if (n->ns_data.x11.surface) { if (im->native.loose) { if (glsym_glXReleaseTexImage) { - glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)n->surface, + glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)n->ns_data.x11.surface, GLX_FRONT_LEFT_EXT); } else @@ -2151,12 +2130,12 @@ _native_free_cb(void *data, void *image) } if (glsym_glXDestroyPixmap) { - glsym_glXDestroyPixmap(eng_get_ob(re)->disp, (XID)n->surface); + glsym_glXDestroyPixmap(eng_get_ob(re)->disp, (XID)n->ns_data.x11.surface); GLERRV("glsym_glXDestroyPixmap"); } else ERR("Try glXDestroyPixmap on GLX with no support"); - n->surface = 0; + n->ns_data.x11.surface = 0; } # endif #endif @@ -2168,15 +2147,15 @@ _native_free_cb(void *data, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) { - eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->buffer, im); + eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->ns_data.tbm.buffer, im); #ifdef GL_GLES - if (n->surface) + if (n->ns_data.tbm.surface) { int err; if (glsym_eglDestroyImage) { glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, - n->surface); + n->ns_data.tbm.surface); if ((err = eglGetError()) != EGL_SUCCESS) { ERR("eglDestroyImage() failed."); @@ -2196,13 +2175,13 @@ _native_free_cb(void *data, void *image) { #ifdef GL_GLES # ifdef HAVE_WAYLAND - wlid = (void*)n->wl_buf; + wlid = (void*)n->ns_data.wl_surface.wl_buf; eina_hash_del(eng_get_ob(re)->gl_context->shared->native_wl_hash, &wlid, image); - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_eglDestroyImage) { - glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, n->egl_surface); + glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, n->ns_data.wl_surface.surface); if (eglGetError() != EGL_SUCCESS) ERR("eglDestroyImage() failed."); } @@ -2234,11 +2213,11 @@ _native_yinvert_cb(void *data, void *image) { #if GL_GLES if (extn_have_y_inverted && - eglGetConfigAttrib(eng_get_ob(re)->egl_disp, n->config, + eglGetConfigAttrib(eng_get_ob(re)->egl_disp, n->ns_data.x11.config, EGL_Y_INVERTED_NOK, &val)) yinvert = val; #else - glXGetFBConfigAttrib(eng_get_ob(re)->disp, n->config, + glXGetFBConfigAttrib(eng_get_ob(re)->disp, n->ns_data.x11.config, GLX_Y_INVERTED_EXT, &val); if (val) yinvert = 1; #endif @@ -2253,7 +2232,7 @@ _native_yinvert_cb(void *data, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - yinvert = glsym_evgl_native_surface_yinvert_get(n->surface); + yinvert = glsym_evgl_native_surface_yinvert_get(n->ns_data.evasgl.surface); } return yinvert; @@ -2510,19 +2489,19 @@ eng_image_native_set(void *data, void *image, void *native) } memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->pixmap = pm; - n->visual = vis; + n->ns_data.x11.pixmap = pm; + n->ns_data.x11.visual = vis; if (glsym_eglCreateImage) - n->surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, - EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, - (void *)pm, - NULL); + n->ns_data.x11.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, + EGL_NO_CONTEXT, + EGL_NATIVE_PIXMAP_KHR, + (void *)pm, + NULL); else ERR("Try eglCreateImage on EGL with no support"); - if (!n->surface) + if (!n->ns_data.x11.surface) ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm); - n->config = (void *)egl_config; + n->ns_data.x11.config = (void *)egl_config; im->native.yinvert = yinvert; im->native.loose = 0; @@ -2646,7 +2625,7 @@ eng_image_native_set(void *data, void *image, void *native) glXGetFBConfigAttrib(eng_get_ob(re)->disp, configs[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val); mipmap = val; - n->config = configs[j]; + n->ns_data.x11.config = configs[j]; found = 1; break; } @@ -2688,16 +2667,16 @@ eng_image_native_set(void *data, void *image, void *native) pixmap_att[i++] = 0; memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->pixmap = pm; - n->visual = vis; + n->ns_data.x11.pixmap = pm; + n->ns_data.x11.visual = vis; if (glsym_glXCreatePixmap) - n->surface = (void *)glsym_glXCreatePixmap(eng_get_ob(re)->disp, - n->config, - n->pixmap, + n->ns_data.x11.surface = (void *)glsym_glXCreatePixmap(eng_get_ob(re)->disp, + n->ns_data.x11.config, + n->ns_data.x11.pixmap, pixmap_att); else ERR("Try glXCreatePixmap on GLX with no support"); - if (n->surface) + if (n->ns_data.x11.surface) { // printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n", // n, pm, w, h, depth, n->surface); @@ -2706,7 +2685,7 @@ eng_image_native_set(void *data, void *image, void *native) ERR("no target :("); if (glsym_glXQueryDrawable) glsym_glXQueryDrawable(eng_get_ob(re)->disp, - n->pixmap, + n->ns_data.x11.pixmap, GLX_TEXTURE_TARGET_EXT, &target); } @@ -2757,10 +2736,7 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tex_hash, &texid, im); - n->pixmap = 0; - n->visual = 0; - n->config = 0; - n->surface = 0; + n->ns_data.opengl.surface = 0; im->native.yinvert = 0; im->native.loose = 0; @@ -2790,16 +2766,16 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer, im); memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->buffer = buffer; + n->ns_data.tbm.buffer = buffer; if (glsym_eglCreateImage) - n->surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, - EGL_NO_CONTEXT, - EGL_NATIVE_SURFACE_TIZEN, - (void *)buffer, - NULL); + n->ns_data.tbm.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, + EGL_NO_CONTEXT, + EGL_NATIVE_SURFACE_TIZEN, + (void *)buffer, + NULL); else ERR("Try eglCreateImage on EGL with no support"); - if (!n->surface) + if (!n->ns_data.tbm.surface) ERR("eglCreateImage() for %p failed", buffer); im->native.yinvert = 1; im->native.loose = 0; @@ -2826,10 +2802,7 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &buffer, im); - n->pixmap = 0; - n->visual = 0; - - n->surface = ns->data.evasgl.surface; + n->ns_data.evasgl.surface = ns->data.evasgl.surface; im->native.yinvert = 0; im->native.loose = 0; @@ -2883,12 +2856,12 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(eng_get_ob(re)->gl_context->shared->native_wl_hash, &wlid, im); - n->wl_buf = wl_buf; + n->ns_data.wl_surface.wl_buf = wl_buf; if (glsym_eglCreateImage) - n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, - NULL, - EGL_WAYLAND_BUFFER_WL, - wl_buf, attribs); + n->ns_data.wl_surface.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, + NULL, + EGL_WAYLAND_BUFFER_WL, + wl_buf, attribs); else { ERR("Try eglCreateImage on EGL with no support"); @@ -2899,7 +2872,7 @@ eng_image_native_set(void *data, void *image, void *native) return NULL; } - if (!n->egl_surface) + if (!n->ns_data.wl_surface.surface) { ERR("eglCreatePixmapSurface() for %p failed", wl_buf); eina_hash_del(eng_get_ob(re)->gl_context->shared->native_wl_hash, diff --git a/src/modules/evas/engines/software_generic/evas_native_common.h b/src/modules/evas/engines/software_generic/evas_native_common.h new file mode 100644 index 0000000..0ff0b74 --- /dev/null +++ b/src/modules/evas/engines/software_generic/evas_native_common.h @@ -0,0 +1,82 @@ +#ifndef _EVAS_NATIVE_COMMON_H +#define _EVAS_NATIVE_COMMON_H + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_EVAS_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EVAS_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif /* ! _WIN32 */ + +//#include + +typedef struct _Native Native; +struct _Native +{ + Evas_Native_Surface ns; + union { + /* EVAS_NATIVE_SURFACE_X11 */ + struct + { + unsigned long pixmap; /* Pixmap */ + void *visual; /* Visual */ + void *display; /* Display */ + void *exim; /* Ecore_X_Image or Evas_DRI_Image */ + + void *buffer; + void *config; /* egl configuration or glx configuration */ + void *surface; /* egl surface or glx surface */ + } x11; /**< Set this struct fields if surface data is SW X11 based. */ + + /* EVAS_NATIVE_SURFACE_WL */ + struct + { + void *wl_buf; /* struct wl_buffer */ + void *surface; /*egl surface*/ + } wl_surface; /**< Set this struct fields if surface data is Wayland based. */ + + /* EVAS_NATIVE_SURFACE_OPENGL */ + struct + { + void *surface; /*egl surface*/ + } opengl; + + /* EVAS_NATIVE_SURFACE_EVASGL */ + struct + { + void *surface; /*evas gl surface*/ + } evasgl; + + /* EVAS_NATIVE_SURFACE_TBM */ + struct + { + void *buffer; /*tbm surface*/ + void *surface; /*egl surface*/ + } tbm; + } ns_data; /**< Choose one union data according to your surface in Evas Engine. */ +}; + +EAPI void * evas_native_tbm_surface_image_set(void *data, void *image, void *native); + +typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native); + +#endif //_EVAS_NATIVE_COMMON_H diff --git a/src/modules/evas/engines/software_x11/evas_native_tbm.c b/src/modules/evas/engines/software_generic/evas_native_tbm.c similarity index 87% rename from src/modules/evas/engines/software_x11/evas_native_tbm.c rename to src/modules/evas/engines/software_generic/evas_native_tbm.c index aeedc70..07b4414 100644 --- a/src/modules/evas/engines/software_x11/evas_native_tbm.c +++ b/src/modules/evas/engines/software_generic/evas_native_tbm.c @@ -1,14 +1,6 @@ #include "evas_common_private.h" -#ifdef BUILD_ENGINE_SOFTWARE_XLIB -# include "evas_xlib_image.h" -#endif -#ifdef BUILD_ENGINE_SOFTWARE_XCB -# include "evas_xcb_image.h" -#endif #include "evas_private.h" - -#include "Evas_Engine_Software_X11.h" -#include "evas_engine.h" +#include "evas_native_common.h" #ifdef HAVE_DLSYM # include /* dlopen,dlclose,etc */ @@ -28,6 +20,8 @@ #define __tbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) +#define TBM_FORMAT_ARGB8888 __tbm_fourcc_code('A', 'R', '2', '4') +#define TBM_FORMAT_ABGR8888 __tbm_fourcc_code('A', 'B', '2', '4') #define TBM_FORMAT_RGBX8888 __tbm_fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ #define TBM_FORMAT_RGBA8888 __tbm_fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ #define TBM_FORMAT_BGRA8888 __tbm_fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ @@ -69,7 +63,6 @@ typedef struct _tbm_surface_info void *reserved6; /**< Reserved pointer6 */ } tbm_surface_info_s; - /* returns 0 on success */ static int (*sym_tbm_surface_map) (tbm_surface_h surface, int opt, tbm_surface_info_s *info) = NULL; static int (*sym_tbm_surface_unmap) (tbm_surface_h surface) = NULL; @@ -214,47 +207,44 @@ _evas_video_nv12(unsigned char *evas_data, const unsigned char *source_data, uns static void _native_bind_cb(void *data EINA_UNUSED, void *image, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) { - RGBA_Image *im; - Native *n; - - if (!(im = image)) return; + RGBA_Image *im = image; + Native *n = im->native.data; + tbm_surface_info_s info; + tbm_surface_h tbm_surf; - n = im->native.data; - if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM)) - { - tbm_surface_info_s info; + if (!im || !n) return; + if (n->ns.type != EVAS_NATIVE_SURFACE_TBM) + return; - if (sym_tbm_surface_map(n->ns.data.tbm.buffer, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) return; + tbm_surf = n->ns.data.tbm.buffer; + if (sym_tbm_surface_map(tbm_surf, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) + return; - im->image.data = (DATA32 *)info.planes[0].ptr; - } + im->image.data = (DATA32 *)info.planes[0].ptr; } static void _native_unbind_cb(void *data EINA_UNUSED, void *image) { - RGBA_Image *im; - Native *n; + RGBA_Image *im = image; + Native *n = im->native.data; + tbm_surface_h tbm_surf; - if (!(im = image)) return; + if (!im || !n) return; + if (n->ns.type != EVAS_NATIVE_SURFACE_TBM) + return; - n = im->native.data; - if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM)) - { - sym_tbm_surface_unmap(n->ns.data.tbm.buffer); - } + tbm_surf = n->ns.data.tbm.buffer; + sym_tbm_surface_unmap(tbm_surf); } static void _native_free_cb(void *data EINA_UNUSED, void *image) { - RGBA_Image *im; - Native *n; - - if (!(im = image)) return; - - n = im->native.data; + RGBA_Image *im = image; + Native *n = im->native.data; + if (!im) return; im->native.data = NULL; im->native.func.bind = NULL; im->native.func.unbind = NULL; @@ -267,14 +257,16 @@ _native_free_cb(void *data EINA_UNUSED, void *image) tbm_shutdown(); } -void * -evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native) +EAPI void * +evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *native) { Evas_Native_Surface *ns = native; RGBA_Image *im = image; + tbm_surface_h tbm_surf; if (!im) return NULL; - if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_TBM)) + + if (ns) { void *pixels_data; int w, h, stride; @@ -282,6 +274,11 @@ evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native) tbm_surface_info_s info; Native *n; + if (ns->type != EVAS_NATIVE_SURFACE_TBM) + return NULL; + + tbm_surf = ns->data.tbm.buffer; + if (!tbm_init()) { ERR("Could not initialize TBM!"); @@ -291,7 +288,7 @@ evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native) n = calloc(1, sizeof(Native)); if (!n) return NULL; - if (sym_tbm_surface_map(ns->data.tbm.buffer, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) + if (sym_tbm_surface_map(tbm_surf, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) { free(n); return im; @@ -311,6 +308,8 @@ evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native) case TBM_FORMAT_RGBA8888: case TBM_FORMAT_RGBX8888: case TBM_FORMAT_BGRA8888: + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_ABGR8888: im->cache_entry.w = stride / 4; evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_ARGB8888); im->cache_entry.flags.alpha = (format == TBM_FORMAT_RGBX8888 ? 0 : 1); @@ -346,8 +345,7 @@ evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native) im->native.func.unbind = _native_unbind_cb; im->native.func.free = _native_free_cb; - sym_tbm_surface_unmap(ns->data.tbm.buffer); + sym_tbm_surface_unmap(tbm_surf); } return im; } - diff --git a/src/modules/evas/engines/software_x11/evas_engine.c b/src/modules/evas/engines/software_x11/evas_engine.c index 1b73f33..70ba970 100644 --- a/src/modules/evas/engines/software_x11/evas_engine.c +++ b/src/modules/evas/engines/software_x11/evas_engine.c @@ -26,6 +26,13 @@ #include "evas_x_egl.h" #endif +#include "../software_generic/evas_native_common.h" + +#ifdef HAVE_DLSYM +# include +#endif + +Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL; int _evas_engine_soft_x11_log_dom = -1; /* function tables - filled in later (func and parent func) */ @@ -414,6 +421,22 @@ _best_depth_get(int backend, void *connection, int screen) return 0; } +static void +_symbols(void) +{ + static int done = 0; + + if (done) return; + +#define LINK2GENERIC(sym) \ + glsym_##sym = dlsym(RTLD_DEFAULT, #sym); + + // Get function pointer to native_common that is now provided through the link of SW_Generic. + LINK2GENERIC(evas_native_tbm_surface_image_set); + + done = 1; +} + /* engine api this module provides */ static void * eng_info(Evas *eo_e EINA_UNUSED) @@ -730,7 +753,7 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) } else if (ns->type == EVAS_NATIVE_SURFACE_TBM) { - return evas_native_tbm_image_set(re->generic.ob, ie, ns); + return glsym_evas_native_tbm_surface_image_set(re->generic.ob, ie, ns); } else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL) { @@ -738,6 +761,7 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) Native *n = calloc(1, sizeof(Native)); if (n) { + n->ns_data.evasgl.surface = ns->data.evasgl.surface; im = (RGBA_Image *) ie; n->ns.type = EVAS_NATIVE_SURFACE_EVASGL; n->ns.version = EVAS_NATIVE_SURFACE_VERSION; @@ -796,6 +820,7 @@ module_open(Evas_Module *em) ORD(image_native_set); ORD(image_native_get); + _symbols(); /* now advertise out own api */ em->functions = (void *)(&func); return 1; diff --git a/src/modules/evas/engines/software_x11/evas_engine.h b/src/modules/evas/engines/software_x11/evas_engine.h index b561e2f..c29f62d 100644 --- a/src/modules/evas/engines/software_x11/evas_engine.h +++ b/src/modules/evas/engines/software_x11/evas_engine.h @@ -116,6 +116,5 @@ struct _Outbuf void evas_software_xlib_x_init(void); void evas_software_xcb_init(void); -void *evas_native_tbm_image_set(void *data, void *image, void *native); #endif diff --git a/src/modules/evas/engines/software_x11/evas_xcb_image.c b/src/modules/evas/engines/software_x11/evas_xcb_image.c index 597a8c6..dc89245 100644 --- a/src/modules/evas/engines/software_x11/evas_xcb_image.c +++ b/src/modules/evas/engines/software_x11/evas_xcb_image.c @@ -14,20 +14,20 @@ _evas_xcb_image_update(void *data EINA_UNUSED, void *image, int x, int y, int w, im = image; n = im->native.data; - if (ecore_x_image_get(n->exim, n->pixmap, 0, 0, x, y, w, h)) + if (ecore_x_image_get(n->ns_data.x11->exim, n->ns_data.x11->pixmap, 0, 0, x, y, w, h)) { char *pix; int bpl, rows, bpp; - pix = ecore_x_image_data_get(n->exim, &bpl, &rows, &bpp); - if (!ecore_x_image_is_argb32_get(n->exim)) + pix = ecore_x_image_data_get(n->ns_data.x11->exim, &bpl, &rows, &bpp); + if (!ecore_x_image_is_argb32_get(n->ns_data.x11->exim)) { Ecore_X_Colormap colormap; if (!im->image.data) im->image.data = (DATA32 *)malloc(im->cache_entry.w * im->cache_entry.h * sizeof(DATA32)); colormap = ecore_x_default_colormap_get(ecore_x_display_get(), ecore_x_default_screen_get()); - ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->visual, + ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->ns_data.x11->visual, x, y, w, h, im->image.data, (w * sizeof(int)), 0, 0); } @@ -58,12 +58,12 @@ _native_cb_free(void *data EINA_UNUSED, void *image) im = image; n = im->native.data; - if (n->exim) + if (n->ns_data.x11->exim) { - ecore_x_image_free(n->exim); - n->exim = NULL; + ecore_x_image_free(n->ns_data.x11->exim); + n->ns_data.x11->exim = NULL; } - n->visual = NULL; + n->ns_data.x11->visual = NULL; im->native.data = NULL; im->native.func.data = NULL; @@ -110,9 +110,9 @@ evas_xcb_image_native_set(void *data, void *image, void *native) } memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->pixmap = pm; - n->visual = vis; - n->exim = exim; + n->ns_data.x11->pixmap = pm; + n->ns_data.x11->visual = vis; + n->ns_data.x11->exim = exim; im->native.data = n; im->native.func.data = NULL; diff --git a/src/modules/evas/engines/software_x11/evas_xcb_image.h b/src/modules/evas/engines/software_x11/evas_xcb_image.h index ffd9e62..cfe6c63 100644 --- a/src/modules/evas/engines/software_x11/evas_xcb_image.h +++ b/src/modules/evas/engines/software_x11/evas_xcb_image.h @@ -1,15 +1,5 @@ #include "evas_engine.h" #include - -typedef struct _Native Native; - -struct _Native -{ - Evas_Native_Surface ns; - Ecore_X_Pixmap pixmap; - Ecore_X_Visual *visual; - - Ecore_X_Image *exim; -}; +#include "../software_generic/evas_native_common.h" void *evas_xcb_image_native_set(void *data, void *image, void *native); diff --git a/src/modules/evas/engines/software_x11/evas_xlib_dri_image.c b/src/modules/evas/engines/software_x11/evas_xlib_dri_image.c index d76e356..fa33391 100644 --- a/src/modules/evas/engines/software_x11/evas_xlib_dri_image.c +++ b/src/modules/evas/engines/software_x11/evas_xlib_dri_image.c @@ -4,6 +4,7 @@ #include "evas_common_private.h" #include "evas_xlib_dri_image.h" +#include "../software_generic/evas_native_common.h" # include /* dlopen,dlclose,etc */ # include @@ -408,7 +409,7 @@ _evas_xlib_image_x_free(Display *d) Eina_Bool evas_xlib_image_get_buffers(RGBA_Image *im) { - DRI_Native *n = NULL; + Native *n = NULL; Display *d; Evas_DRI_Image *exim; @@ -416,8 +417,8 @@ evas_xlib_image_get_buffers(RGBA_Image *im) n = im->native.data; if (!n) return EINA_FALSE; - exim = n->exim; - d = n->d; + exim = n->ns_data.x11.exim; + d = n->ns_data.x11.display; if(!exim) return EINA_FALSE; @@ -513,7 +514,7 @@ static void _native_bind_cb(void *data EINA_UNUSED, void *image, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED) { RGBA_Image *im = image; - DRI_Native *n = im->native.data; + Native *n = im->native.data; if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_X11)) { @@ -528,15 +529,15 @@ static void _native_free_cb(void *data EINA_UNUSED, void *image) { RGBA_Image *im = image; - DRI_Native *n = im->native.data; + Native *n = im->native.data; if (!n) return; - if (n->exim) + if (n->ns_data.x11.exim) { - evas_xlib_image_dri_free(n->exim); - n->exim = NULL; + evas_xlib_image_dri_free(n->ns_data.x11.exim); + n->ns_data.x11.exim = NULL; } - n->visual = NULL; - n->d = NULL; + n->ns_data.x11.visual = NULL; + n->ns_data.x11.display = NULL; im->native.data = NULL; im->native.func.data = NULL; @@ -552,7 +553,7 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native) Display *d = NULL; Visual *vis = NULL; Pixmap pm = 0; - DRI_Native *n = NULL; + Native *n = NULL; RGBA_Image *im = image; int w, h; Evas_DRI_Image *exim; @@ -563,13 +564,13 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native) int idum; unsigned int uidum, depth = 0; - if(!ns || ns->type != EVAS_NATIVE_SURFACE_X11) - return EINA_FALSE; + if (!ns || ns->type != EVAS_NATIVE_SURFACE_X11) + return NULL; d = ob->priv.x11.xlib.disp; vis = ns->data.x11.visual; pm = ns->data.x11.pixmap; - if (!pm) return EINA_FALSE; + if (!pm) return NULL; XGetGeometry(d, pm, &wdum, &idum, &idum, &uidum, &uidum, &uidum, &depth); @@ -579,29 +580,32 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native) exim = evas_xlib_image_dri_new(w, h, vis, depth); if (!exim) - { + { ERR("evas_xlib_image_dri_new failed."); - return EINA_FALSE; - } + return NULL; + } exim->draw = (Drawable)ns->data.x11.pixmap; - n = calloc(1, sizeof(DRI_Native)); + n = calloc(1, sizeof(Native)); if (!n) - return EINA_FALSE; + { + evas_xlib_image_dri_free(exim); + return NULL; + } memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->pixmap = pm; - n->visual = vis; - n->d = d; - n->exim = exim; + n->ns_data.x11.pixmap = pm; + n->ns_data.x11.visual = vis; + n->ns_data.x11.display = d; + n->ns_data.x11.exim = exim; im->native.data = n; im->native.func.data = NULL; im->native.func.bind = _native_bind_cb; im->native.func.free = _native_free_cb; if (evas_xlib_image_dri_init(exim, d)) evas_xlib_image_get_buffers(im); - else return EINA_FALSE; + else return NULL; return im; } diff --git a/src/modules/evas/engines/software_x11/evas_xlib_dri_image.h b/src/modules/evas/engines/software_x11/evas_xlib_dri_image.h index 555468d..563e7c7 100644 --- a/src/modules/evas/engines/software_x11/evas_xlib_dri_image.h +++ b/src/modules/evas/engines/software_x11/evas_xlib_dri_image.h @@ -80,5 +80,5 @@ void evas_xlib_image_dir_free(Evas_DRI_Image *exim); Eina_Bool evas_xlib_image_get_buffers(RGBA_Image *im); void evas_xlib_image_buffer_unmap(Evas_DRI_Image *exim); Eina_Bool evas_xlib_image_dri_init(Evas_DRI_Image *exim, Display *display); -Eina_Bool evas_xlib_image_dri_used(); +Eina_Bool evas_xlib_image_dri_used(void); void *evas_xlib_image_dri_native_set(void *data, void *image, void *native); diff --git a/src/modules/evas/engines/software_x11/evas_xlib_image.c b/src/modules/evas/engines/software_x11/evas_xlib_image.c index 9472977..7573148 100644 --- a/src/modules/evas/engines/software_x11/evas_xlib_image.c +++ b/src/modules/evas/engines/software_x11/evas_xlib_image.c @@ -13,15 +13,15 @@ evas_xlib_image_update(void *data EINA_UNUSED, void *image, int x, int y, int w, char *pix; int bpl, rows, bpp; - if (ecore_x_image_get(n->exim, n->pixmap, 0, 0, x, y, w, h)) + if (ecore_x_image_get(n->ns_data.x11.exim, n->ns_data.x11.pixmap, 0, 0, x, y, w, h)) { - pix = ecore_x_image_data_get(n->exim, &bpl, &rows, &bpp); - if (!ecore_x_image_is_argb32_get(n->exim)) + pix = ecore_x_image_data_get(n->ns_data.x11.exim, &bpl, &rows, &bpp); + if (!ecore_x_image_is_argb32_get(n->ns_data.x11.exim)) { if (!im->image.data) im->image.data = (DATA32 *)malloc(im->cache_entry.w * im->cache_entry.h * sizeof(DATA32)); Ecore_X_Colormap colormap = ecore_x_default_colormap_get(ecore_x_display_get(), ecore_x_default_screen_get()); - ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->visual, + ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->ns_data.x11.visual, x, y, w, h, im->image.data, (w * sizeof(int)), 0, 0); } @@ -50,12 +50,12 @@ _native_free_cb(void *data EINA_UNUSED, void *image) RGBA_Image *im = image; Native *n = im->native.data; - if (n->exim) + if (n->ns_data.x11.exim) { - ecore_x_image_free(n->exim); - n->exim = NULL; + ecore_x_image_free(n->ns_data.x11.exim); + n->ns_data.x11.exim = NULL; } - n->visual = NULL; + n->ns_data.x11.visual = NULL; im->native.data = NULL; im->native.func.data = NULL; @@ -99,9 +99,9 @@ evas_xlib_image_native_set(void *data, void *image, void *native) } memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); - n->pixmap = pm; - n->visual = vis; - n->exim = exim; + n->ns_data.x11.pixmap = pm; + n->ns_data.x11.visual = vis; + n->ns_data.x11.exim = exim; im->native.data = n; im->native.func.data = NULL; im->native.func.bind = _native_bind_cb; diff --git a/src/modules/evas/engines/software_x11/evas_xlib_image.h b/src/modules/evas/engines/software_x11/evas_xlib_image.h index 36a6225..7d73475 100644 --- a/src/modules/evas/engines/software_x11/evas_xlib_image.h +++ b/src/modules/evas/engines/software_x11/evas_xlib_image.h @@ -1,15 +1,5 @@ #include "evas_engine.h" #include - -typedef struct _Native Native; - -struct _Native -{ - Evas_Native_Surface ns; - Pixmap pixmap; - Visual *visual; - - Ecore_X_Image *exim; -}; +#include "../software_generic/evas_native_common.h" void *evas_xlib_image_native_set(void *data, void *image, void *native); diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c index 671d3fd..92a1f14 100755 --- a/src/modules/evas/engines/wayland_egl/evas_engine.c +++ b/src/modules/evas/engines/wayland_egl/evas_engine.c @@ -1,6 +1,7 @@ #include "evas_common_private.h" #include "evas_engine.h" #include "../gl_common/evas_gl_define.h" +#include "../software_generic/evas_native_common.h" #ifdef HAVE_DLSYM # include @@ -30,16 +31,6 @@ struct _Render_Engine Render_Engine_GL_Generic generic; }; -typedef struct _Native Native; -struct _Native -{ - Evas_Native_Surface ns; - struct wl_buffer *wl_buf; - void *egl_surface; - - void *surface; -}; - /* Evas GL wl_surface & wl_egl_window */ typedef struct _Evgl_wl_Surface Evgl_wl_Surface; struct _Evgl_wl_Surface @@ -1180,11 +1171,11 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_WL) { - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { if (glsym_glEGLImageTargetTexture2DOES) { - glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); + glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->ns_data.wl_surface.surface); GLERRV("glsym_glEGLImageTargetTexture2DOES"); } else @@ -1197,10 +1188,14 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - if (n->egl_surface) + if (n->ns_data.evasgl.surface) { - Eina_Bool is_egl_image; - void *surface = glsym_evgl_native_surface_buffer_get(n->egl_surface, &is_egl_image); + Eina_Bool is_egl_image = EINA_FALSE; + void *surface; + + if (glsym_evgl_native_surface_buffer_get) + surface = glsym_evgl_native_surface_buffer_get(n->ns_data.evasgl.surface, &is_egl_image); + if (is_egl_image) { if (glsym_glEGLImageTargetTexture2DOES) @@ -1217,7 +1212,23 @@ _native_cb_bind(void *data EINA_UNUSED, void *image) glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)surface); } } - } + } + else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) + { +#ifdef GL_GLES + if (n->ns_data.tbm.surface) + { + if (glsym_glEGLImageTargetTexture2DOES) + { + glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->ns_data.tbm.surface); + if (eglGetError() != EGL_SUCCESS) + ERR("glEGLImageTargetTexture2DOES() failed."); + } + else + ERR("Try glEGLImageTargetTexture2DOES on EGL with no support"); + } +#endif + } } static void @@ -1241,6 +1252,10 @@ _native_cb_unbind(void *data EINA_UNUSED, void *image) { // nothing } + else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) + { + // nothing + } } static void @@ -1260,14 +1275,14 @@ _native_cb_free(void *data, void *image) if (n->ns.type == EVAS_NATIVE_SURFACE_WL) { - wlid = (void*)n->wl_buf; + wlid = (void*)n->ns_data.wl_surface.wl_buf; eina_hash_del(ob->gl_context->shared->native_wl_hash, &wlid, img); - if (n->egl_surface) + if (n->ns_data.wl_surface.surface) { int err; if (glsym_eglDestroyImage) { - glsym_eglDestroyImage(ob->egl_disp, n->egl_surface); + glsym_eglDestroyImage(ob->egl_disp, n->ns_data.wl_surface.surface); if ((err = eglGetError()) != EGL_SUCCESS) { ERR("eglDestroyImage() failed."); @@ -1285,7 +1300,28 @@ _native_cb_free(void *data, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - eina_hash_del(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &n->ns.data.evasgl.surface, img); + eina_hash_del(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &n->ns_data.evasgl.surface, img); + } + else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) + { + eina_hash_del(ob->gl_context->shared->native_tbm_hash, &n->ns_data.tbm.buffer, img); +#ifdef GL_GLES + if (n->ns_data.tbm.surface) + { + int err; + if (glsym_eglDestroyImage) + { + glsym_eglDestroyImage(ob->egl_disp, + n->ns_data.tbm.surface); + if ((err = eglGetError()) != EGL_SUCCESS) + { + ERR("eglDestroyImage() failed."); + } + } + else + ERR("Try eglDestroyImage on EGL with no support"); + } +#endif } img->native.data = NULL; img->native.func.data = NULL; @@ -1319,7 +1355,8 @@ _native_cb_yinvert(void *data, void *image) } else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) { - yinvert = glsym_evgl_native_surface_yinvert_get(n->surface); + if (glsym_evgl_native_surface_yinvert_get) + yinvert = glsym_evgl_native_surface_yinvert_get(n->ns_data.evasgl.surface); } return yinvert; @@ -1387,15 +1424,25 @@ eng_image_native_set(void *data, void *image, void *native) } } else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL) - { - buffer = ns->data.evasgl.surface; - if (img->native.data) - { - Evas_Native_Surface *ens = img->native.data; - if (ens->data.evasgl.surface == buffer) - return img; - } - } + { + buffer = ns->data.evasgl.surface; + if (img->native.data) + { + Evas_Native_Surface *ens = img->native.data; + if (ens->data.evasgl.surface == buffer) + return img; + } + } + else if (ns->type == EVAS_NATIVE_SURFACE_TBM) + { + buffer = ns->data.tbm.buffer; + if (img->native.data) + { + Evas_Native_Surface *ens = img->native.data; + if (ens->data.tbm.buffer == buffer) + return img; + } + } } if ((!ns) && (!img->native.data)) return img; @@ -1456,6 +1503,21 @@ eng_image_native_set(void *data, void *image, void *native) } } } + else if (ns->type == EVAS_NATIVE_SURFACE_TBM) + { + img2 = eina_hash_find(ob->gl_context->shared->native_tbm_hash, &buffer); + if (img2 == img) return img; + if (img2) + { + n = img2->native.data; + if (n) + { + glsym_evas_gl_common_image_ref(img2); + glsym_evas_gl_common_image_free(img); + return img2; + } + } + } img2 = glsym_evas_gl_common_image_new_from_data(ob->gl_context, img->w, img->h, NULL, img->alpha, @@ -1496,9 +1558,9 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(ob->gl_context->shared->native_wl_hash, &wlid, img); - n->wl_buf = wl_buf; + n->ns_data.wl_surface.wl_buf = wl_buf; if (glsym_eglCreateImage) - n->egl_surface = glsym_eglCreateImage(ob->egl_disp, + n->ns_data.wl_surface.surface = glsym_eglCreateImage(ob->egl_disp, NULL, EVAS_GL_WAYLAND_BUFFER_WL, wl_buf, attribs); @@ -1512,7 +1574,7 @@ eng_image_native_set(void *data, void *image, void *native) return NULL; } - if (!n->egl_surface) + if (!n->ns_data.wl_surface.surface) { ERR("eglCreatePixmapSurface() for %p failed", wl_buf); eina_hash_del(ob->gl_context->shared->native_wl_hash, @@ -1548,7 +1610,7 @@ eng_image_native_set(void *data, void *image, void *native) memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); eina_hash_add(ob->gl_context->shared->native_tex_hash, &texid, img); - n->egl_surface = 0; + n->ns_data.opengl.surface = 0; img->native.yinvert = 0; img->native.loose = 0; @@ -1576,7 +1638,7 @@ eng_image_native_set(void *data, void *image, void *native) eina_hash_add(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &buffer, img); - n->egl_surface = ns->data.evasgl.surface; + n->ns_data.evasgl.surface = ns->data.evasgl.surface; img->native.yinvert = 0; img->native.loose = 0; img->native.data = n; @@ -1591,10 +1653,59 @@ eng_image_native_set(void *data, void *image, void *native) } } } + else if (ns->type == EVAS_NATIVE_SURFACE_TBM) + { +#ifdef GL_GLES + if (native) + { + n = calloc(1, sizeof(Native)); + if (n) + { + eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer, img); + + memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); + n->ns_data.tbm.buffer = buffer; + + if (glsym_eglCreateImage) + n->ns_data.tbm.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, + EGL_NO_CONTEXT, + EGL_NATIVE_SURFACE_TIZEN, + (void *)buffer, + NULL); + else + ERR("Try eglCreateImage on EGL with no support"); + if (!n->ns_data.tbm.surface) + ERR("eglCreateImage() for %p failed", buffer); + img->native.yinvert = 1; + img->native.loose = 0; + img->native.data = n; + img->native.func.data = re; + img->native.func.bind = _native_cb_bind; + img->native.func.unbind = _native_cb_unbind; + img->native.func.free = _native_cb_free; + img->native.target = GL_TEXTURE_EXTERNAL_OES; + img->native.mipmap = 0; + glsym_evas_gl_common_image_native_enable(img); + } + } +#endif + } return img; } +static void * +eng_image_native_get(void *data EINA_UNUSED, void *image) +{ + Evas_GL_Image *im = image; + Evas_Native_Surface *n; + + if (!im) return NULL; + n = im->native.data; + if (!n) return NULL; + return n; +} + Eina_Bool eng_preload_make_current(void *data, void *doit) { -- 2.7.4