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)
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 \
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 \
#include "config.h"
#include "evas_engine.h"
#include "../gl_common/evas_gl_define.h"
+#include "../software_generic/evas_native_common.h"
#include <wayland-client.h>
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)();
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
}
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)
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.");
}
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,
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,
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;
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;
#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 <dlfcn.h> /* dlopen,dlclose,etc */
/////////////////////////////////////////////////////////////////////////
//
//
-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.
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
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");
}
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
}
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
}
else
{
- glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)buffer);
+ glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)surface);
}
}
}
{
#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
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
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.");
}
#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
}
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
}
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.");
{
#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.");
}
{
#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
}
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;
}
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;
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;
}
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);
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);
}
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;
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;
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;
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");
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,
--- /dev/null
+#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 <Evas_Common.h>
+
+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
--- /dev/null
+#include "evas_common_private.h"
+#include "evas_private.h"
+#include "evas_native_common.h"
+
+#ifdef HAVE_DLSYM
+# include <dlfcn.h> /* dlopen,dlclose,etc */
+#else
+# warning native_tbm should not get compiled if dlsym is not found on the system!
+#endif
+
+#define EVAS_ROUND_UP_4(num) (((num)+3) & ~3)
+#define EVAS_ROUND_UP_8(num) (((num)+7) & ~7)
+
+#define TBM_SURF_PLANE_MAX 4 /**< maximum number of the planes */
+
+/* option to map the tbm_surface */
+#define TBM_SURF_OPTION_READ (1 << 0) /**< access option to read */
+#define TBM_SURF_OPTION_WRITE (1 << 1) /**< access option to write */
+
+#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 */
+#define TBM_FORMAT_NV12 __tbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
+#define TBM_FORMAT_YUV420 __tbm_fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
+#define TBM_FORMAT_YVU420 __tbm_fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
+
+static void *tbm_lib = NULL;
+static int tbm_ref = 0;
+
+typedef struct _tbm_surface * tbm_surface_h;
+typedef uint32_t tbm_format;
+
+typedef struct _tbm_surface_plane
+{
+ unsigned char *ptr; /**< Plane pointer */
+ uint32_t size; /**< Plane size */
+ uint32_t offset; /**< Plane offset */
+ uint32_t stride; /**< Plane stride */
+
+ void *reserved1; /**< Reserved pointer1 */
+ void *reserved2; /**< Reserved pointer2 */
+ void *reserved3; /**< Reserved pointer3 */
+} tbm_surface_plane_s;
+
+typedef struct _tbm_surface_info
+{
+ uint32_t width; /**< TBM surface width */
+ uint32_t height; /**< TBM surface height */
+ tbm_format format; /**< TBM surface format*/
+ uint32_t bpp; /**< TBM surface bbp */
+ uint32_t size; /**< TBM surface size */
+
+ uint32_t num_planes; /**< The number of planes */
+ tbm_surface_plane_s planes[TBM_SURF_PLANE_MAX]; /**< Array of planes */
+
+ void *reserved4; /**< Reserved pointer4 */
+ void *reserved5; /**< Reserved pointer5 */
+ 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;
+
+static Eina_Bool
+tbm_init(void)
+{
+ if (tbm_lib)
+ {
+ tbm_ref++;
+ return EINA_TRUE;
+ }
+
+ const char *tbm_libs[] =
+ {
+ "libtbm.so.1",
+ "libtbm.so.0",
+ NULL,
+ };
+ int i, fail;
+#define SYM(lib, xx) \
+ do { \
+ sym_ ## xx = dlsym(lib, #xx); \
+ if (!(sym_ ## xx)) { \
+ ERR("%s", dlerror()); \
+ fail = 1; \
+ } \
+ } while (0)
+
+ for (i = 0; tbm_libs[i]; i++)
+ {
+ tbm_lib = dlopen(tbm_libs[i], RTLD_LOCAL | RTLD_LAZY);
+ if (tbm_lib)
+ {
+ fail = 0;
+ SYM(tbm_lib, tbm_surface_map);
+ SYM(tbm_lib, tbm_surface_unmap);
+ if (fail)
+ {
+ dlclose(tbm_lib);
+ tbm_lib = NULL;
+ }
+ else break;
+ }
+ }
+ if (!tbm_lib) return EINA_FALSE;
+
+ tbm_ref++;
+ return EINA_TRUE;
+}
+
+static void
+tbm_shutdown(void)
+{
+ if (tbm_ref > 0)
+ {
+ tbm_ref--;
+
+ if (tbm_ref == 0)
+ {
+ if (tbm_lib)
+ {
+ dlclose(tbm_lib);
+ tbm_lib = NULL;
+ }
+ }
+ }
+}
+
+static void
+_evas_video_yv12(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h, unsigned int output_height)
+{
+ const unsigned char **rows;
+ unsigned int i, j;
+ unsigned int rh;
+ unsigned int stride_y, stride_uv;
+
+ rh = output_height;
+
+ rows = (const unsigned char **)evas_data;
+
+ stride_y = EVAS_ROUND_UP_4(w);
+ stride_uv = EVAS_ROUND_UP_8(w) / 2;
+
+ for (i = 0; i < rh; i++)
+ rows[i] = &source_data[i * stride_y];
+
+ for (j = 0; j < (rh / 2); j++, i++)
+ rows[i] = &source_data[h * stride_y +
+ (rh / 2) * stride_uv +
+ j * stride_uv];
+
+ for (j = 0; j < (rh / 2); j++, i++)
+ rows[i] = &source_data[h * stride_y + j * stride_uv];
+}
+
+static void
+_evas_video_i420(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h, unsigned int output_height)
+{
+ const unsigned char **rows;
+ unsigned int i, j;
+ unsigned int rh;
+ unsigned int stride_y, stride_uv;
+
+ rh = output_height;
+
+ rows = (const unsigned char **)evas_data;
+
+ stride_y = EVAS_ROUND_UP_4(w);
+ stride_uv = EVAS_ROUND_UP_8(w) / 2;
+
+ for (i = 0; i < rh; i++)
+ rows[i] = &source_data[i * stride_y];
+
+ for (j = 0; j < (rh / 2); j++, i++)
+ rows[i] = &source_data[h * stride_y + j * stride_uv];
+
+ for (j = 0; j < (rh / 2); j++, i++)
+ rows[i] = &source_data[h * stride_y +
+ (rh / 2) * stride_uv +
+ j * stride_uv];
+}
+
+static void
+_evas_video_nv12(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height)
+{
+ const unsigned char **rows;
+ unsigned int i, j;
+ unsigned int rh;
+
+ rh = output_height;
+
+ rows = (const unsigned char **)evas_data;
+
+ for (i = 0; i < rh; i++)
+ rows[i] = &source_data[i * w];
+
+ for (j = 0; j < (rh / 2); j++, i++)
+ rows[i] = &source_data[rh * w + j * w];
+}
+
+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;
+ Native *n = im->native.data;
+ tbm_surface_info_s info;
+ tbm_surface_h tbm_surf;
+
+ if (!im || !n) return;
+ if (n->ns.type != EVAS_NATIVE_SURFACE_TBM)
+ 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;
+}
+
+static void
+_native_unbind_cb(void *data EINA_UNUSED, void *image)
+{
+ RGBA_Image *im = image;
+ Native *n = im->native.data;
+ tbm_surface_h tbm_surf;
+
+ if (!im || !n) return;
+ if (n->ns.type != EVAS_NATIVE_SURFACE_TBM)
+ return;
+
+ 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 = image;
+ Native *n = im->native.data;
+
+ if (!im) return;
+ im->native.data = NULL;
+ im->native.func.bind = NULL;
+ im->native.func.unbind = NULL;
+ im->native.func.free = NULL;
+ im->native.func.data = NULL;
+ im->image.data = NULL;
+
+ free(n);
+
+ tbm_shutdown();
+}
+
+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)
+ {
+ void *pixels_data;
+ int w, h, stride;
+ tbm_format format;
+ 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!");
+ return NULL;
+ }
+
+ n = calloc(1, sizeof(Native));
+ if (!n) return NULL;
+
+ if (sym_tbm_surface_map(tbm_surf, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info))
+ {
+ free(n);
+ return im;
+ }
+
+ w = info.width;
+ h = info.height;
+ stride = info.planes[0].stride;
+ format = info.format;
+ pixels_data = info.planes[0].ptr;
+ im->cache_entry.w = stride;
+ im->cache_entry.h = h;
+
+ // Handle all possible format here :"(
+ switch (format)
+ {
+ 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);
+ im->image.data = pixels_data;
+ im->image.no_free = 1;
+ break;
+ /* borrowing code from emotion here */
+ case TBM_FORMAT_YVU420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
+ evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
+ _evas_video_yv12(im->cs.data, pixels_data, w, h, h);
+ evas_common_image_colorspace_dirty(im);
+ break;
+ case TBM_FORMAT_YUV420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
+ evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
+ _evas_video_i420(im->cs.data, pixels_data, w, h, h);
+ evas_common_image_colorspace_dirty(im);
+ break;
+ case TBM_FORMAT_NV12: /* EVAS_COLORSPACE_YCBCR420NV12601_PL */
+ evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR420NV12601_PL);
+ _evas_video_nv12(im->cs.data, pixels_data, w, h, h);
+ evas_common_image_colorspace_dirty(im);
+ break;
+ /* Not planning to handle those in software */
+ default:
+ sym_tbm_surface_unmap(ns->data.tbm.buffer);
+ free(n);
+ return im;
+ }
+
+ memcpy(n, ns, sizeof(Evas_Native_Surface));
+ im->native.data = n;
+ im->native.func.bind = _native_bind_cb;
+ im->native.func.unbind = _native_unbind_cb;
+ im->native.func.free = _native_free_cb;
+
+ sym_tbm_surface_unmap(tbm_surf);
+ }
+ return im;
+}
#include "evas_x_egl.h"
#endif
+#include "../software_generic/evas_native_common.h"
+
+#ifdef HAVE_DLSYM
+# include <dlfcn.h>
+#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) */
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)
}
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)
{
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;
ORD(image_native_set);
ORD(image_native_get);
+ _symbols();
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;
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
+++ /dev/null
-#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"
-
-#ifdef HAVE_DLSYM
-# include <dlfcn.h> /* dlopen,dlclose,etc */
-#else
-# warning native_tbm should not get compiled if dlsym is not found on the system!
-#endif
-
-#define EVAS_ROUND_UP_4(num) (((num)+3) & ~3)
-#define EVAS_ROUND_UP_8(num) (((num)+7) & ~7)
-
-#define TBM_SURF_PLANE_MAX 4 /**< maximum number of the planes */
-
-/* option to map the tbm_surface */
-#define TBM_SURF_OPTION_READ (1 << 0) /**< access option to read */
-#define TBM_SURF_OPTION_WRITE (1 << 1) /**< access option to write */
-
-#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_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 */
-#define TBM_FORMAT_NV12 __tbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
-#define TBM_FORMAT_YUV420 __tbm_fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
-#define TBM_FORMAT_YVU420 __tbm_fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
-
-static void *tbm_lib = NULL;
-static int tbm_ref = 0;
-
-typedef struct _tbm_surface * tbm_surface_h;
-typedef uint32_t tbm_format;
-
-typedef struct _tbm_surface_plane
-{
- unsigned char *ptr; /**< Plane pointer */
- uint32_t size; /**< Plane size */
- uint32_t offset; /**< Plane offset */
- uint32_t stride; /**< Plane stride */
-
- void *reserved1; /**< Reserved pointer1 */
- void *reserved2; /**< Reserved pointer2 */
- void *reserved3; /**< Reserved pointer3 */
-} tbm_surface_plane_s;
-
-typedef struct _tbm_surface_info
-{
- uint32_t width; /**< TBM surface width */
- uint32_t height; /**< TBM surface height */
- tbm_format format; /**< TBM surface format*/
- uint32_t bpp; /**< TBM surface bbp */
- uint32_t size; /**< TBM surface size */
-
- uint32_t num_planes; /**< The number of planes */
- tbm_surface_plane_s planes[TBM_SURF_PLANE_MAX]; /**< Array of planes */
-
- void *reserved4; /**< Reserved pointer4 */
- void *reserved5; /**< Reserved pointer5 */
- 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;
-
-static Eina_Bool
-tbm_init(void)
-{
- if (tbm_lib)
- {
- tbm_ref++;
- return EINA_TRUE;
- }
-
- const char *tbm_libs[] =
- {
- "libtbm.so.1",
- "libtbm.so.0",
- NULL,
- };
- int i, fail;
-#define SYM(lib, xx) \
- do { \
- sym_ ## xx = dlsym(lib, #xx); \
- if (!(sym_ ## xx)) { \
- ERR("%s", dlerror()); \
- fail = 1; \
- } \
- } while (0)
-
- for (i = 0; tbm_libs[i]; i++)
- {
- tbm_lib = dlopen(tbm_libs[i], RTLD_LOCAL | RTLD_LAZY);
- if (tbm_lib)
- {
- fail = 0;
- SYM(tbm_lib, tbm_surface_map);
- SYM(tbm_lib, tbm_surface_unmap);
- if (fail)
- {
- dlclose(tbm_lib);
- tbm_lib = NULL;
- }
- else break;
- }
- }
- if (!tbm_lib) return EINA_FALSE;
-
- tbm_ref++;
- return EINA_TRUE;
-}
-
-static void
-tbm_shutdown(void)
-{
- if (tbm_ref > 0)
- {
- tbm_ref--;
-
- if (tbm_ref == 0)
- {
- if (tbm_lib)
- {
- dlclose(tbm_lib);
- tbm_lib = NULL;
- }
- }
- }
-}
-
-static void
-_evas_video_yv12(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h, unsigned int output_height)
-{
- const unsigned char **rows;
- unsigned int i, j;
- unsigned int rh;
- unsigned int stride_y, stride_uv;
-
- rh = output_height;
-
- rows = (const unsigned char **)evas_data;
-
- stride_y = EVAS_ROUND_UP_4(w);
- stride_uv = EVAS_ROUND_UP_8(w) / 2;
-
- for (i = 0; i < rh; i++)
- rows[i] = &source_data[i * stride_y];
-
- for (j = 0; j < (rh / 2); j++, i++)
- rows[i] = &source_data[h * stride_y +
- (rh / 2) * stride_uv +
- j * stride_uv];
-
- for (j = 0; j < (rh / 2); j++, i++)
- rows[i] = &source_data[h * stride_y + j * stride_uv];
-}
-
-static void
-_evas_video_i420(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h, unsigned int output_height)
-{
- const unsigned char **rows;
- unsigned int i, j;
- unsigned int rh;
- unsigned int stride_y, stride_uv;
-
- rh = output_height;
-
- rows = (const unsigned char **)evas_data;
-
- stride_y = EVAS_ROUND_UP_4(w);
- stride_uv = EVAS_ROUND_UP_8(w) / 2;
-
- for (i = 0; i < rh; i++)
- rows[i] = &source_data[i * stride_y];
-
- for (j = 0; j < (rh / 2); j++, i++)
- rows[i] = &source_data[h * stride_y + j * stride_uv];
-
- for (j = 0; j < (rh / 2); j++, i++)
- rows[i] = &source_data[h * stride_y +
- (rh / 2) * stride_uv +
- j * stride_uv];
-}
-
-static void
-_evas_video_nv12(unsigned char *evas_data, const unsigned char *source_data, unsigned int w, unsigned int h EINA_UNUSED, unsigned int output_height)
-{
- const unsigned char **rows;
- unsigned int i, j;
- unsigned int rh;
-
- rh = output_height;
-
- rows = (const unsigned char **)evas_data;
-
- for (i = 0; i < rh; i++)
- rows[i] = &source_data[i * w];
-
- for (j = 0; j < (rh / 2); j++, i++)
- rows[i] = &source_data[rh * w + j * w];
-}
-
-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;
-
- n = im->native.data;
- if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM))
- {
- tbm_surface_info_s info;
-
- if (sym_tbm_surface_map(n->ns.data.tbm.buffer, TBM_SURF_OPTION_READ|TBM_SURF_OPTION_WRITE, &info)) return;
-
- im->image.data = (DATA32 *)info.planes[0].ptr;
- }
-}
-
-static void
-_native_unbind_cb(void *data EINA_UNUSED, void *image)
-{
- RGBA_Image *im;
- Native *n;
-
- if (!(im = image)) return;
-
- n = im->native.data;
- if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_TBM))
- {
- sym_tbm_surface_unmap(n->ns.data.tbm.buffer);
- }
-}
-
-static void
-_native_free_cb(void *data EINA_UNUSED, void *image)
-{
- RGBA_Image *im;
- Native *n;
-
- if (!(im = image)) return;
-
- n = im->native.data;
-
- im->native.data = NULL;
- im->native.func.bind = NULL;
- im->native.func.unbind = NULL;
- im->native.func.free = NULL;
- im->native.func.data = NULL;
- im->image.data = NULL;
-
- free(n);
-
- tbm_shutdown();
-}
-
-void *
-evas_native_tbm_image_set(void *data EINA_UNUSED, void *image, void *native)
-{
- Evas_Native_Surface *ns = native;
- RGBA_Image *im = image;
-
- if (!im) return NULL;
- if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_TBM))
- {
- void *pixels_data;
- int w, h, stride;
- tbm_format format;
- tbm_surface_info_s info;
- Native *n;
-
- if (!tbm_init())
- {
- ERR("Could not initialize TBM!");
- return NULL;
- }
-
- 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))
- {
- free(n);
- return im;
- }
-
- w = info.width;
- h = info.height;
- stride = info.planes[0].stride;
- format = info.format;
- pixels_data = info.planes[0].ptr;
- im->cache_entry.w = stride;
- im->cache_entry.h = h;
-
- // Handle all possible format here :"(
- switch (format)
- {
- case TBM_FORMAT_RGBA8888:
- case TBM_FORMAT_RGBX8888:
- case TBM_FORMAT_BGRA8888:
- 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);
- im->image.data = pixels_data;
- im->image.no_free = 1;
- break;
- /* borrowing code from emotion here */
- case TBM_FORMAT_YVU420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
- evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
- _evas_video_yv12(im->cs.data, pixels_data, w, h, h);
- evas_common_image_colorspace_dirty(im);
- break;
- case TBM_FORMAT_YUV420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
- evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
- _evas_video_i420(im->cs.data, pixels_data, w, h, h);
- evas_common_image_colorspace_dirty(im);
- break;
- case TBM_FORMAT_NV12: /* EVAS_COLORSPACE_YCBCR420NV12601_PL */
- evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR420NV12601_PL);
- _evas_video_nv12(im->cs.data, pixels_data, w, h, h);
- evas_common_image_colorspace_dirty(im);
- break;
- /* Not planning to handle those in software */
- default:
- sym_tbm_surface_unmap(ns->data.tbm.buffer);
- free(n);
- return im;
- }
-
- memcpy(n, ns, sizeof(Evas_Native_Surface));
- im->native.data = n;
- im->native.func.bind = _native_bind_cb;
- im->native.func.unbind = _native_unbind_cb;
- im->native.func.free = _native_free_cb;
-
- sym_tbm_surface_unmap(ns->data.tbm.buffer);
- }
- return im;
-}
-
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);
}
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;
}
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;
#include "evas_engine.h"
#include <Ecore_X.h>
-
-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);
#include "evas_common_private.h"
#include "evas_xlib_dri_image.h"
+#include "../software_generic/evas_native_common.h"
# include <dlfcn.h> /* dlopen,dlclose,etc */
# include <sys/types.h>
Eina_Bool
evas_xlib_image_get_buffers(RGBA_Image *im)
{
- DRI_Native *n = NULL;
+ Native *n = NULL;
Display *d;
Evas_DRI_Image *exim;
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;
_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))
{
_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;
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;
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);
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;
}
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);
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);
}
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;
}
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;
#include "evas_engine.h"
#include <Ecore_X.h>
-
-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);
#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 <dlfcn.h>
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
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
}
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)
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
{
// nothing
}
+ else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
+ {
+ // nothing
+ }
}
static void
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.");
}
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;
}
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;
}
}
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;
}
}
}
+ 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,
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);
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,
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;
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;
}
}
}
+ 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)
{