From 50c6136ac4336c383cafd3a8fff5916a92c0f288 Mon Sep 17 00:00:00 2001 From: "Mun, Gwan-gyeong" Date: Thu, 24 Dec 2015 12:57:15 +0900 Subject: [PATCH] Add error checking code for initialize of real EGL. Change-Id: Id635f0e87c5d5d6309b3ca10dd7df7c82bb82e69 --- src/coregl_export_egl.c | 170 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 136 insertions(+), 34 deletions(-) diff --git a/src/coregl_export_egl.c b/src/coregl_export_egl.c index da04740..b8ae001 100644 --- a/src/coregl_export_egl.c +++ b/src/coregl_export_egl.c @@ -8,8 +8,10 @@ Mutex init_export_mutex = MUTEX_INITIALIZER; mutex_lock(&init_export_mutex); \ if (export_initialized == 0) \ { \ - coregl_initialize(); \ - export_initialized = 1; \ + if (coregl_initialize() != 0) \ + { \ + export_initialized = 1; \ + } \ } \ mutex_unlock(&init_export_mutex); \ } @@ -18,49 +20,70 @@ EGLint coregl_api_eglGetError(void) { INIT_EXPORT(); - return ovr_eglGetError(); + if (!export_initialized) + return EGL_NOT_INITIALIZED; + else + return ovr_eglGetError(); } EGLDisplay coregl_api_eglGetDisplay(EGLNativeDisplayType display_id) { INIT_EXPORT(); - return ovr_eglGetDisplay(display_id); + if (!export_initialized) + return NULL; + else + return ovr_eglGetDisplay(display_id); } EGLBoolean coregl_api_eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) { INIT_EXPORT(); - return ovr_eglInitialize(dpy, major, minor); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglInitialize(dpy, major, minor); } EGLBoolean coregl_api_eglTerminate(EGLDisplay dpy) { INIT_EXPORT(); - return ovr_eglTerminate(dpy); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglTerminate(dpy); } EGLBoolean coregl_api_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { INIT_EXPORT(); - return ovr_eglGetConfigs(dpy, configs, config_size, num_config); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglGetConfigs(dpy, configs, config_size, num_config); } EGLBoolean coregl_api_eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) { INIT_EXPORT(); - return ovr_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); } EGLBoolean coregl_api_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { INIT_EXPORT(); - return ovr_eglGetConfigAttrib(dpy, config, attribute, value); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglGetConfigAttrib(dpy, config, attribute, value); } @@ -68,146 +91,208 @@ EGLSurface coregl_api_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) { INIT_EXPORT(); - return ovr_eglCreateWindowSurface(dpy, config, win, attrib_list); + if (!export_initialized) + return EGL_NO_SURFACE; + else + return ovr_eglCreateWindowSurface(dpy, config, win, attrib_list); } EGLSurface coregl_api_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) { INIT_EXPORT(); - return ovr_eglCreatePbufferSurface(dpy, config, attrib_list); + if (!export_initialized) + return EGL_NO_SURFACE; + else + return ovr_eglCreatePbufferSurface(dpy, config, attrib_list); } EGLSurface coregl_api_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) { INIT_EXPORT(); - return ovr_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); + if (!export_initialized) + return EGL_NO_SURFACE; + else + return ovr_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); } EGLBoolean coregl_api_eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { INIT_EXPORT(); - return ovr_eglDestroySurface(dpy, surface); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglDestroySurface(dpy, surface); } EGLBoolean coregl_api_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { INIT_EXPORT(); - return ovr_eglQuerySurface(dpy, surface, attribute, value); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglQuerySurface(dpy, surface, attribute, value); } EGLBoolean coregl_api_eglBindAPI(EGLenum api) { INIT_EXPORT(); - return ovr_eglBindAPI(api); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglBindAPI(api); } EGLenum coregl_api_eglQueryAPI(void) { INIT_EXPORT(); - return ovr_eglQueryAPI(); + if (!export_initialized) + return EGL_NONE; + else + return ovr_eglQueryAPI(); } EGLBoolean coregl_api_eglWaitClient(void) { INIT_EXPORT(); - return ovr_eglWaitClient(); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglWaitClient(); } EGLBoolean coregl_api_eglReleaseThread(void) { INIT_EXPORT(); - return ovr_eglReleaseThread(); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglReleaseThread(); } EGLSurface coregl_api_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) { INIT_EXPORT(); - return ovr_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); + if (!export_initialized) + return EGL_NO_SURFACE; + else + return ovr_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); } EGLBoolean coregl_api_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { INIT_EXPORT(); - return ovr_eglSurfaceAttrib(dpy, surface, attribute, value); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglSurfaceAttrib(dpy, surface, attribute, value); } EGLBoolean coregl_api_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { INIT_EXPORT(); - return ovr_eglBindTexImage(dpy, surface, buffer); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglBindTexImage(dpy, surface, buffer); } EGLBoolean coregl_api_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) { INIT_EXPORT(); - return ovr_eglReleaseTexImage(dpy, surface, buffer); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglReleaseTexImage(dpy, surface, buffer); } EGLBoolean coregl_api_eglSwapInterval(EGLDisplay dpy, EGLint interval) { INIT_EXPORT(); - return ovr_eglSwapInterval(dpy, interval); + if (!export_initialized) + EGL_FALSE; + else + return ovr_eglSwapInterval(dpy, interval); } EGLContext coregl_api_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) { INIT_EXPORT(); - return ovr_eglCreateContext(dpy, config, share_context, attrib_list); + if (!export_initialized) + return EGL_NO_CONTEXT; + else + return ovr_eglCreateContext(dpy, config, share_context, attrib_list); } EGLBoolean coregl_api_eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { INIT_EXPORT(); - return ovr_eglDestroyContext(dpy, ctx); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglDestroyContext(dpy, ctx); } EGLBoolean coregl_api_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { INIT_EXPORT(); - return ovr_eglMakeCurrent(dpy, draw, read, ctx); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglMakeCurrent(dpy, draw, read, ctx); } EGLContext coregl_api_eglGetCurrentContext(void) { INIT_EXPORT(); - return ovr_eglGetCurrentContext(); + if (!export_initialized) + return EGL_NO_CONTEXT; + else + return ovr_eglGetCurrentContext(); } EGLSurface coregl_api_eglGetCurrentSurface(EGLint readdraw) { INIT_EXPORT(); - return ovr_eglGetCurrentSurface(readdraw); + if (!export_initialized) + return EGL_NO_SURFACE; + else + return ovr_eglGetCurrentSurface(readdraw); } EGLDisplay coregl_api_eglGetCurrentDisplay(void) { INIT_EXPORT(); - return ovr_eglGetCurrentDisplay(); + if (!export_initialized) + return EGL_NO_DISPLAY; + else + return ovr_eglGetCurrentDisplay(); } EGLBoolean coregl_api_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) { INIT_EXPORT(); + if (!export_initialized) + return EGL_FALSE; return ovr_eglQueryContext(dpy, ctx, attribute, value); } @@ -215,41 +300,58 @@ EGLBoolean coregl_api_eglWaitGL(void) { INIT_EXPORT(); - return ovr_eglWaitGL(); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglWaitGL(); } EGLBoolean coregl_api_eglWaitNative(EGLint engine) { INIT_EXPORT(); - return ovr_eglWaitNative(engine); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglWaitNative(engine); } EGLBoolean coregl_api_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { INIT_EXPORT(); - return ovr_eglSwapBuffers(dpy, surface); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglSwapBuffers(dpy, surface); } EGLBoolean coregl_api_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { INIT_EXPORT(); - return ovr_eglCopyBuffers(dpy, surface, target); + if (!export_initialized) + return EGL_FALSE; + else + return ovr_eglCopyBuffers(dpy, surface, target); } _eng_fn coregl_api_eglGetProcAddress(const char* procname) { INIT_EXPORT(); - return ovr_eglGetProcAddress(procname); + if (!export_initialized) + return NULL; + else + return ovr_eglGetProcAddress(procname); } const char * coregl_api_eglQueryString(EGLDisplay dpy, EGLint name) { INIT_EXPORT(); + if (!export_initialized) + return NULL; return ovr_eglQueryString(dpy, name); } -- 2.7.4