jpeg pushed a commit to branch master.

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

commit f30f55f9f444522397dbb2b83bce3371af5ea34b
Author: Jean-Philippe Andre <[email protected]>
Date:   Fri Sep 19 17:44:56 2014 +0900

    Evas GL: Fix compilation for EGL/GLES
    
    Configure with --with-opengl=es --enable-egl
    Fixes runtime link dependencies
---
 src/lib/evas/canvas/evas_gl.c                      |  8 ++++++
 .../evas/engines/gl_common/evas_gl_api_ext.c       |  8 +++---
 src/modules/evas/engines/gl_common/evas_gl_core.c  | 22 +++++++++++++++
 .../evas/engines/gl_common/evas_gl_core_private.h  |  1 +
 src/modules/evas/engines/gl_generic/evas_engine.c  |  6 ++--
 src/modules/evas/engines/gl_x11/evas_engine.c      | 17 ++++++++----
 src/modules/evas/engines/gl_x11/evas_x_main.c      | 32 ++++++++++++----------
 7 files changed, 68 insertions(+), 26 deletions(-)

diff --git a/src/lib/evas/canvas/evas_gl.c b/src/lib/evas/canvas/evas_gl.c
index 456d1be..2eefa1a 100644
--- a/src/lib/evas/canvas/evas_gl.c
+++ b/src/lib/evas/canvas/evas_gl.c
@@ -613,3 +613,11 @@ evas_gl_surface_query(Evas_GL *evas_gl, Evas_GL_Surface 
*surface, int attribute,
    return evas_gl->evas->engine.func->gl_surface_query
          (evas_gl->evas->engine.data.output, surface->data, attribute, value);
 }
+
+// Internal function - called from evas_gl_core.c
+EAPI void *
+_evas_gl_native_context_get(Evas_GL_Context *ctx)
+{
+   if (!ctx) return NULL;
+   return ctx->data;
+}
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 7a33f40..8b86b53 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
@@ -73,14 +73,14 @@ _evgl_egl_display_get(const char *function)
    if (!(rsc=_evgl_tls_resource_get()))
      {
         ERR("%s: Unable to execute GL command. Error retrieving tls", 
function);
-        _evgl_error_set(EVAS_GL_NOT_INITIALIZED);
+        evas_gl_common_error_set(NULL, EVAS_GL_NOT_INITIALIZED);
         return EGL_NO_DISPLAY;
      }
 
    if (!rsc->current_eng)
      {
         ERR("%s: Unable to retrive Current Engine", function);
-        _evgl_error_set(EVAS_GL_NOT_INITIALIZED);
+        evas_gl_common_error_set(NULL, EVAS_GL_NOT_INITIALIZED);
         return EGL_NO_DISPLAY;
      }
 
@@ -92,7 +92,7 @@ _evgl_egl_display_get(const char *function)
    else
      {
         ERR("%s: Invalid Engine... (Can't acccess EGL Display)\n", function);
-        _evgl_error_set(EVAS_GL_BAD_DISPLAY);
+        evas_gl_common_error_set(NULL, EVAS_GL_BAD_DISPLAY);
         return EGL_NO_DISPLAY;
      }
 }
@@ -155,7 +155,7 @@ evgl_evasglCreateImageForContext(Evas_GL *evasgl 
EINA_UNUSED, Evas_GL_Context *e
 
    if (!evasgl || !dpy) return NULL;
 
-   ctx = evgl_context_native_get(evasctx);
+   ctx = _evgl_native_context_get(evasctx);
    return _evgl_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
 }
 
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 1b18ae1..a9a3a11 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -14,6 +14,9 @@ EVGL_Engine *evgl_engine = NULL;
 int _evas_gl_log_dom   = -1;
 int _evas_gl_log_level = -1;
 
+typedef void           *(*glsym_func_void_ptr) ();
+glsym_func_void_ptr glsym_evas_gl_native_context_get = NULL;
+
 static void _surface_cap_print(int error);
 static void _surface_context_list_print();
 static void _internal_resources_destroy(void *eng_data, EVGL_Resource *rsc);
@@ -1305,6 +1308,22 @@ evas_gl_common_error_get(void *data EINA_UNUSED)
    return rsc->error_state;
 }
 
+EVGLNative_Context
+_evgl_native_context_get(Evas_GL_Context *ctx)
+{
+   EVGL_Context *evglctx;
+
+   if (!glsym_evas_gl_native_context_get)
+     {
+        ERR("Engine can't get a pointer to the native context");
+        return NULL;
+     }
+
+   evglctx = glsym_evas_gl_native_context_get(ctx);
+   if (!evglctx) return NULL;
+   return evglctx->context;
+}
+
 //---------------------------------------------------------------//
 // Exported functions for evas_engine to use
 
