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
_evgl_api_get(Evas_GL_API *funcs, int debug)
{
memset(funcs, 0, sizeof(Evas_GL_API));
if (debug)
_debug_gl_api_get(funcs);
else

View File

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

View File

@ -8,9 +8,11 @@ typedef struct _GL_Format
GLenum fmt;
} GL_Format;
// Globals
static Evas_GL_API gl_funcs;
static Evas_GL_API gles1_funcs;
// Extended struct size based on the 314 functions found in gl31.h
#define EVAS_GL_API_STRUCT_SIZE (sizeof(Evas_GL_API) + 300 * sizeof(void*))
static Evas_GL_API *gl_funcs = NULL;
static Evas_GL_API *gles1_funcs = NULL;
EVGL_Engine *evgl_engine = NULL;
int _evas_gl_log_dom = -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;
// 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;
@ -2414,13 +2417,13 @@ evgl_api_get(Evas_GL_Context_Version version)
{
if (version == EVAS_GL_GLES_2_X)
{
_evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode);
return &gl_funcs;
_evgl_api_get(gl_funcs, evgl_engine->api_debug_mode);
return gl_funcs;
}
else if (version == EVAS_GL_GLES_1_X)
{
_evgl_api_gles1_get(&gles1_funcs, evgl_engine->api_debug_mode);
return &gles1_funcs;
_evgl_api_gles1_get(gles1_funcs, evgl_engine->api_debug_mode);
return gles1_funcs;
}
else return NULL;
}