jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=660bfcf3c2bafb58bf0957c28f92572195ffa3ec

commit 660bfcf3c2bafb58bf0957c28f92572195ffa3ec
Author: Dongyeon Kim <dy5....@samsung.com>
Date:   Thu Apr 30 12:20:29 2015 +0900

    Evas GL: Separate EGL and GL extension lists
    
    Summary:
    Separate EGL extensions from GL/GLES extension list, since
    we have extension list for each GL version, and we do not want to
    check EGL extensions differently when different GL versions are used.
    This also simplifies extension string get function as we just need to
    concatenate EGL and GL extensions rathan than keeping track of
    GL extensions only.
---
 src/modules/evas/engines/gl_common/evas_gl_api.c   |   2 +-
 .../evas/engines/gl_common/evas_gl_api_ext.c       | 295 +++++++++++++++++++--
 .../evas/engines/gl_common/evas_gl_api_ext.h       |  13 +-
 .../evas/engines/gl_common/evas_gl_api_ext_def.h   |  89 ++++---
 src/modules/evas/engines/gl_common/evas_gl_core.c  |  35 ++-
 5 files changed, 361 insertions(+), 73 deletions(-)

diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c 
b/src/modules/evas/engines/gl_common/evas_gl_api.c
index 6ef7a3d..2d75586 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -727,7 +727,7 @@ _evgl_glGetString(GLenum name)
 #endif
 
       case GL_EXTENSIONS:
-        // Passing the verion -  GLESv2/GLESv3.
+        // Passing the version -  GLESv2/GLESv3.
         return (GLubyte *) evgl_api_ext_string_get(EINA_TRUE, 
rsc->current_ctx->version);
 
       default:
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 1d9869e..639f60c 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
@@ -3,14 +3,20 @@
 
 #include <dlfcn.h>
 
-// list of exts like "discard_framebuffer GL_EXT_discard_framebuffer 
multi_draw_arrays GL_EXT_multi_draw_arrays"
+// list of egl extensions
+#ifdef GL_GLES
+static char *_egl_ext_string = NULL;
+#endif
+// list of gles 2.0 exts by official name
 static char *_gl_ext_string = NULL;
 // list of exts by official name only like "GL_EXT_discard_framebuffer 
GL_EXT_multi_draw_arrays"
 static char *_gl_ext_string_official = NULL;
 // list of gles 1.1 exts by official name
 static char *_gles1_ext_string = NULL;
+static char *_gles1_ext_string_official = NULL;
 // list of gles 3.1 exts by official name
 static char *_gles3_ext_string = NULL;
+static char *_gles3_ext_string_official = NULL;
 
 typedef void (*_getproc_fn) (void);
 typedef _getproc_fn (*fp_getproc)(const char *);
@@ -35,6 +41,7 @@ struct wl_resource;
 #define _EVASGL_EXT_DRVNAME_PRIVATE(name)
 #define _EVASGL_EXT_DRVNAME_DESKTOP(deskname)
 #define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) \
+   ret (*egl_ext_sym_##name) param = NULL; \
    ret (*gl_ext_sym_##name) param = NULL; \
    ret (*gles1_ext_sym_##name) param = NULL; \
    ret (*gles3_ext_sym_##name) param = NULL;
@@ -67,12 +74,14 @@ struct wl_resource;
 #define _EVASGL_EXT_CHECK_SUPPORT(name)
 #define _EVASGL_EXT_DISCARD_SUPPORT()
 #define _EVASGL_EXT_BEGIN(name) \
+   int _egl_ext_support_##name = 0; \
    int _gl_ext_support_##name = 0; \
    int _gles1_ext_support_##name = 0; \
    int _gles3_ext_support_##name = 0;
 #define _EVASGL_EXT_END()
 #define _EVASGL_EXT_DRVNAME(name)
 #define _EVASGL_EXT_DRVNAME_PRIVATE(name) \
+   int _egl_ext_support_func_##name = 0; \
    int _gl_ext_support_func_##name = 0; \
    int _gles1_ext_support_func_##name = 0; \
    int _gles3_ext_support_func_##name = 0;
@@ -86,6 +95,8 @@ struct wl_resource;
 
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -166,7 +177,7 @@ _evgl_eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx,
         *a = EGL_NONE;
      }
 
-   return EXT_FUNC(eglCreateImage)(dpy, ctx, target, buffer, attribs);
+   return EXT_FUNC_EGL(eglCreateImage)(dpy, ctx, target, buffer, attribs);
 }
 
 static void *
@@ -205,7 +216,7 @@ evgl_evasglDestroyImage(EvasGLImage image)
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return;
-   EXT_FUNC(eglDestroyImage)(dpy, image);
+   EXT_FUNC_EGL(eglDestroyImage)(dpy, image);
 }
 
 static void
@@ -226,7 +237,7 @@ evgl_evasglCreateSync(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return NULL;
-   return EXT_FUNC(eglCreateSyncKHR)(dpy, type, attrib_list);
+   return EXT_FUNC_EGL(eglCreateSyncKHR)(dpy, type, attrib_list);
 }
 
 static Eina_Bool
@@ -234,7 +245,7 @@ evgl_evasglDestroySync(Evas_GL *evas_gl EINA_UNUSED, 
EvasGLSync sync)
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglDestroySyncKHR)(dpy, sync);
+   return EXT_FUNC_EGL(eglDestroySyncKHR)(dpy, sync);
 }
 
 static int