@@ -1367,6 +1386,9 @@ evgl_engine_init(void *eng_data, const EVGL_Interface 
*efunc)
      }
    DBG("TLS KEY created: %d", evgl_engine->resource_key);
 
+   // Link to evas_gl.c (this doesn't look great)
+   glsym_evas_gl_native_context_get = dlsym(RTLD_DEFAULT, 
"_evas_gl_native_context_get");
+
    // Initialize Extensions
    if (efunc->proc_address_get && efunc->ext_string_get)
       evgl_api_ext_init(efunc->proc_address_get, 
efunc->ext_string_get(eng_data));
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h 
b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index 7325bde..f6551dd 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -306,5 +306,6 @@ extern EVGL_Resource *_evgl_tls_resource_create(void *data);
 extern void           _evgl_tls_resource_destroy(void *data);
 extern int            _evgl_not_in_pixel_get(void);
 extern int            _evgl_direct_enabled(void);
+extern EVGLNative_Context _evgl_native_context_get(Evas_GL_Context *ctx);
 
 #endif //_EVAS_GL_CORE_PRIVATE_H
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c 
b/src/modules/evas/engines/gl_generic/evas_engine.c
index caba606..eb1a2a5 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1349,8 +1349,10 @@ eng_gl_surface_query(void *data, void *surface, int 
attr, void *value)
         // This is a real EGL surface, let's just call EGL directly
         int val;
         Eina_Bool ok;
+        void *disp;
 
-        ok = eglQuerySurface(re->win->egl_disp, sfc->pbuffer.native_surface, 
attr, &val);
+        disp = re->window_egl_display_get(re->software.ob);
+        ok = eglQuerySurface(disp, sfc->pbuffer.native_surface, attr, &val);
         if (!ok) return EINA_FALSE;
         switch (attr)
           {
@@ -1430,7 +1432,7 @@ eng_gl_surface_query(void *data, void *surface, int attr, 
void *value)
              */
            default: break;
           }
