summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-11-16 19:43:16 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-11-16 19:44:20 +0900
commitcc4b54ec0a69c43f5163addbb6a4f4a6615cb8c0 (patch)
tree8466ce0bc642a2545f1d5e0a74059d3fa8cd8fec
parent69a8de59b05626591ddc0b960e2e4ccf45f26f2d (diff)
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.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c5
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_gles1.c2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c6
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c13
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 2c96a6c748..e469fb3d4e 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)
2467static void 2467static void
2468_normal_gles3_api_get(Evas_GL_API *funcs) 2468_normal_gles3_api_get(Evas_GL_API *funcs)
2469{ 2469{
2470 if (!funcs) return;
2471 funcs->version = EVAS_GL_API_VERSION;
2472
2470#define ORD(f) EVAS_API_OVERRIDE(f, funcs, evgl_) 2473#define ORD(f) EVAS_API_OVERRIDE(f, funcs, evgl_)
2471 // GLES 3.0 APIs that are same as GLES 2.0 2474 // GLES 3.0 APIs that are same as GLES 2.0
2472 ORD(glActiveTexture); 2475 ORD(glActiveTexture);
@@ -2727,6 +2730,8 @@ _normal_gles3_api_get(Evas_GL_API *funcs)
2727static void 2730static void
2728_debug_gles3_api_get(Evas_GL_API *funcs) 2731_debug_gles3_api_get(Evas_GL_API *funcs)
2729{ 2732{
2733 if (!funcs) return;
2734 funcs->version = EVAS_GL_API_VERSION;
2730 2735
2731#define ORD(f) EVAS_API_OVERRIDE(f, funcs, _evgld_) 2736#define ORD(f) EVAS_API_OVERRIDE(f, funcs, _evgld_)
2732 // GLES 3.0 APIs that are same as GLES 2.0 2737 // 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 4a2f7dd644..28d4784338 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
4018_debug_gles1_api_get(Evas_GL_API *funcs) 4018_debug_gles1_api_get(Evas_GL_API *funcs)
4019{ 4019{
4020 if (!funcs) return; 4020 if (!funcs) return;
4021 funcs->version = EVAS_GL_API_VERSION;
4021 4022
4022#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgld_gles1_) 4023#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgld_gles1_)
4023 /* Available only in Common profile */ 4024 /* Available only in Common profile */
@@ -4174,6 +4175,7 @@ static void
4174_normal_gles1_api_get(Evas_GL_API *funcs) 4175_normal_gles1_api_get(Evas_GL_API *funcs)
4175{ 4176{
4176 if (!funcs) return; 4177 if (!funcs) return;
4178 funcs->version = EVAS_GL_API_VERSION;
4177 4179
4178#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgl_gles1_) 4180#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgl_gles1_)
4179 /* Available only in Common profile */ 4181 /* 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 75b1b98000..bf179bcb1a 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)
1881 if (gles1_funcs) free(gles1_funcs); 1881 if (gles1_funcs) free(gles1_funcs);
1882 if (gles2_funcs) free(gles2_funcs); 1882 if (gles2_funcs) free(gles2_funcs);
1883 if (gles3_funcs) free(gles3_funcs); 1883 if (gles3_funcs) free(gles3_funcs);
1884 gles1_funcs = NULL;
1885 gles2_funcs = NULL;
1886 gles3_funcs = NULL;
1884 1887
1885 // Destroy internal resources 1888 // Destroy internal resources
1886 _evgl_tls_resource_destroy(eng_data); 1889 _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
3053 api = gles3_funcs; 3056 api = gles3_funcs;
3054 } 3057 }
3055 else return NULL; 3058 else return NULL;
3056 if (alloc_only) return api; 3059 if (alloc_only && (api->version == EVAS_GL_API_VERSION))
3060 return api;
3057 3061
3058#ifdef GL_GLES 3062#ifdef GL_GLES
3059 if (!evgl_api_egl_ext_init(evgl_engine->funcs->proc_address_get, evgl_engine->funcs->ext_string_get(eng_data))) 3063 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 ecd96f187c..3d26fc6a40 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
286/* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */ 286/* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
287/* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */ 287/* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */
288/* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */ 288/* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */
289
290static int gl_lib_init(void);
289#endif 291#endif
290 292
291// Threaded Render 293// Threaded Render
@@ -3055,6 +3057,12 @@ eng_gl_context_create(void *data EINA_UNUSED, void *share_context, int version,
3055 Render_Engine_GL_Context *ctx; 3057 Render_Engine_GL_Context *ctx;
3056 Render_Engine_GL_Context *share_ctx; 3058 Render_Engine_GL_Context *share_ctx;
3057 3059
3060 if (!_tls_check() && !gl_lib_init())
3061 {
3062 WRN("Failed to initialize Evas GL (with OSMesa)");
3063 return NULL;
3064 }
3065
3058 if (version != EVAS_GL_GLES_2_X) 3066 if (version != EVAS_GL_GLES_2_X)
3059 { 3067 {
3060 ERR("This engine only supports OpenGL-ES 2.0 contexts for now!"); 3068 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)
3251 return NULL; 3259 return NULL;
3252 3260
3253#ifdef EVAS_GL 3261#ifdef EVAS_GL
3262 if (!_tls_init)
3263 gl_lib_init();
3264
3254 return &gl_funcs; 3265 return &gl_funcs;
3255#else 3266#else
3256 return NULL; 3267 return NULL;
@@ -4990,7 +5001,7 @@ evgl_glGetString(GLenum name)
4990static void 5001static void
4991override_gl_apis(Evas_GL_API *api) 5002override_gl_apis(Evas_GL_API *api)
4992{ 5003{
4993 memset(&gl_funcs, 0, sizeof(gl_funcs)); 5004 memset(api, 0, sizeof(*api));
4994 api->version = EVAS_GL_API_VERSION; 5005 api->version = EVAS_GL_API_VERSION;
4995 5006
4996#define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_) 5007#define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)