@@ -243,7 +254,7 @@ evgl_evasglClientWaitSync(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglClientWaitSyncKHR)(dpy, sync, flags, timeout);
+   return EXT_FUNC_EGL(eglClientWaitSyncKHR)(dpy, sync, flags, timeout);
 }
 
 static Eina_Bool
@@ -252,7 +263,7 @@ evgl_evasglSignalSync(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglSignalSyncKHR)(dpy, sync, mode);
+   return EXT_FUNC_EGL(eglSignalSyncKHR)(dpy, sync, mode);
 }
 
 static Eina_Bool
@@ -261,7 +272,7 @@ evgl_evasglGetSyncAttrib(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglGetSyncAttribKHR)(dpy, sync, attribute, value);
+   return EXT_FUNC_EGL(eglGetSyncAttribKHR)(dpy, sync, attribute, value);
 }
 
 static int
@@ -270,7 +281,7 @@ evgl_evasglWaitSync(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglWaitSyncKHR)(dpy, sync, flags);
+   return EXT_FUNC_EGL(eglWaitSyncKHR)(dpy, sync, flags);
 }
 
 static Eina_Bool
@@ -279,7 +290,7 @@ evgl_evasglBindWaylandDisplay(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglBindWaylandDisplayWL)(dpy, wl_display);
+   return EXT_FUNC_EGL(eglBindWaylandDisplayWL)(dpy, wl_display);
 }
 
 static Eina_Bool
@@ -288,7 +299,7 @@ evgl_evasglUnbindWaylandDisplay(Evas_GL *evas_gl 
EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglUnbindWaylandDisplayWL)(dpy, wl_display);
+   return EXT_FUNC_EGL(eglUnbindWaylandDisplayWL)(dpy, wl_display);
 }
 
 static Eina_Bool
