jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=576f2ccab7d3f83cff00d08c6610f3fd97375f1d
commit 576f2ccab7d3f83cff00d08c6610f3fd97375f1d Author: Jean-Philippe Andre <jp.an...@samsung.com> Date: Mon Jul 13 13:51:10 2015 +0900 Evas GL: Fix evasglImageDestroy() from non-evasgl threads If the TLS variable was not initialized, Evas GL can't get a pointer to a valid EGLDisplay which is required by eglImageDestroy. So, we keep track of the dpy used at creation time and use that if we're in another thread. --- src/lib/evas/Evas_GL.h | 3 ++ .../evas/engines/gl_common/evas_gl_api_ext.c | 34 ++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/lib/evas/Evas_GL.h b/src/lib/evas/Evas_GL.h index 255ccfc..f25cd50 100644 --- a/src/lib/evas/Evas_GL.h +++ b/src/lib/evas/Evas_GL.h @@ -4143,6 +4143,9 @@ struct _Evas_GL_API * Destroy an image created by either @ref evasglCreateImage or @ref evasglCreateImageForContext. * * Requires the @c EVAS_GL_image extension. + * + * @note Unlike in pure EGL, the display pointer needs not be passed in, as + * Evas GL will use the same EGLDisplay as used in the create function. */ void (*evasglDestroyImage) (EvasGLImage image); diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c index ea74dd4..ef5ee4f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c +++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c @@ -116,6 +116,13 @@ struct wl_resource; // Evas extensions from EGL extensions #ifdef GL_GLES #define EGLDISPLAY_GET() _evgl_egl_display_get(__FUNCTION__) + +// this struct defines an EvasGLImage when using EGL +typedef struct _EvasGLImage { + EGLDisplay dpy; + EGLImageKHR img; +} EvasGLImage_EGL; + static EGLDisplay _evgl_egl_display_get(const char *function) { @@ -153,7 +160,9 @@ static void * _evgl_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, int target, void* buffer, const int *attrib_list) { + EvasGLImage_EGL *img; int *attribs = NULL; + void *eglimg; /* Convert 0 terminator into a EGL_NONE terminator */ if (attrib_list) @@ -177,7 +186,13 @@ _evgl_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, *a = EGL_NONE; } - return EXT_FUNC_EGL(eglCreateImage)(dpy, ctx, target, buffer, attribs); + eglimg = EXT_FUNC_EGL(eglCreateImage)(dpy, ctx, target, buffer, attribs); + if (!eglimg) return NULL; + + img = calloc(1, sizeof(EvasGLImage_EGL)); + img->dpy = dpy; + img->img = eglimg; + return img; } static void * @@ -215,20 +230,29 @@ static void evgl_evasglDestroyImage(EvasGLImage image) { EGLDisplay dpy = EGLDISPLAY_GET(); - if (!dpy) return; - EXT_FUNC_EGL(eglDestroyImage)(dpy, image); + EvasGLImage_EGL *img = image; + + if (dpy) + EXT_FUNC_EGL(eglDestroyImage)(dpy, img->img); + else + EXT_FUNC_EGL(eglDestroyImage)(img->dpy, img->img); + free(img); } static void evgl_glEvasGLImageTargetTexture2D(GLenum target, EvasGLImage image) { - EXT_FUNC(glEGLImageTargetTexture2DOES)(target, image); + EvasGLImage_EGL *img = image; + + EXT_FUNC(glEGLImageTargetTexture2DOES)(target, img->img); } static void evgl_glEvasGLImageTargetRenderbufferStorage(GLenum target, EvasGLImage image) { - EXT_FUNC(glEGLImageTargetRenderbufferStorageOES)(target, image); + EvasGLImage_EGL *img = image; + + EXT_FUNC(glEGLImageTargetRenderbufferStorageOES)(target, img->img); } static EvasGLSync --