summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-10-14 16:03:47 -0500
committerDerek Foreman <derekf@osg.samsung.com>2016-10-14 16:07:08 -0500
commit3d6aae46331ec186b5b7db232925da76894d132e (patch)
tree515ab3aa1d866daee84f1a6efe4f5fadbae45197
parent54582858d8422c4594899eba7209b12c9b704c27 (diff)
downloadefl-3d6aae46331ec186b5b7db232925da76894d132e.tar.gz
evas gl x11 engine - Wrap eglCreateImage
eglCreateImage and eglCreateImageKHR have different parameters - the attribute list is EGLint for one and EGLAttrib for the other. Since EGLAttrib is long, on a 64-bit system it's a different size than EGLint. This was causing a crash in Enlightenment's wl_x11 on 64-bit machines when trying to use a gl client. Add a thin wrapper to use whichever is available and pass the appropriate sized data.
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c79
1 files changed, 53 insertions, 26 deletions
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index e0938c151f..f79d566345 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -80,7 +80,8 @@ glsym_func_void_ptr glsym_evas_gl_common_current_context_get = NULL;
#ifdef GL_GLES
_eng_fn (*glsym_eglGetProcAddress) (const char *a) = NULL;
-void *(*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const int *e) = NULL;
+EGLImage (*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const EGLAttrib *e) = NULL;
+EGLImage (*glsym_eglCreateImageKHR) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, EGLint *e) = NULL;
void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL;
@@ -1325,6 +1326,31 @@ gl_symbols(void)
done = 1;
}
+#ifdef GL_GLES
+static EGLImage
+_eflCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
+{
+ if (glsym_eglCreateImage)
+ return glsym_eglCreateImage(dpy, ctx, target, buffer, attrib_list);
+ if (glsym_eglCreateImageKHR)
+ {
+ int count, i;
+ EGLint *ints = NULL;
+
+ if (attrib_list)
+ {
+ for (count = 0; attrib_list[count] != EGL_NONE; count += 2);
+ count++;
+ ints = alloca(count * sizeof(EGLint));
+ for (i = 0; i < count; i++)
+ ints[i] = attrib_list[i];
+ }
+ return glsym_eglCreateImageKHR(dpy, ctx, target, buffer, ints);
+ }
+ return NULL;
+}
+#endif
+
void
eng_gl_symbols(Outbuf *ob)
{
@@ -1358,8 +1384,8 @@ eng_gl_symbols(Outbuf *ob)
exts = eglQueryString(ob->egl_disp, EGL_EXTENSIONS);
FINDSYM(glsym_eglCreateImage, "eglCreateImage", NULL, glsym_func_void_ptr);
- FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", "EGL_KHR_image_base", glsym_func_void_ptr);
- FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", "EGL_KHR_image", glsym_func_void_ptr);
+ FINDSYM(glsym_eglCreateImageKHR, "eglCreateImageKHR", "EGL_KHR_image_base", glsym_func_void_ptr);
+ FINDSYM(glsym_eglCreateImageKHR, "eglCreateImageKHR", "EGL_KHR_image", glsym_func_void_ptr);
FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", NULL, glsym_func_void);
FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", "EGL_KHR_image_base", glsym_func_void);
@@ -2042,7 +2068,8 @@ _native_bind_cb(void *image)
if (n->ns_data.x11.multiple_buffer)
{
EGLint err;
- if (!glsym_eglDestroyImage || !glsym_eglCreateImage)
+ if (!glsym_eglDestroyImage ||
+ (!glsym_eglCreateImage && !glsym_eglCreateImageKHR))
{
ERR("Try eglDestroyImage()/eglCreateImage() on EGL with no support");
return;
@@ -2055,11 +2082,11 @@ _native_bind_cb(void *image)
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
}
- n->ns_data.x11.surface = glsym_eglCreateImage(im->native.disp,
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (void *)n->ns_data.x11.pixmap,
- NULL);
+ n->ns_data.x11.surface = _eflCreateImage(im->native.disp,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (void *)n->ns_data.x11.pixmap,
+ NULL);
if (!n->ns_data.x11.surface)
ERR("eglCreateImage() for Pixmap 0x%#lx failed: %#x", n->ns_data.x11.pixmap, eglGetError());
@@ -2594,7 +2621,7 @@ eng_image_native_set(void *data, void *image, void *native)
#ifdef GL_GLES
if (native)
{
- if (!glsym_eglCreateImage)
+ if (!glsym_eglCreateImage && !glsym_eglCreateImageKHR)
{
ERR("Try eglCreateImage on EGL with no support");
return NULL;
@@ -2651,10 +2678,10 @@ eng_image_native_set(void *data, void *image, void *native)
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
n->ns_data.x11.pixmap = pm;
n->ns_data.x11.visual = vis;
- n->ns_data.x11.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (void *)pm, NULL);
+ n->ns_data.x11.surface = _eflCreateImage(eng_get_ob(re)->egl_disp,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (void *)pm, NULL);
if ((ns->version < 4) ||
((ns->version == 4) && !(ns->data.x11.multiple_buffer == 1)))
@@ -2941,12 +2968,12 @@ eng_image_native_set(void *data, void *image, void *native)
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);
+ if (glsym_eglCreateImage || glsym_eglCreateImageKHR)
+ n->ns_data.tbm.surface = _eflCreateImage(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)
@@ -3010,7 +3037,7 @@ eng_image_native_set(void *data, void *image, void *native)
{
if ((n = calloc(1, sizeof(Native))))
{
- EGLint attribs[3];
+ EGLAttrib attribs[3];
int format, yinvert = 1;
glsym_eglQueryWaylandBufferWL(eng_get_ob(re)->egl_disp, wl_buf,
@@ -3037,11 +3064,11 @@ eng_image_native_set(void *data, void *image, void *native)
&wlid, im);
n->ns_data.wl_surface.wl_buf = wl_buf;
- if (glsym_eglCreateImage)
- n->ns_data.wl_surface.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
- NULL,
- EGL_WAYLAND_BUFFER_WL,
- wl_buf, attribs);
+ if (glsym_eglCreateImage || glsym_eglCreateImageKHR)
+ n->ns_data.wl_surface.surface = _eflCreateImage(eng_get_ob(re)->egl_disp,
+ NULL,
+ EGL_WAYLAND_BUFFER_WL,
+ wl_buf, attribs);
else
{
ERR("Try eglCreateImage on EGL with no support");