Evas GL: Fix runtime linking issues

There is some mess with gl common functions that need to be
called from the engine itself, eg. error set/get.
This commit is contained in:
Jean-Philippe Andre 2014-09-02 12:52:52 +09:00
parent 0ee951fc21
commit 28a76266c6
8 changed files with 75 additions and 62 deletions

View File

@ -505,7 +505,8 @@ evas_gl_error_get(Evas_GL *evas_gl)
return EVAS_GL_NOT_INITIALIZED;
MAGIC_CHECK_END();
if ((err = _evas_gl_internal_error_get(evas_gl)) != EVAS_GL_SUCCESS) goto end;
if ((err = _evas_gl_internal_error_get(evas_gl)) != EVAS_GL_SUCCESS)
goto end;
if (!evas_gl->evas->engine.func->gl_error_get)
err = EVAS_GL_NOT_INITIALIZED;

View File

@ -16,7 +16,7 @@ void _make_current_check(const char* api)
{
EVGL_Context *ctx = NULL;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (!ctx)
{
@ -29,7 +29,7 @@ void _direct_rendering_check(const char *api)
{
EVGL_Context *ctx = NULL;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (!ctx)
{
ERR("Current Context Not Set");
@ -59,7 +59,7 @@ _evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
EVGL_Resource *rsc;
rsc = _evgl_tls_resource_get();
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (!ctx)
{
@ -449,7 +449,7 @@ _evgl_glEnable(GLenum cap)
{
EVGL_Context *ctx;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (cap == GL_SCISSOR_TEST)
if (ctx) ctx->scissor_enabled = 1;
@ -461,7 +461,7 @@ _evgl_glDisable(GLenum cap)
{
EVGL_Context *ctx;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (cap == GL_SCISSOR_TEST)
if (ctx) ctx->scissor_enabled = 0;

View File

@ -754,6 +754,10 @@ EAPI void evas_gl_preload_render_unlock(evas_gl_make_current_cb make_cur
EAPI void evas_gl_preload_render_relax(evas_gl_make_current_cb make_current, void *engine_data);
EAPI void evas_gl_symbols(void *(*GetProcAddress)(const char *name));
EAPI void evas_gl_common_error_set(void *data, int error_enum);
EAPI int evas_gl_common_error_get(void *data);
EAPI void *evas_gl_common_current_context_get(void);
typedef int (*Evas_GL_Preload)(void);
typedef void (*Evas_GL_Common_Image_Call)(Evas_GL_Image *im);
typedef void (*Evas_GL_Common_Context_Call)(Evas_Engine_GL_Context *gc);

View File

@ -1230,8 +1230,8 @@ _evgl_tls_resource_destroy(void *eng_data)
evgl_engine->resource_key = 0;
}
EVGL_Context *
_evgl_current_context_get()
EAPI void * /* EVGL_Context */
evas_gl_common_current_context_get(void)
{
EVGL_Resource *rsc;
@ -1241,7 +1241,7 @@ _evgl_current_context_get()
return NULL;
}
else
return rsc->current_ctx;
return rsc->current_ctx;
}
int
@ -1277,8 +1277,8 @@ _evgl_direct_enabled()
return _evgl_direct_renderable(rsc, sfc);
}
void
_evgl_error_set(int error_enum)
EAPI void
evas_gl_common_error_set(void *data EINA_UNUSED, int error_enum)
{
EVGL_Resource *rsc;
@ -1291,8 +1291,8 @@ _evgl_error_set(int error_enum)
rsc->error_state = error_enum;
}
int
_evgl_error_get()
EAPI int
evas_gl_common_error_get(void *data EINA_UNUSED)
{
EVGL_Resource *rsc;
@ -1463,14 +1463,14 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!evgl_engine)
{
ERR("Invalid EVGL Engine!");
_evgl_error_set(EVAS_GL_BAD_ACCESS);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ACCESS);
return NULL;
}
if (!cfg)
{
ERR("Invalid Config!");
_evgl_error_set(EVAS_GL_BAD_CONFIG);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG);
return NULL;
}
@ -1479,7 +1479,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
{
ERR("Requested surface size [%d, %d] is greater than max supported size [%d, %d]",
w, h, evgl_engine->caps.max_w, evgl_engine->caps.max_h);
_evgl_error_set(EVAS_GL_BAD_PARAMETER);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_PARAMETER);
return NULL;
}
@ -1507,7 +1507,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!sfc)
{
ERR("Surface allocation failed.");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
goto error;
}
@ -1519,7 +1519,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!_internal_config_set(sfc, cfg))
{
ERR("Unsupported Format!");
_evgl_error_set(EVAS_GL_BAD_CONFIG);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG);
goto error;
}
@ -1527,7 +1527,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!_internal_resource_make_current(eng_data, NULL))
{
ERR("Error doing an internal resource make current");
_evgl_error_set(EVAS_GL_BAD_CONTEXT);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
goto error;
}
@ -1535,7 +1535,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!_surface_buffers_create(sfc))
{
ERR("Unable Create Specificed Surfaces.");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
goto error;
};
@ -1545,7 +1545,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0))
{
ERR("Unable Create Allocate Memory for Surface.");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
goto error;
}
}
@ -1553,7 +1553,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
{
ERR("Error doing make_current(NULL, NULL).");
_evgl_error_set(EVAS_GL_BAD_CONTEXT);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
goto error;
}
@ -1645,7 +1645,7 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx)
if (!evgl_engine)
{
ERR("Invalid EVGL Engine!");
_evgl_error_set(EVAS_GL_BAD_ACCESS);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ACCESS);
return NULL;
}
@ -1654,7 +1654,7 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx)
if (!ctx)
{
ERR("Error allocating context object.");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
return NULL;
}
@ -1740,8 +1740,8 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
(sfc && (!ctx)) )
{
ERR("Invalid Inputs. Engine: %p Surface: %p Context: %p!", evgl_engine, sfc, ctx);
if(!sfc) _evgl_error_set(EVAS_GL_BAD_SURFACE);
if(!ctx) _evgl_error_set(EVAS_GL_BAD_CONTEXT);
if(!sfc) evas_gl_common_error_set(eng_data, EVAS_GL_BAD_SURFACE);
if(!ctx) evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
return 0;
}
@ -1791,7 +1791,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
if (!_surface_buffers_allocate(eng_data, sfc, 0, 0, 1))
{
ERR("Unable to destroy surface buffers!");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
return 0;
}
sfc->buffers_allocated = 0;
@ -1811,7 +1811,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 1))
{
ERR("Unable Create Specificed Surfaces. Unsupported format!");
_evgl_error_set(EVAS_GL_BAD_ALLOC);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
return 0;
};
sfc->buffers_allocated = 1;
@ -1824,7 +1824,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
if (!_internal_resource_make_current(eng_data, ctx))
{
ERR("Error doing a make current with internal surface. Context: %p", ctx);
_evgl_error_set(EVAS_GL_BAD_CONTEXT);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
return 0;
}
@ -1879,7 +1879,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo))
{
ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo);
_evgl_error_set(EVAS_GL_BAD_CONTEXT);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
return 0;
}
}
@ -2062,7 +2062,7 @@ void
evgl_direct_partial_render_end()
{
EVGL_Context *ctx;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (!ctx) return;

View File

@ -289,10 +289,7 @@ extern void _evgl_api_get(Evas_GL_API *api, int debug);
extern EVGL_Resource *_evgl_tls_resource_get();
extern EVGL_Resource *_evgl_tls_resource_create(void *data);
extern void _evgl_tls_resource_destroy(void *data);
extern EVGL_Context *_evgl_current_context_get();
extern int _evgl_not_in_pixel_get();
extern int _evgl_direct_enabled();
extern void _evgl_error_set(int error_enum);
extern int _evgl_error_get();
#endif //_EVAS_GL_CORE_PRIVATE_H

View File

@ -1173,7 +1173,7 @@ eng_gl_current_surface_get(void *data EINA_UNUSED)
{
EVGL_Context *ctx;
ctx = _evgl_current_context_get();
ctx = evas_gl_common_current_context_get();
if (!ctx)
return NULL;

View File

@ -75,6 +75,10 @@ Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_lock = NULL;
Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock = NULL;
Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_relax = NULL;
glsym_func_void glsym_evas_gl_common_error_set = NULL;
glsym_func_int glsym_evas_gl_common_error_get = NULL;
glsym_func_void_ptr glsym_evas_gl_common_current_context_get = NULL;
#ifdef GL_GLES
#ifndef EGL_NATIVE_PIXMAP_KHR
@ -217,7 +221,7 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return 0;
}
@ -233,13 +237,14 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush)
if (!ret)
{
int err = eglGetError();
_evgl_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
ERR("eglMakeCurrent() failed! Error Code=%#x", err);
return 0;
}
return 1;
}
// FIXME: Check (eglGetCurrentDisplay() != dpy) ?
if ((eglGetCurrentContext() != ctx) ||
(eglGetCurrentSurface(EGL_READ) != sfc) ||
(eglGetCurrentSurface(EGL_DRAW) != sfc) )
@ -255,7 +260,7 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush)
if (!ret)
{
int err = eglGetError();
_evgl_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
ERR("eglMakeCurrent() failed! Error Code=%#x", err);
return 0;
}
@ -272,7 +277,7 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush)
if (!ret)
{
ERR("glXMakeCurrent() failed!");
_evgl_error_set(EVAS_GL_BAD_DISPLAY);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_DISPLAY);
return 0;
}
return 1;
@ -291,7 +296,7 @@ evgl_eng_make_current(void *data, void *surface, void *context, int flush)
if (!ret)
{
ERR("glXMakeCurrent() failed. Ret: %d! Context: %p Surface: %p", ret, (void*)ctx, (void*)sfc);
_evgl_error_set(EVAS_GL_BAD_DISPLAY);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_DISPLAY);
return 0;
}
}
@ -310,7 +315,7 @@ evgl_eng_native_window_create(void *data)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return NULL;
}
@ -339,7 +344,7 @@ evgl_eng_native_window_create(void *data)
if (!win)
{
ERR("Creating native X window failed.");
_evgl_error_set(EVAS_GL_BAD_DISPLAY);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_DISPLAY);
return NULL;
}
@ -355,14 +360,14 @@ evgl_eng_native_window_destroy(void *data, void *native_window)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return 0;
}
if (!native_window)
{
ERR("Inavlid native surface.");
_evgl_error_set(EVAS_GL_BAD_NATIVE_WINDOW);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_NATIVE_WINDOW);
return 0;
}
@ -385,7 +390,7 @@ evgl_eng_window_surface_create(void *data, void *native_window EINA_UNUSED)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return NULL;
}
@ -426,7 +431,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return 0;
}
@ -434,7 +439,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
if (!surface)
{
ERR("Invalid surface.");
_evgl_error_set(EVAS_GL_BAD_SURFACE);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_SURFACE);
return 0;
}
@ -454,7 +459,7 @@ evgl_eng_context_create(void *data, void *share_ctx)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return NULL;
}
@ -486,7 +491,7 @@ evgl_eng_context_create(void *data, void *share_ctx)
{
int err = eglGetError();
ERR("Engine Context Creations Failed. Error: %#x.", err);
_evgl_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
return NULL;
}
@ -513,8 +518,8 @@ evgl_eng_context_create(void *data, void *share_ctx)
if (!context)
{
ERR("Internal Resource Context Creations Failed.");
if(!(eng_get_ob(re)->info->info.display)) _evgl_error_set(EVAS_GL_BAD_DISPLAY);
if(!(eng_get_ob(re)->win)) _evgl_error_set(EVAS_GL_BAD_NATIVE_WINDOW);
if(!(eng_get_ob(re)->info->info.display)) glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_DISPLAY);
if(!(eng_get_ob(re)->win)) glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_NATIVE_WINDOW);
return NULL;
}
@ -532,8 +537,8 @@ evgl_eng_context_destroy(void *data, void *context)
if ((!re) || (!context))
{
ERR("Invalid Render Input Data. Engine: %p, Context: %p", data, context);
if (!re) _evgl_error_set(EVAS_GL_NOT_INITIALIZED);
if (!context) _evgl_error_set(EVAS_GL_BAD_CONTEXT);
if (!re) glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
if (!context) glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_CONTEXT);
return 0;
}
@ -555,7 +560,7 @@ evgl_eng_string_get(void *data)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return NULL;
}
@ -588,7 +593,7 @@ evgl_eng_rotation_angle_get(void *data)
if (!re)
{
ERR("Invalid Render Engine Data!");
_evgl_error_set(EVAS_GL_NOT_INITIALIZED);
glsym_evas_gl_common_error_set(data, EVAS_GL_NOT_INITIALIZED);
return 0;
}
@ -597,7 +602,7 @@ evgl_eng_rotation_angle_get(void *data)
else
{
ERR("Unable to retrieve rotation angle.");
_evgl_error_set(EVAS_GL_BAD_CONTEXT);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_CONTEXT);
return 0;
}
}
@ -654,6 +659,9 @@ gl_symbols(void)
LINK2GENERIC(evas_gl_preload_shutdown);
LINK2GENERIC(evgl_engine_shutdown);
LINK2GENERIC(evas_gl_symbols);
LINK2GENERIC(evas_gl_common_error_get);
LINK2GENERIC(evas_gl_common_error_set);
LINK2GENERIC(evas_gl_common_current_context_get);
#ifdef GL_GLES
#define FINDSYM(dst, sym, typ) \
@ -1269,7 +1277,7 @@ eng_gl_current_context_get(void *data EINA_UNUSED)
{
EVGL_Context *ctx;
ctx = _evgl_current_context_get();
ctx = glsym_evas_gl_common_current_context_get();
if (!ctx)
return NULL;
@ -1287,11 +1295,11 @@ eng_gl_current_context_get(void *data EINA_UNUSED)
}
static int
eng_gl_error_get(void *data EINA_UNUSED)
eng_gl_error_get(void *data)
{
int err;
if ((err = _evgl_error_get()) != EVAS_GL_SUCCESS)
if ((err = glsym_evas_gl_common_error_get(data)) != EVAS_GL_SUCCESS)
goto end;
#ifdef GL_GLES
@ -1306,7 +1314,7 @@ eng_gl_error_get(void *data EINA_UNUSED)
#endif
end:
_evgl_error_set(EVAS_GL_SUCCESS);
glsym_evas_gl_common_error_set(data, EVAS_GL_SUCCESS);
return err;
}
@ -1435,7 +1443,7 @@ _native_free_cb(void *data, void *image)
if ((err = eglGetError()) != EGL_SUCCESS)
{
ERR("eglDestroyImage() failed.");
_evgl_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
}
}
else
@ -1627,7 +1635,7 @@ eng_image_native_set(void *data, void *image, void *native)
int err = eglGetError();
ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i with error %d",
(unsigned int)pm, num_config, err);
_evgl_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
}
else
{

View File

@ -4023,6 +4023,9 @@ init_gl(void)
ORD(gl_proc_address_get); // FIXME: Need to implement
ORD(gl_native_surface_get);
ORD(gl_api_get);
//ORD(gl_error_get);
//ORD(gl_current_context_get);
//ORD(gl_current_surface_get);
#undef ORD
}
}