summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-12-03 11:44:09 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-12-09 11:33:09 +0900
commit4a5f8d6ac9746ef0c237242619e95aa233af2373 (patch)
tree44205562186f802e905f2229b95a81b89de17d9b
parentebddf088ec3c19a742e0001a8a30f7e1bf2ceff1 (diff)
Evas GL: Add preventive padding after Evas_GL_API
Since this struct is likely to grow in size over time, client apps built against future versions of EFL might start indexing fields that are not present in the current form. Also, don't reset the struct memory as this would break multithreaded GL applications. While this is not exactly a fix, I'll backport this. @fix
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c2
-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.c19
3 files changed, 11 insertions, 12 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 477e8315d0..2bf6485af6 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -2767,8 +2767,6 @@ _debug_gl_api_get(Evas_GL_API *funcs)
2767void 2767void
2768_evgl_api_get(Evas_GL_API *funcs, int debug) 2768_evgl_api_get(Evas_GL_API *funcs, int debug)
2769{ 2769{
2770 memset(funcs, 0, sizeof(Evas_GL_API));
2771
2772 if (debug) 2770 if (debug)
2773 _debug_gl_api_get(funcs); 2771 _debug_gl_api_get(funcs);
2774 else 2772 else
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 f03d731b27..0363bec4ac 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
@@ -4263,8 +4263,6 @@ _normal_gles1_api_get(Evas_GL_API *funcs)
4263void 4263void
4264_evgl_api_gles1_get(Evas_GL_API *funcs, Eina_Bool debug) 4264_evgl_api_gles1_get(Evas_GL_API *funcs, Eina_Bool debug)
4265{ 4265{
4266 memset(funcs, 0, sizeof(Evas_GL_API));
4267
4268 if (!_evgl_gles1_api_init()) 4266 if (!_evgl_gles1_api_init())
4269 return; 4267 return;
4270 4268
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 fb56d00062..7956a1e9dd 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -8,9 +8,11 @@ typedef struct _GL_Format
8 GLenum fmt; 8 GLenum fmt;
9} GL_Format; 9} GL_Format;
10 10
11// Globals 11// Extended struct size based on the 314 functions found in gl31.h
12static Evas_GL_API gl_funcs; 12#define EVAS_GL_API_STRUCT_SIZE (sizeof(Evas_GL_API) + 300 * sizeof(void*))
13static Evas_GL_API gles1_funcs; 13static Evas_GL_API *gl_funcs = NULL;
14static Evas_GL_API *gles1_funcs = NULL;
15
14EVGL_Engine *evgl_engine = NULL; 16EVGL_Engine *evgl_engine = NULL;
15int _evas_gl_log_dom = -1; 17int _evas_gl_log_dom = -1;
16int _evas_gl_log_level = -1; 18int _evas_gl_log_level = -1;
@@ -1450,7 +1452,8 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
1450 evgl_engine->main_tid = 0; 1452 evgl_engine->main_tid = 0;
1451 1453
1452 // Clear Function Pointers 1454 // Clear Function Pointers
1453 memset(&gl_funcs, 0, sizeof(Evas_GL_API)); 1455 if (!gl_funcs) gl_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
1456 if (!gles1_funcs) gles1_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
1454 1457
1455 return evgl_engine; 1458 return evgl_engine;
1456 1459
@@ -2309,13 +2312,13 @@ evgl_api_get(Evas_GL_Context_Version version)
2309{ 2312{
2310 if (version == EVAS_GL_GLES_2_X) 2313 if (version == EVAS_GL_GLES_2_X)
2311 { 2314 {
2312 _evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode); 2315 _evgl_api_get(gl_funcs, evgl_engine->api_debug_mode);
2313 return &gl_funcs; 2316 return gl_funcs;
2314 } 2317 }
2315 else if (version == EVAS_GL_GLES_1_X) 2318 else if (version == EVAS_GL_GLES_1_X)
2316 { 2319 {
2317 _evgl_api_gles1_get(&gles1_funcs, evgl_engine->api_debug_mode); 2320 _evgl_api_gles1_get(gles1_funcs, evgl_engine->api_debug_mode);
2318 return &gles1_funcs; 2321 return gles1_funcs;
2319 } 2322 }
2320 else return NULL; 2323 else return NULL;
2321} 2324}