-        _evgl_error_set(EVAS_GL_BAD_ATTRIBUTE);
+        evas_gl_common_error_set(data, EVAS_GL_BAD_ATTRIBUTE);
         return EINA_FALSE;
      }
 #else
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c 
b/src/modules/evas/engines/gl_x11/evas_engine.c
index 2b0153a..0fe42b7 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -611,7 +611,7 @@ static void *
 evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface *sfc,
                                 const int *attrib_list)
 {
-   Render_Engine *re = (Render_Engine *)data;
+   Render_Engine_GL_Generic *re = data;
 
    // TODO: Add support for surfaceless pbuffers (EGL_NO_TEXTURE)
    // TODO: Add support for EGL_MIPMAP_TEXTURE??? (GLX doesn't support them)
@@ -622,10 +622,15 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface 
*sfc,
    EGLSurface egl_sfc;
    EGLConfig egl_cfg;
    int num_config, i = 0;
+   EGLDisplay disp;
+   EGLContext ctx;
 
    if (attrib_list)
      WRN("This PBuffer implementation does not support extra attributes yet");
 
+   disp = re->window_egl_display_get(re->software.ob);
+   ctx = re->window_gl_context_get(re->software.ob);
+
 #if 0
    // Choose framebuffer configuration
    // DISABLED FOR NOW
@@ -676,14 +681,14 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface 
*sfc,
    config_attrs[i++] = EGL_CONFIG_ID;
    config_attrs[i++] = 0;
    config_attrs[i++] = EGL_NONE;
-   eglQueryContext(re->win->egl_disp, re->win->egl_context[0], EGL_CONFIG_ID, 
&config_attrs[1]);
+   eglQueryContext(disp, ctx, EGL_CONFIG_ID, &config_attrs[1]);
 #endif
 
-   if (!eglChooseConfig(re->win->egl_disp, config_attrs, &egl_cfg, 1, 
&num_config)
+   if (!eglChooseConfig(disp, config_attrs, &egl_cfg, 1, &num_config)
        || (num_config < 1))
      {
         int err = eglGetError();
-        _evgl_error_set(err - EGL_SUCCESS);
+        glsym_evas_gl_common_error_set(data, err - EGL_SUCCESS);
         ERR("eglChooseConfig failed with error %x", err);
         return NULL;
      }
@@ -710,11 +715,11 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface 
*sfc,
 #endif
    surface_attrs[i++] = EGL_NONE;
 
-   egl_sfc = eglCreatePbufferSurface(re->win->egl_disp, egl_cfg, 
surface_attrs);
+   egl_sfc = eglCreatePbufferSurface(disp, egl_cfg, surface_attrs);
    if (!egl_sfc)
      {
         int err = eglGetError();
-        _evgl_error_set(err - EGL_SUCCESS);
+        glsym_evas_gl_common_error_set(data, err - EGL_SUCCESS);
         ERR("eglCreatePbufferSurface failed with error %x", err);
         return NULL;
      }
diff --git a/src/modules/evas/engines/gl_x11/evas_x_main.c 
b/src/modules/evas/engines/gl_x11/evas_x_main.c
index ebb5bcf..e06e21f 100644
--- a/src/modules/evas/engines/gl_x11/evas_x_main.c
+++ b/src/modules/evas/engines/gl_x11/evas_x_main.c
@@ -54,14 +54,14 @@ error:
 }
 
 static inline Outbuf *
-tls_outbuf_get(void)
+_tls_outbuf_get(void)
 {
    if (!initted) eng_init();
    return eina_tls_get(_outbuf_key);
 }
 
 static inline Eina_Bool
-_tls_Outbuf_set(Outbuf *xwin)
+_tls_outbuf_set(Outbuf *xwin)
 {
    if (!initted) eng_init();
    return eina_tls_set(_outbuf_key, xwin);
@@ -496,9 +496,9 @@ eng_window_free(Outbuf *gw)
    eng_window_use(gw);
 
    context = _tls_context_get();
-   xwin = tls_outbuf_get();
+   xwin = _tls_outbuf_get();
 
-   if (gw == xwin) _tls_Outbuf_set(NULL);
+   if (gw == xwin) _tls_outbuf_set(NULL);
    if (gw->gl_context)
      {
         ref = gw->gl_context->references - 1;
@@ -600,7 +600,7 @@ eng_window_use(Outbuf *gw)
    Eina_Bool force_use = EINA_FALSE;
    Outbuf *xwin;
 
-   xwin = tls_outbuf_get();
+   xwin = _tls_outbuf_get();
 
    glsym_evas_gl_preload_render_lock(eng_window_make_current, gw);
 #ifdef GL_GLES
@@ -609,11 +609,15 @@ eng_window_use(Outbuf *gw)
         if ((eglGetCurrentDisplay() !=
              xwin->egl_disp) ||
             (eglGetCurrentContext() !=
-             xwin->egl_context[0]) ||
-            (eglGetCurrentSurface(EGL_READ) !=
-             xwin->egl_surface[xwin->offscreen]) ||
-            (eglGetCurrentSurface(EGL_DRAW) !=
-             xwin->egl_surface[xwin->offscreen]))
+             xwin->egl_context[0])
+#if 0
+            // FIXME: Figure out what that offscreen thing was about...
+            || (eglGetCurrentSurface(EGL_READ) !=
+                xwin->egl_surface[xwin->offscreen])
+            || (eglGetCurrentSurface(EGL_DRAW) !=
+                xwin->egl_surface[xwin->offscreen])
+#endif
+            )
           force_use = EINA_TRUE;
      }
 #else
@@ -630,7 +634,7 @@ eng_window_use(Outbuf *gw)
              glsym_evas_gl_common_context_use(xwin->gl_context);
              glsym_evas_gl_common_context_flush(xwin->gl_context);
           }
-        _tls_Outbuf_set(gw);
+        _tls_outbuf_set(gw);
         if (gw)
           {
 // EGL / GLES
@@ -679,9 +683,9 @@ eng_window_unsurf(Outbuf *gw)
 #ifdef GL_GLES
    Outbuf *xwin;
 
-   xwin = _tls_Outbuf_get();
+   xwin = _tls_outbuf_get();
    if (xwin)
-      evas_gl_common_context_flush(xwin->gl_context);
+      glsym_evas_gl_common_context_flush(xwin->gl_context);
    if (xwin == gw)
      {
         eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, 
EGL_NO_CONTEXT);
@@ -691,7 +695,7 @@ eng_window_unsurf(Outbuf *gw)
         if (gw->egl_surface[1] != EGL_NO_SURFACE)
            eglDestroySurface(gw->egl_disp, gw->egl_surface[1]);
         gw->egl_surface[1] = EGL_NO_SURFACE;
-        _tls_Outbuf_set(NULL);
+        _tls_outbuf_set(NULL);
      }
 #else
    if (gw->glxwin)

-- 


Reply via email to