@@ -297,7 +308,7 @@ evgl_evasglQueryWaylandBuffer(Evas_GL *evas_gl EINA_UNUSED,
 {
    EGLDisplay dpy = EGLDISPLAY_GET();
    if (!dpy) return EINA_FALSE;
-   return EXT_FUNC(eglQueryWaylandBufferWL)(dpy, buffer, attribute, value);
+   return EXT_FUNC_EGL(eglQueryWaylandBufferWL)(dpy, buffer, attribute, value);
 }
 
 
@@ -313,7 +324,171 @@ static int _evgl_api_ext_status = 0;
 #define EVASGL_API_GLES2_EXT_INITIALIZED 0x1
 #define EVASGL_API_GLES1_EXT_INITIALIZED 0x2
 #define EVASGL_API_GLES3_EXT_INITIALIZED 0x4
+#define EVASGL_API_EGL_EXT_INITIALIZED   0x8
+
+#ifdef GL_GLES
+Eina_Bool
+evgl_api_egl_ext_init(void *getproc, const char *glueexts)
+{
+   fp_getproc gp = (fp_getproc)getproc;
+   int _curext_supported = 0;
+   Eina_Strbuf *sb = NULL;
+
+   if (_evgl_api_ext_status & EVASGL_API_EGL_EXT_INITIALIZED)
+      return EINA_TRUE;
+
+   sb = eina_strbuf_new();
+
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+   // Extension HEADER
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+#define GETPROCADDR(sym) \
+   (((!(*drvfunc)) && (gp)) ? (__typeof__((*drvfunc)))gp(sym) : 
(__typeof__((*drvfunc)))dlsym(RTLD_DEFAULT, sym))
+
+#define _EVASGL_EXT_BEGIN(name) \
+     { \
+        int *ext_support = &_egl_ext_support_##name; \
+        *ext_support = 0;
+
+#define _EVASGL_EXT_END() \
+     }
+
+#define _EVASGL_EXT_CHECK_SUPPORT(name) \
+   (strstr(glueexts, name) != NULL)
+
+#define _EVASGL_EXT_DISCARD_SUPPORT() \
+   *ext_support = 0;
+
+#define _EVASGL_EXT_DRVNAME(name) \
+   if (_EVASGL_EXT_CHECK_SUPPORT(#name)) *ext_support = 1;
+
+#define _EVASGL_EXT_DRVNAME_PRIVATE(name) \
+   if (_EVASGL_EXT_CHECK_SUPPORT(#name)) { *ext_support = 1; 
_egl_ext_support_func_##name = 1; }
+
+#define _EVASGL_EXT_DRVNAME_DESKTOP(deskname) \
+   if (_EVASGL_EXT_CHECK_SUPPORT(deskname)) *ext_support = 1;
+
+#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) \
+     { \
+        ret (**drvfunc)param = &egl_ext_sym_##name; \
+        if (*ext_support == 1) \
+          {
+
+#define _EVASGL_EXT_FUNCTION_END() \
+          } \
+        if ((*drvfunc) == NULL) _EVASGL_EXT_DISCARD_SUPPORT(); \
+     }
+#define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_BEGIN()
+#define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END()
+#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) \
+   if ((*drvfunc) == NULL) *drvfunc = name;
+
+// This adds all the function names to the "safe" list but only one pointer
+// will be stored in the hash table.
+#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name) \
+   if ((*drvfunc) == NULL) \
+     { \
+        *drvfunc = GETPROCADDR(name); \
+        evgl_safe_extension_add(name, (void *) (*drvfunc)); \
+     } \
+   else evgl_safe_extension_add(name, NULL);
+
+#ifdef _EVASGL_EXT_FUNCTION_WHITELIST
+# undef _EVASGL_EXT_FUNCTION_WHITELIST
+#endif
+#define _EVASGL_EXT_FUNCTION_WHITELIST(name) evgl_safe_extension_add(name, 
NULL);
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 0
+#define _EVASGL_EXT_ENABLE_EGL 1
+
+#include "evas_gl_api_ext_def.h"
+
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
+#undef _EVASGL_EXT_FUNCTION_WHITELIST
+#undef _EVASGL_EXT_CHECK_SUPPORT
+#undef _EVASGL_EXT_DISCARD_SUPPORT
+#undef _EVASGL_EXT_BEGIN
+#undef _EVASGL_EXT_END
+#undef _EVASGL_EXT_DRVNAME
+#undef _EVASGL_EXT_DRVNAME_PRIVATE
+#undef _EVASGL_EXT_DRVNAME_DESKTOP
+#undef _EVASGL_EXT_FUNCTION_BEGIN
+#undef _EVASGL_EXT_FUNCTION_END
+#undef _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_BEGIN
+#undef _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END
+#undef _EVASGL_EXT_FUNCTION_DRVFUNC
+#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
+
+#undef GETPROCADDR
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+   // Extension HEADER
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+#define _EVASGL_EXT_BEGIN(name) \
+     if (_egl_ext_support_##name != 0) \
+       { \
+          eina_strbuf_append(sb, #name" "); \
+          _curext_supported = 1; \
+       } \
+     else _curext_supported = 0;
+
+#define _EVASGL_EXT_END()
+#define _EVASGL_EXT_CHECK_SUPPORT(name)
+#define _EVASGL_EXT_DISCARD_SUPPORT()
+#define _EVASGL_EXT_DRVNAME_PRINT(name) \
+       { \
+          if ((strncmp(name, "EGL_", 4) == 0) && 
(strstr(eina_strbuf_string_get(sb), name) == NULL)) \
+            eina_strbuf_append(sb, name" "); \
+       }
+#define _EVASGL_EXT_DRVNAME(name) \
+     if (_curext_supported) \
+       _EVASGL_EXT_DRVNAME_PRINT(#name)
+#define _EVASGL_EXT_DRVNAME_PRIVATE(name) \
+     if (_curext_supported && _egl_ext_support_func_##name) \
+       _EVASGL_EXT_DRVNAME_PRINT(#name)
+#define _EVASGL_EXT_DRVNAME_DESKTOP(deskname)
+#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param)
+#define _EVASGL_EXT_FUNCTION_END()
+#define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_BEGIN()
+#define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END()
+#define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
+#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
+
+#define _EVASGL_EXT_ENABLE_GL_GLES 0
+#define _EVASGL_EXT_ENABLE_EGL 1
+
+#include "evas_gl_api_ext_def.h"
+
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
+#undef _EVASGL_EXT_CHECK_SUPPORT
+#undef _EVASGL_EXT_DISCARD_SUPPORT
+#undef _EVASGL_EXT_BEGIN
+#undef _EVASGL_EXT_END
+#undef _EVASGL_EXT_DRVNAME_PRINT
+#undef _EVASGL_EXT_DRVNAME
+#undef _EVASGL_EXT_DRVNAME_DESKTOP
+#undef _EVASGL_EXT_DRVNAME_PRIVATE
+#undef _EVASGL_EXT_FUNCTION_BEGIN
+#undef _EVASGL_EXT_FUNCTION_END
+#undef _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_BEGIN
+#undef _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END
+#undef _EVASGL_EXT_FUNCTION_DRVFUNC
+#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
+   
/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+   if (_egl_ext_string) free(_egl_ext_string);
+   _egl_ext_string = eina_strbuf_string_steal(sb);
+   eina_strbuf_free(sb);
+
+  ERR("EGL extension string: %s", _egl_ext_string);
+
+  _evgl_api_ext_status |= EVASGL_API_EGL_EXT_INITIALIZED;
+   return EINA_TRUE;
+}
+#endif
 
 Eina_Bool
 _evgl_api_gles2_ext_init(void *getproc, const char *glueexts)
@@ -401,8 +576,13 @@ _evgl_api_gles2_ext_init(void *getproc, const char 
*glueexts)
 #endif
 #define _EVASGL_EXT_FUNCTION_WHITELIST(name) evgl_safe_extension_add(name, 
NULL);
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
+
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_FUNCTION_WHITELIST
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
@@ -454,9 +634,13 @@ _evgl_api_gles2_ext_init(void *getproc, const char 
*glueexts)
 #define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END()
 #define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
 #define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
 
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -524,8 +708,13 @@ evgl_api_gles2_ext_get(Evas_GL_API *gl_funcs, void 
*getproc, const char *glueext
 #undef _EVASGL_EXT_WHITELIST_ONLY
 #define _EVASGL_EXT_WHITELIST_ONLY 0
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
+
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_WHITELIST_ONLY
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
@@ -555,6 +744,7 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
    int _curext_supported = 0;
    Evas_GL_API *gles1_funcs;
    Eina_Strbuf *sb = eina_strbuf_new();
+   Eina_Strbuf *sboff = eina_strbuf_new();
 
 #ifdef GL_GLES
    EVGL_Resource *rsc;
@@ -665,12 +855,16 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
 #endif
 #define _EVASGL_EXT_FUNCTION_WHITELIST(name) evgl_safe_extension_add(name, 
NULL);
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
 #define _EVASGL_EXT_GLES1_ONLY 1
 
    // Okay, now we are ready to scan.
 #include "evas_gl_api_ext_def.h"
 
 #undef _EVASGL_EXT_GLES1_ONLY
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_FUNCTION_WHITELIST
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
@@ -688,7 +882,12 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
 #undef GETPROCADDR
 
 #define _EVASGL_EXT_BEGIN(name) \
-     _curext_supported = (_gles1_ext_support_##name != 0);
+     if (_gles1_ext_support_##name != 0) \
+       { \
+          eina_strbuf_append(sb, #name" "); \
+          _curext_supported = 1; \
+       } \
+     else _curext_supported = 0;
 
 
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -700,8 +899,9 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
 #define _EVASGL_EXT_DISCARD_SUPPORT()
 #define _EVASGL_EXT_DRVNAME_PRINT(name) \
      { \
-        if ((strncmp(name, "GL_", 3) == 0) && 
(strstr(eina_strbuf_string_get(sb), name) == NULL)) \
-          eina_strbuf_append(sb, name" "); \
+        eina_strbuf_append(sb, name" "); \
+        if ((strncmp(name, "GL_", 3) == 0) && 
(strstr(eina_strbuf_string_get(sboff), name) == NULL)) \
+          eina_strbuf_append(sboff, name" "); \
      }
 #define _EVASGL_EXT_DRVNAME(name) \
    if (_curext_supported) \
@@ -716,9 +916,13 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
 #define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END()
 #define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
 #define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
 
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -735,8 +939,11 @@ _evgl_api_gles1_ext_init(void *getproc, const char 
*glueexts)
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
 
    if (_gles1_ext_string) free(_gles1_ext_string);
+   if (_gles1_ext_string_official) free(_gles1_ext_string_official);
    _gles1_ext_string = eina_strbuf_string_steal(sb);
+   _gles1_ext_string_official = eina_strbuf_string_steal(sboff);
    eina_strbuf_free(sb);
+   eina_strbuf_free(sboff);
 
    if (evgl_engine->api_debug_mode)
      DBG("GLES1: List of supported extensions:\n%s", _gles1_ext_string);
@@ -786,9 +993,13 @@ evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs, void 
*getproc, const char *glueext
 
 #undef _EVASGL_EXT_WHITELIST_ONLY
 #define _EVASGL_EXT_WHITELIST_ONLY 0
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
 
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -817,6 +1028,7 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
    int _curext_supported = 0;
    Evas_GL_API *gles3_funcs;
    Eina_Strbuf *sb = eina_strbuf_new();
+   Eina_Strbuf *sboff = eina_strbuf_new();
 
 #ifdef GL_GLES
    EVGL_Resource *rsc;
@@ -924,9 +1136,14 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
 #endif
 #define _EVASGL_EXT_FUNCTION_WHITELIST(name) evgl_safe_extension_add(name, 
NULL);
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
+
    // Okay, now we are ready to scan.
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_FUNCTION_WHITELIST
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
@@ -944,7 +1161,12 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
 #undef GETPROCADDR
 
 #define _EVASGL_EXT_BEGIN(name) \
-     _curext_supported = (_gles3_ext_support_##name != 0);
+     if (_gles3_ext_support_##name != 0) \
+       { \
+          eina_strbuf_append(sb, #name" "); \
+          _curext_supported = 1; \
+       } \
+     else _curext_supported = 0;
 
 
    
/////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -956,8 +1178,9 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
 #define _EVASGL_EXT_DISCARD_SUPPORT()
 #define _EVASGL_EXT_DRVNAME_PRINT(name) \
      { \
-        if ((strncmp(name, "GL", 2) == 0) && 
(strstr(eina_strbuf_string_get(sb), name) == NULL)) \
-          eina_strbuf_append(sb, name" "); \
+        eina_strbuf_append(sb, name" "); \
+        if ((strncmp(name, "GL_", 3) == 0) && 
(strstr(eina_strbuf_string_get(sboff), name) == NULL)) \
+          eina_strbuf_append(sboff, name" "); \
      }
 #define _EVASGL_EXT_DRVNAME(name) \
    if (_curext_supported) \
@@ -973,8 +1196,13 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
 #define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
 #define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
+
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -991,8 +1219,11 @@ _evgl_api_gles3_ext_init(void *getproc, const char 
*glueexts)
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
 
    if (_gles3_ext_string) free(_gles3_ext_string);
+   if (_gles3_ext_string_official) free(_gles3_ext_string_official);
    _gles3_ext_string = eina_strbuf_string_steal(sb);
+   _gles3_ext_string_official = eina_strbuf_string_steal(sboff);
    eina_strbuf_free(sb);
+   eina_strbuf_free(sboff);
 
    if (evgl_engine->api_debug_mode)
      DBG("GLES3: List of supported extensions:\n%s", _gles3_ext_string);
@@ -1043,8 +1274,13 @@ evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void 
*getproc, const char *glueext
 #undef _EVASGL_EXT_WHITELIST_ONLY
 #define _EVASGL_EXT_WHITELIST_ONLY 0
 
+#define _EVASGL_EXT_ENABLE_GL_GLES 1
+#define _EVASGL_EXT_ENABLE_EGL 1
+
 #include "evas_gl_api_ext_def.h"
 
+#undef _EVASGL_EXT_ENABLE_EGL
+#undef _EVASGL_EXT_ENABLE_GL_GLES
 #undef _EVASGL_EXT_CHECK_SUPPORT
 #undef _EVASGL_EXT_DISCARD_SUPPORT
 #undef _EVASGL_EXT_BEGIN
@@ -1065,7 +1301,21 @@ evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void 
*getproc, const char *glueext
 
 }
 
+const char *
+evgl_api_ext_egl_string_get(void)
+{
+#ifdef GL_GLES
+   if (!(_evgl_api_ext_status & EVASGL_API_EGL_EXT_INITIALIZED))
+     {
+        ERR("EVGL extension for egl is not yet initialized.");
+        return NULL;
+     }
 
+   return _egl_ext_string;
+#else
+   return "";
+#endif
+}
 
 const char *
 evgl_api_ext_string_get(Eina_Bool official, int version)
@@ -1077,13 +1327,10 @@ evgl_api_ext_string_get(Eina_Bool official, int version)
      }
 
    if (version == EVAS_GL_GLES_1_X)
-     return _gles1_ext_string;
+     return (official?_gles1_ext_string_official:_gles1_ext_string);
 
    if (version == EVAS_GL_GLES_3_X)
-     return _gles3_ext_string;
-
-   if (official)
-     return _gl_ext_string_official;
+     return (official?_gles3_ext_string_official:_gles3_ext_string);
 
-   return _gl_ext_string;
+   return (official?_gl_ext_string_official:_gl_ext_string);
 }
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h 
b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
index f61fe19..2cd5bc9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
@@ -26,7 +26,11 @@
 #define _EVASGL_EXT_DRVNAME(name)
 #define _EVASGL_EXT_DRVNAME_PRIVATE(name)
 #define _EVASGL_EXT_DRVNAME_DESKTOP(deskname)
-#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) extern ret 
(*gl_ext_sym_##name) param;
+#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) \
+   extern ret (*egl_ext_sym_##name) param; \
+   extern ret (*gl_ext_sym_##name) param; \
+   extern ret (*gles1_ext_sym_##name) param; \
+   extern ret (*gles3_ext_sym_##name) param;
 #define _EVASGL_EXT_FUNCTION_END()
 #define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_BEGIN()
 #define _EVASGL_EXT_FUNCTION_DISABLE_FOR_GLES1_END()
@@ -49,6 +53,7 @@
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
 
/////////////////////////////////////////////////////////////////////////////////////////////////////
+#define EXT_FUNC_EGL(fname) egl_ext_sym_##fname
 #define EXT_FUNC(fname) gl_ext_sym_##fname
 #define EXT_FUNC_GLES1(fname) gles1_ext_sym_##fname
 #define EXT_FUNC_GLES3(fname) gles3_ext_sym_##fname
@@ -59,6 +64,7 @@
 #define _EVASGL_EXT_CHECK_SUPPORT(name)
 #define _EVASGL_EXT_DISCARD_SUPPORT()
 #define _EVASGL_EXT_BEGIN(name) \
+   extern int _egl_ext_support_##name; \
    extern int _gl_ext_support_##name; \
    extern int _gles1_ext_support_##name; \
    extern int _gles3_ext_support_##name;
@@ -89,13 +95,18 @@
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC
 #undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
 
/////////////////////////////////////////////////////////////////////////////////////////////////////
+#define EXTENSION_SUPPORT_EGL(name) (_egl_ext_support_##name == 1)
 #define EXTENSION_SUPPORT(name) (_gl_ext_support_##name == 1)
 #define EXTENSION_SUPPORT_GLES1(name) (_gles1_ext_support_##name == 1)
 #define EXTENSION_SUPPORT_GLES3(name) (_gles3_ext_support_##name == 1)
 
+#ifdef GL_GLES
+extern Eina_Bool evgl_api_egl_ext_init(void *getproc, const char *glueexts);
+#endif
 extern void evgl_api_gles2_ext_get(Evas_GL_API *gl_funcs, void *getproc, const 
char *glueexts);
 extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs, void *getproc, const 
char *glueexts);
 extern void evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void *getproc, const 
char *glueexts);
+extern const char *evgl_api_ext_egl_string_get(void);
 extern const char *evgl_api_ext_string_get(Eina_Bool official, int version);
 
 #endif //_EVAS_GL_API_EXT_H
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h 
b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
index 09a9b75..f20c3a7 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
@@ -64,6 +64,14 @@
 # define _EVASGL_EXT_WHITELIST_ONLY 1
 #endif
 
+#ifndef _EVASGL_EXT_ENABLE_GL_GLES
+# define _EVASGL_EXT_ENABLE_GL_GLES 1
+#endif
+
+#ifndef _EVASGL_EXT_ENABLE_EGL
+# define _EVASGL_EXT_ENABLE_EGL 1
+#endif
+
 #ifndef _EVASGL_EXT_FUNCTION_WHITELIST
 # define _EVASGL_EXT_FUNCTION_WHITELIST(name)
 #endif
@@ -71,6 +79,7 @@
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // GL/GLES EXTENSIONS
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#if _EVASGL_EXT_ENABLE_GL_GLES
 _EVASGL_EXT_BEGIN(get_program_binary)
        _EVASGL_EXT_DRVNAME(GL_OES_get_program_binary)
 
@@ -1143,7 +1152,46 @@ _EVASGL_EXT_BEGIN(shader_texture_lod)
         _EVASGL_EXT_DRVNAME(GL_EXT_shader_texture_lod)
 _EVASGL_EXT_END()
 
+#ifdef GL_GLES
+_EVASGL_EXT_BEGIN(GL_OES_EGL_image)
+
+       _EVASGL_EXT_DRVNAME(GL_OES_EGL_image)
+
+       _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(void, glEGLImageTargetTexture2DOES, 
(GLenum target, GLeglImageOES image))
+                
_EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glEGLImageTargetTexture2DOES")
+       _EVASGL_EXT_FUNCTION_PRIVATE_END()
+       _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(void, 
glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image))
+                
_EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glEGLImageTargetRenderbufferStorageOES")
+       _EVASGL_EXT_FUNCTION_PRIVATE_END()
+
+       _EVASGL_EXT_FUNCTION_BEGIN(void, glEvasGLImageTargetTexture2DOES, 
(GLenum target, EvasGLImage image))
+               _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_glEvasGLImageTargetTexture2D)
+       _EVASGL_EXT_FUNCTION_END()
+       _EVASGL_EXT_FUNCTION_BEGIN(void, 
glEvasGLImageTargetRenderbufferStorageOES, (GLenum target, EvasGLImage image))
+               
_EVASGL_EXT_FUNCTION_DRVFUNC(evgl_glEvasGLImageTargetRenderbufferStorage)
+       _EVASGL_EXT_FUNCTION_END()
+
+       #ifdef _EVASGL_EXT_VERIFY
+       {
+                if (!_EVASGL_EXT_CHECK_SUPPORT("EGL_KHR_image_base")) 
_EVASGL_EXT_DISCARD_SUPPORT();
+       }
+       #endif
+
+_EVASGL_EXT_END()
+
+
+_EVASGL_EXT_BEGIN(GL_OES_EGL_image_external)
+
+   _EVASGL_EXT_DRVNAME(GL_OES_EGL_image_external)
+
+       #ifdef _EVASGL_EXT_VERIFY
+   {
+                if (!_EVASGL_EXT_CHECK_SUPPORT("EGL_KHR_image_base")) 
_EVASGL_EXT_DISCARD_SUPPORT();
+   }
+       #endif
 
+_EVASGL_EXT_END()
+#endif // GL_GLES
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -1400,6 +1448,7 @@ _EVASGL_EXT_END()
 
 
 #endif // _EVASGL_EXT_WHITELIST_ONLY ("safe" extensions)
+#endif // _EVASGL_EXT_ENABLE_GL_GLES
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -1410,7 +1459,7 @@ _EVASGL_EXT_END()
 // EGL EXTENSIONS
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 #ifdef GL_GLES
-
+#if _EVASGL_EXT_ENABLE_EGL
 _EVASGL_EXT_BEGIN(EGL_KHR_image_base)
 
        _EVASGL_EXT_DRVNAME(EGL_KHR_image_base)
@@ -1444,34 +1493,6 @@ _EVASGL_EXT_END()
 
 
 
-_EVASGL_EXT_BEGIN(GL_OES_EGL_image)
-
-       _EVASGL_EXT_DRVNAME(GL_OES_EGL_image)
-
-       _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(void, glEGLImageTargetTexture2DOES, 
(GLenum target, GLeglImageOES image))
-                
_EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glEGLImageTargetTexture2DOES")
-       _EVASGL_EXT_FUNCTION_PRIVATE_END()
-       _EVASGL_EXT_FUNCTION_PRIVATE_BEGIN(void, 
glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image))
-                
_EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glEGLImageTargetRenderbufferStorageOES")
-       _EVASGL_EXT_FUNCTION_PRIVATE_END()
-
-       _EVASGL_EXT_FUNCTION_BEGIN(void, glEvasGLImageTargetTexture2DOES, 
(GLenum target, EvasGLImage image))
-               _EVASGL_EXT_FUNCTION_DRVFUNC(evgl_glEvasGLImageTargetTexture2D)
-       _EVASGL_EXT_FUNCTION_END()
-       _EVASGL_EXT_FUNCTION_BEGIN(void, 
glEvasGLImageTargetRenderbufferStorageOES, (GLenum target, EvasGLImage image))
-               
_EVASGL_EXT_FUNCTION_DRVFUNC(evgl_glEvasGLImageTargetRenderbufferStorage)
-       _EVASGL_EXT_FUNCTION_END()
-
-       #ifdef _EVASGL_EXT_VERIFY
-       {
-                if (!_EVASGL_EXT_CHECK_SUPPORT("EGL_KHR_image_base")) 
_EVASGL_EXT_DISCARD_SUPPORT();
-       }
-       #endif
-
-_EVASGL_EXT_END()
-
-
-
 _EVASGL_EXT_BEGIN(EGL_KHR_image_pixmap)
        _EVASGL_EXT_DRVNAME(EGL_KHR_image_pixmap)
        #ifdef _EVASGL_EXT_VERIFY
@@ -1542,14 +1563,6 @@ _EVASGL_EXT_BEGIN(EGL_KHR_gl_renderbuffer_image)
 _EVASGL_EXT_END()
 
 
-_EVASGL_EXT_BEGIN(GL_OES_EGL_image_external)
-        _EVASGL_EXT_DRVNAME(GL_OES_EGL_image_external)
-       #ifdef _EVASGL_EXT_VERIFY
-       {
-                if (!_EVASGL_EXT_CHECK_SUPPORT("EGL_KHR_image_base")) 
_EVASGL_EXT_DISCARD_SUPPORT();
-       }
-       #endif
-_EVASGL_EXT_END()
 
 
 _EVASGL_EXT_BEGIN(EGL_KHR_fence_sync)
@@ -1655,7 +1668,7 @@ _EVASGL_EXT_BEGIN(EGL_SEC_map_image)
 _EVASGL_EXT_END()
 #endif
 
-
+#endif // _EVASGL_EXT_ENABLE_EGL
 #endif
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c 
b/src/modules/evas/engines/gl_common/evas_gl_core.c
index 5325bfe..3b75ca3 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -266,7 +266,7 @@ _egl_image_create(EVGL_Context *context, int target, void 
*buffer)
    attribs[n++] = 0;
    attribs[n++] = EGL_NONE;
 
-   return EXT_FUNC(eglCreateImage)(dpy, ctx, target, 
(EGLClientBuffer)(uintptr_t)buffer, attribs);
+   return EXT_FUNC_EGL(eglCreateImage)(dpy, ctx, target, 
(EGLClientBuffer)(uintptr_t)buffer, attribs);
 #else
    (void) context; (void) target; (void) buffer;
    return NULL;
@@ -290,7 +290,7 @@ _egl_image_destroy(void *image)
    dpy = (EGLDisplay)rsc->display;
    if (!dpy) return;
 
-   EXT_FUNC(eglDestroyImage)(dpy, image);
+   EXT_FUNC_EGL(eglDestroyImage)(dpy, image);
 #else
    (void) image;
 #endif
@@ -883,10 +883,9 @@ _context_ext_check(EVGL_Context *ctx)
          fbo_supported = 1;
      }
 
-   if (EXTENSION_SUPPORT(EGL_KHR_image_base))
+   if (EXTENSION_SUPPORT_EGL(EGL_KHR_image_base))
      egl_image_supported = 1;
-
-   if (EXTENSION_SUPPORT(EGL_KHR_gl_texture_2D_image))
+   if (EXTENSION_SUPPORT_EGL(EGL_KHR_gl_texture_2D_image))
      texture_image_supported = 1;
 #else
    fbo_supported = 1;
@@ -2505,10 +2504,22 @@ evgl_string_query(int name)
    switch(name)
      {
       case EVAS_GL_EXTENSIONS:
-         rsc = _evgl_tls_resource_get();
-         if ((rsc) && (rsc->current_ctx))
-           ctx_version = rsc->current_ctx->version;
-         return evgl_api_ext_string_get(EINA_FALSE, ctx_version);
+        {
+           Eina_Strbuf *extstr = eina_strbuf_new();
+           const char *glstr = NULL, *eglstr = NULL, *str = NULL;
+           rsc = _evgl_tls_resource_get();
+           if ((rsc) && (rsc->current_ctx))
+             ctx_version = rsc->current_ctx->version;
+           glstr = evgl_api_ext_string_get(EINA_FALSE, ctx_version);
+           if (glstr)
+             eina_strbuf_append(extstr, glstr);
+           eglstr = evgl_api_ext_egl_string_get();
+           if (eglstr)
+             eina_strbuf_append(extstr, eglstr);
+           str = eina_strbuf_string_steal(extstr);
+           eina_strbuf_free(extstr);
+           return str;
+        }
 
       default:
          return "";
@@ -2756,6 +2767,12 @@ evgl_get_pixels_post(void)
 Evas_GL_API *
 evgl_api_get(void *eng_data, Evas_GL_Context_Version version)
 {
+#ifdef GL_GLES
+    if (!evgl_api_egl_ext_init(evgl_engine->funcs->proc_address_get, 
evgl_engine->funcs->ext_string_get(eng_data)))
+      {
+         ERR("EGL extensions initialization failed");
+      }
+#endif
    if (version == EVAS_GL_GLES_2_X)
      {
         if (!gles2_funcs) gles2_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);

-- 


Reply via email to