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-03 16:57:49 +0900
commit0514cbc1a3c86a86c2abcf39958f562e5bc2e31b (patch)
tree4fe5177158b5fca938da2f26d0ce899f19bff9f0
parentad0f10950c62934cef70d157edc624f60fc4a3d0 (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 6a5ea56..ed8f501 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -2868,8 +2868,6 @@ _debug_gl_api_get(Evas_GL_API *funcs)
2868void 2868void
2869_evgl_api_get(Evas_GL_API *funcs, int debug) 2869_evgl_api_get(Evas_GL_API *funcs, int debug)
2870{ 2870{
2871 memset(funcs, 0, sizeof(Evas_GL_API));
2872
2873 if (debug) 2871 if (debug)
2874 _debug_gl_api_get(funcs); 2872 _debug_gl_api_get(funcs);
2875 else 2873 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 c018f7e..d3eee22 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 1878f5f..9ec771a 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;
@@ -1456,7 +1458,8 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
1456 evgl_engine->main_tid = 0; 1458 evgl_engine->main_tid = 0;
1457 1459
1458 // Clear Function Pointers 1460 // Clear Function Pointers
1459 memset(&gl_funcs, 0, sizeof(Evas_GL_API)); 1461 if (!gl_funcs) gl_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
1462 if (!gles1_funcs) gles1_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
1460 1463
1461 return evgl_engine; 1464 return evgl_engine;
1462 1465
@@ -2414,13 +2417,13 @@ evgl_api_get(Evas_GL_Context_Version version)
2414{ 2417{
2415 if (version == EVAS_GL_GLES_2_X) 2418 if (version == EVAS_GL_GLES_2_X)
2416 { 2419 {
2417 _evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode); 2420 _evgl_api_get(gl_funcs, evgl_engine->api_debug_mode);
2418 return &gl_funcs; 2421 return gl_funcs;
2419 } 2422 }
2420 else if (version == EVAS_GL_GLES_1_X) 2423 else if (version == EVAS_GL_GLES_1_X)
2421 { 2424 {
2422 _evgl_api_gles1_get(&gles1_funcs, evgl_engine->api_debug_mode); 2425 _evgl_api_gles1_get(gles1_funcs, evgl_engine->api_debug_mode);
2423 return &gles1_funcs; 2426 return gles1_funcs;
2424 } 2427 }
2425 else return NULL; 2428 else return NULL;
2426} 2429}