From: Joogab Yun Date: Fri, 20 Nov 2015 05:59:11 +0000 (+0900) Subject: Evas GL: Fix failing make check test case X-Git-Tag: submit/tizen/20151125.071930~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f6d94512c67761358a4651de56f59b50ad6a875e;p=platform%2Fupstream%2Fefl.git 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. From cc4b54ec0a69c43f5163addbb6a4f4a6615cb8c0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Change-Id: Ic4944f5b87743fd0e4f2a8a37a87a4e3df69dd5e --- 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 a3d8088..2186a65 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 f01b753..087bb02 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 @@ -3020,6 +3022,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!"); @@ -3216,6 +3224,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; @@ -4962,7 +4973,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_)