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.
This commit is contained in:
Jean-Philippe Andre 2015-11-16 19:43:16 +09:00
parent 69a8de59b0
commit cc4b54ec0a
4 changed files with 24 additions and 2 deletions

View File

@ -2467,6 +2467,9 @@ _evgl_api_gles2_get(Evas_GL_API *funcs, Eina_Bool debug)
static void
_normal_gles3_api_get(Evas_GL_API *funcs)
{
if (!funcs) return;
funcs->version = EVAS_GL_API_VERSION;
#define ORD(f) EVAS_API_OVERRIDE(f, funcs, evgl_)
// GLES 3.0 APIs that are same as GLES 2.0
ORD(glActiveTexture);
@ -2727,6 +2730,8 @@ _normal_gles3_api_get(Evas_GL_API *funcs)
static void
_debug_gles3_api_get(Evas_GL_API *funcs)
{
if (!funcs) return;
funcs->version = EVAS_GL_API_VERSION;
#define ORD(f) EVAS_API_OVERRIDE(f, funcs, _evgld_)
// GLES 3.0 APIs that are same as GLES 2.0

View File

@ -4018,6 +4018,7 @@ static void
_debug_gles1_api_get(Evas_GL_API *funcs)
{
if (!funcs) return;
funcs->version = EVAS_GL_API_VERSION;
#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgld_gles1_)
/* Available only in Common profile */
@ -4174,6 +4175,7 @@ static void
_normal_gles1_api_get(Evas_GL_API *funcs)
{
if (!funcs) return;
funcs->version = EVAS_GL_API_VERSION;
#define ORD(name) EVAS_API_OVERRIDE(name, funcs, _evgl_gles1_)
/* Available only in Common profile */

View File

@ -1881,6 +1881,9 @@ evgl_engine_shutdown(void *eng_data)
if (gles1_funcs) free(gles1_funcs);
if (gles2_funcs) free(gles2_funcs);
if (gles3_funcs) free(gles3_funcs);
gles1_funcs = NULL;
gles2_funcs = NULL;
gles3_funcs = NULL;
// Destroy internal resources
_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
api = gles3_funcs;
}
else return NULL;
if (alloc_only) return api;
if (alloc_only && (api->version == EVAS_GL_API_VERSION))
return api;
#ifdef GL_GLES
if (!evgl_api_egl_ext_init(evgl_engine->funcs->proc_address_get, evgl_engine->funcs->ext_string_get(eng_data)))

View File

@ -286,6 +286,8 @@ static void (*_sym_glViewport) (GLint x, GLint
/* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
/* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */
/* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */
static int gl_lib_init(void);
#endif
// Threaded Render
@ -3055,6 +3057,12 @@ eng_gl_context_create(void *data EINA_UNUSED, void *share_context, int version,
Render_Engine_GL_Context *ctx;
Render_Engine_GL_Context *share_ctx;
if (!_tls_check() && !gl_lib_init())
{
WRN("Failed to initialize Evas GL (with OSMesa)");
return NULL;
}
if (version != EVAS_GL_GLES_2_X)
{
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)
return NULL;
#ifdef EVAS_GL
if (!_tls_init)
gl_lib_init();
return &gl_funcs;
#else
return NULL;
@ -4990,7 +5001,7 @@ evgl_glGetString(GLenum name)
static void
override_gl_apis(Evas_GL_API *api)
{
memset(&gl_funcs, 0, sizeof(gl_funcs));
memset(api, 0, sizeof(*api));
api->version = EVAS_GL_API_VERSION;
#define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)