jpeg pushed a commit to branch master.

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

commit cc4b54ec0a69c43f5163addbb6a4f4a6615cb8c0
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Mon Nov 16 19:43:16 2015 +0900

    Evas GL: Fix failing make check test case
    
    The version field was not properly set for GLES 1 and 3 (but not tested),
    double free() could happen on the API structs, and empty API structs
    could be returned.
---
 src/modules/evas/engines/gl_common/evas_gl_api.c        |  5 +++++
 src/modules/evas/engines/gl_common/evas_gl_api_gles1.c  |  2 ++
 src/modules/evas/engines/gl_common/evas_gl_core.c       |  6 +++++-
 src/modules/evas/engines/software_generic/evas_engine.c | 13 ++++++++++++-
 4 files changed, 24 insertions(+), 2 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 2c96a6c..e469fb3 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -2467,6 +2467,9 @@ _evgl_api_gles2_get(Evas_GL_API *funcs, Eina_Bool debug)
 static void
 _normal_gles3_api_get(Evas_GL_API *funcs)
 {
+   if (!funcs) return;
+   funcs->version = EVAS_GL_API_VERSION;
+
 #define ORD(f) EVAS_API_OVERRIDE(f, funcs, evgl_)
    // GLES 3.0 APIs that are same as GLES 2.0
    ORD(glActiveTexture);
@@ -2727,6 +2730,8 @@ _normal_gles3_api_get(Evas_GL_API *funcs)
 static void
 _debug_gles3_api_get(Evas_GL_API *funcs)
 {
+   if (!funcs) return;
+   funcs->version = EVAS_GL_API_VERSION;
 
 #define ORD(f) EVAS_API_OVERRIDE(f, funcs, _evgld_)
    // GLES 3.0 APIs that are same as GLES 2.0
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_gles1.c 
b/src/modules/evas/engines/gl_common/evas_gl_api_gles1.c
index 4a2f7dd..28d4784 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_gles1.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_gles1.c
@@ -4018,6 +4018,7 @@ static void
 _debug_gles1_api_get(Evas_GL_API *funcs)
 {
    if (!funcs) return;
+   funcs->version = EVAS_GL_API_VERSION;
 
 #define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgld_gles1_)
    /* Available only in Common profile */
@@ -4174,6 +4175,7 @@ static void
 _normal_gles1_api_get(Evas_GL_API *funcs)
 {
    if (!funcs) return;
+   funcs->version = EVAS_GL_API_VERSION;
 
 #define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgl_gles1_)
    /* Available only in Common profile */
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 75b1b98..bf179bc 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -1881,6 +1881,9 @@ evgl_engine_shutdown(void *eng_data)
    if (gles1_funcs) free(gles1_funcs);
    if (gles2_funcs) free(gles2_funcs);
    if (gles3_funcs) free(gles3_funcs);
+   gles1_funcs = NULL;
+   gles2_funcs = NULL;
+   gles3_funcs = NULL;
 
    // Destroy internal resources
    _evgl_tls_resource_destroy(eng_data);
@@ -3053,7 +3056,8 @@ evgl_api_get(void *eng_data, Evas_GL_Context_Version 
version, Eina_Bool alloc_on
         api = gles3_funcs;
      }
    else return NULL;
-   if (alloc_only) return api;
+   if (alloc_only && (api->version == EVAS_GL_API_VERSION))
+     return api;
 
 #ifdef GL_GLES
     if (!evgl_api_egl_ext_init(evgl_engine->funcs->proc_address_get, 
evgl_engine->funcs->ext_string_get(eng_data)))
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index ecd96f18..3d26fc6 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -286,6 +286,8 @@ static void       (*_sym_glViewport)                        
    (GLint x, GLint
 /* static void       (*_sym_glGetProgramBinary)                    (GLuint a, 
GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
 /* static void       (*_sym_glProgramBinary)                       (GLuint a, 
GLenum b, const void* c, GLint d) = NULL; */
 /* static void       (*_sym_glProgramParameteri)                   (GLuint a, 
GLuint b, GLint d) = NULL; */
+
+static int gl_lib_init(void);
 #endif
 
 // Threaded Render
@@ -3055,6 +3057,12 @@ eng_gl_context_create(void *data EINA_UNUSED, void 
*share_context, int version,
    Render_Engine_GL_Context *ctx;
    Render_Engine_GL_Context *share_ctx;
 
+   if (!_tls_check() && !gl_lib_init())
+     {
+        WRN("Failed to initialize Evas GL (with OSMesa)");
+        return NULL;
+     }
+
    if (version != EVAS_GL_GLES_2_X)
      {
         ERR("This engine only supports OpenGL-ES 2.0 contexts for now!");
@@ -3251,6 +3259,9 @@ eng_gl_api_get(void *data EINA_UNUSED, int version)
      return NULL;
 
 #ifdef EVAS_GL
+   if (!_tls_init)
+     gl_lib_init();
+
    return &gl_funcs;
 #else
    return NULL;
@@ -4990,7 +5001,7 @@ evgl_glGetString(GLenum name)
 static void
 override_gl_apis(Evas_GL_API *api)
 {
-   memset(&gl_funcs, 0, sizeof(gl_funcs));
+   memset(api, 0, sizeof(*api));
    api->version = EVAS_GL_API_VERSION;
 
 #define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)

-- 


Reply via email to