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
This commit is contained in:
Jean-Philippe Andre 2014-12-03 11:44:09 +09:00
parent ad0f10950c
commit 0514cbc1a3
3 changed files with 11 additions and 12 deletions

View File

@ -2868,8 +2868,6 @@ _debug_gl_api_get(Evas_GL_API *funcs)
void void
_evgl_api_get(Evas_GL_API *funcs, int debug) _evgl_api_get(Evas_GL_API *funcs, int debug)
{ {
memset(funcs, 0, sizeof(Evas_GL_API));
if (debug) if (debug)
_debug_gl_api_get(funcs); _debug_gl_api_get(funcs);
else else

View File

@ -4263,8 +4263,6 @@ _normal_gles1_api_get(Evas_GL_API *funcs)
void void
_evgl_api_gles1_get(Evas_GL_API *funcs, Eina_Bool debug) _evgl_api_gles1_get(Evas_GL_API *funcs, Eina_Bool debug)
{ {
memset(funcs, 0, sizeof(Evas_GL_API));
if (!_evgl_gles1_api_init()) if (!_evgl_gles1_api_init())
return; return;

View File

@ -8,9 +8,11 @@ typedef struct _GL_Format
GLenum fmt; GLenum fmt;
} GL_Format; } GL_Format;
// Globals // Extended struct size based on the 314 functions found in gl31.h
static Evas_GL_API gl_funcs; #define EVAS_GL_API_STRUCT_SIZE (sizeof(Evas_GL_API) + 300 * sizeof(void*))
static Evas_GL_API gles1_funcs; static Evas_GL_API *gl_funcs = NULL;
static Evas_GL_API *gles1_funcs = NULL;
EVGL_Engine *evgl_engine = NULL; EVGL_Engine *evgl_engine = NULL;
int _evas_gl_log_dom = -1; int _evas_gl_log_dom = -1;
int _evas_gl_log_level = -1; int _evas_gl_log_level = -1;
@ -1456,7 +1458,8 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
evgl_engine->main_tid = 0; evgl_engine->main_tid = 0;
// Clear Function Pointers // Clear Function Pointers
memset(&gl_funcs, 0, sizeof(Evas_GL_API)); if (!gl_funcs) gl_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
if (!gles1_funcs) gles1_funcs = calloc(1, EVAS_GL_API_STRUCT_SIZE);
return evgl_engine; return evgl_engine;
@ -2414,13 +2417,13 @@ evgl_api_get(Evas_GL_Context_Version version)
{ {
if (version == EVAS_GL_GLES_2_X) if (version == EVAS_GL_GLES_2_X)
{ {
_evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode); _evgl_api_get(gl_funcs, evgl_engine->api_debug_mode);
return &gl_funcs; return gl_funcs;
} }
else if (version == EVAS_GL_GLES_1_X) else if (version == EVAS_GL_GLES_1_X)
{ {
_evgl_api_gles1_get(&gles1_funcs, evgl_engine->api_debug_mode); _evgl_api_gles1_get(gles1_funcs, evgl_engine->api_debug_mode);
return &gles1_funcs; return gles1_funcs;
} }
else return NULL; else return NULL;
} }