diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index d5b3167d09..43f11d7e68 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -577,13 +577,12 @@ modules/evas/engines/software_generic/evas_ector_software_buffer.eo ### Engines if EVAS_STATIC_BUILD_SOFTWARE_GENERIC -BUILT_SOURCES += \ - modules/evas/engines/software_generic/evas_ector_software_buffer.eo.c \ - modules/evas/engines/software_generic/evas_ector_software_buffer.eo.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_ector_software_buffer.c +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_ector_software_buffer.c \ +modules/evas/engines/software_generic/evas_native_common.h lib_evas_libevas_la_LIBADD += lib_evas_libevas_la_CPPFLAGS += -I$(top_srcdir)/src/lib/ector else @@ -595,7 +594,12 @@ 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_ector_software_buffer.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 \ @@ -1075,8 +1079,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 908dd2312c..bddaa7b0f9 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)(); @@ -627,11 +619,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 @@ -680,13 +672,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."); } @@ -1168,9 +1160,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, EGL_WAYLAND_BUFFER_WL, wl_buf, attribs); @@ -1184,7 +1176,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, @@ -1221,7 +1213,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; diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index 84db094fc8..c94ab17756 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 */ @@ -2000,31 +2001,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. @@ -2043,11 +2019,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 @@ -2059,7 +2035,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"); } @@ -2075,11 +2051,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 @@ -2089,16 +2065,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 @@ -2107,7 +2086,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); } } } @@ -2115,11 +2094,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 @@ -2146,7 +2125,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 @@ -2187,16 +2166,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."); @@ -2208,13 +2187,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 @@ -2222,12 +2201,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 @@ -2239,15 +2218,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."); @@ -2267,13 +2246,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."); } @@ -2305,11 +2284,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 @@ -2324,7 +2303,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; @@ -2581,19 +2560,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; @@ -2717,7 +2696,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; } @@ -2759,16 +2738,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); @@ -2777,7 +2756,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); } @@ -2828,10 +2807,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; @@ -2861,16 +2837,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; @@ -2897,10 +2873,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; @@ -2954,12 +2927,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"); @@ -2970,7 +2943,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 0000000000..0ff0b7437d --- /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 85% 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 aeedc70748..bcc81c6d69 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,17 +207,24 @@ _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; + RGBA_Image *im = image; + Native *n = im->native.data; + tbm_surface_info_s info; + tbm_surface_h *tbm_surf; - if (!(im = image)) return; - - n = im->native.data; - if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM)) + if (!im) return; + if (n) { - tbm_surface_info_s info; + if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) + { + tbm_surf = n->ns.data.tbm.buffer; + } + else tbm_surf = NULL; - if (sym_tbm_surface_map(n->ns.data.tbm.buffer, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) return; + if (!tbm_surf) + return; + 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; } @@ -233,28 +233,32 @@ _native_bind_cb(void *data EINA_UNUSED, void *image, int x EINA_UNUSED, int y EI 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; - - n = im->native.data; - if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM)) + if (!im) return; + if (n) { - sym_tbm_surface_unmap(n->ns.data.tbm.buffer); + if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) + { + tbm_surf = n->ns.data.tbm.buffer; + } + else tbm_surf = NULL; + + if (!tbm_surf) + return; + 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 +271,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 +288,14 @@ 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) + { + tbm_surf = ns->data.tbm.buffer; + } + else tbm_surf = NULL; + + if (!tbm_surf) return NULL; + if (!tbm_init()) { ERR("Could not initialize TBM!"); @@ -291,7 +305,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 +325,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 +362,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 5ed5fd14be..b6dc615f48 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 b561e2f83b..c29f62deea 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 597a8c6bd4..dc892456c4 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 ffd9e6254b..cfe6c6302d 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 0c0a0ab025..fa33391c35 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; @@ -586,7 +587,7 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native) exim->draw = (Drawable)ns->data.x11.pixmap; - n = calloc(1, sizeof(DRI_Native)); + n = calloc(1, sizeof(Native)); if (!n) { evas_xlib_image_dri_free(exim); @@ -594,10 +595,10 @@ evas_xlib_image_dri_native_set(void *data, void *image, void *native) } 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; 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 947297785a..75731485e5 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 36a62258c4..7d7347583f 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_shm/evas_engine.c b/src/modules/evas/engines/wayland_shm/evas_engine.c index 82500908b3..e6a810c130 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.c +++ b/src/modules/evas/engines/wayland_shm/evas_engine.c @@ -5,6 +5,11 @@ #endif #include "evas_engine.h" +#include "../software_generic/evas_native_common.h" + +#ifdef HAVE_DLSYM +# include +#endif /* logging domain variable */ int _evas_engine_way_shm_log_dom = -1; @@ -12,6 +17,8 @@ int _evas_engine_way_shm_log_dom = -1; /* evas function tables - filled in later (func and parent func) */ static Evas_Func func, pfunc; +Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL; + /* engine structure data */ typedef struct _Render_Engine Render_Engine; struct _Render_Engine @@ -77,6 +84,22 @@ err: return NULL; } +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 FUNCTIONS WE PROVIDE */ static void * eng_info(Evas *eo_evas EINA_UNUSED) @@ -242,6 +265,71 @@ eng_output_resize(void *data, int w, int h) re->generic.h = h; } +static void * +eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) +{ + Evas_Native_Surface *ns = native; + Image_Entry *ie = image; + RGBA_Image *im = image, *im2; + + if (!im || !ns) return im; + + if (ns->type == EVAS_NATIVE_SURFACE_TBM) + { + if (im->native.data) + { + //image have native surface already + Evas_Native_Surface *ens = im->native.data; + + if ((ens->type == ns->type) && + (ens->data.tbm.buffer == ns->data.tbm.buffer)) + return im; + } + } + + if ((ns->type == EVAS_NATIVE_SURFACE_OPENGL) && + (ns->version == EVAS_NATIVE_SURFACE_VERSION)) + im2 = evas_cache_image_data(evas_common_image_cache_get(), + ie->w, ie->h, + ns->data.x11.visual, 1, + EVAS_COLORSPACE_ARGB8888); + else + im2 = evas_cache_image_data(evas_common_image_cache_get(), + ie->w, ie->h, + NULL, 1, + EVAS_COLORSPACE_ARGB8888); + + if (im->native.data) + { + if (im->native.func.free) + im->native.func.free(im->native.func.data, im); + } + +#ifdef EVAS_CSERVE2 + if (evas_cserve2_use_get() && evas_cache2_image_cached(ie)) + evas_cache2_image_close(ie); + else +#endif + evas_cache_image_drop(ie); + im = im2; + + if (ns->type == EVAS_NATIVE_SURFACE_TBM) + return glsym_evas_native_tbm_surface_image_set(NULL, im, ns); + + return im; +} + +static void * +eng_image_native_get(void *data EINA_UNUSED, void *image) +{ + RGBA_Image *im = image; + Native *n; + if (!im) return NULL; + n = im->native.data; + if (!n) return NULL; + return &(n->ns); +} + /* EVAS MODULE FUNCTIONS */ static int module_open(Evas_Module *em) @@ -273,7 +361,10 @@ module_open(Evas_Module *em) ORD(setup); ORD(output_free); ORD(output_resize); + ORD(image_native_set); + ORD(image_native_get); + _symbols(); /* advertise our own engine functions */ em->functions = (void *)(&func);