From 35f9a9c5c99d0d723bb9361fc5018cf2fdec1fce Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 28 Sep 2009 17:25:48 +0800 Subject: [PATCH] egl: Allow driver to be built-in. This undoes a temporary hack. --- src/egl/Android.mk | 2 +- src/egl/main/egldriver.c | 127 +++++++++++++++++++++++++++-------------------- src/egl/main/egllog.c | 4 -- 3 files changed, 74 insertions(+), 59 deletions(-) diff --git a/src/egl/Android.mk b/src/egl/Android.mk index 2dd4df9c171..aeccb86de53 100644 --- a/src/egl/Android.mk +++ b/src/egl/Android.mk @@ -32,7 +32,7 @@ LOCAL_C_INCLUDES += \ external/mesa/src/mesa \ external/drm/shared-core -LOCAL_CFLAGS += -DPTHREADS -D_EGL_PLATFORM_X=1 +LOCAL_CFLAGS += -DPTHREADS LOCAL_SHARED_LIBRARIES := libdl libui libutils LOCAL_STATIC_LIBRARIES := libes1api diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index f693b304d44..4673617cff2 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -23,59 +23,70 @@ #if defined(_EGL_PLATFORM_X) #include -#elif defined(_EGL_PLATFORM_WINDOWS) -/* Use static linking on Windows for now */ -#define WINDOWS_STATIC_LINK #endif + /** * Wrappers for dlopen/dlclose() */ #if defined(_EGL_PLATFORM_WINDOWS) -#ifdef WINDOWS_STATIC_LINK - static const char *DefaultDriverName = "Windows EGL Static Library"; -#else - /* XXX Need to decide how to do dynamic name lookup on Windows */ - static const char *DefaultDriverName = "TBD"; -#endif - typedef HMODULE lib_handle; - - static HMODULE - open_library(const char *filename) - { -#ifdef WINDOWS_STATIC_LINK - return 0; -#else - return LoadLibrary(filename); -#endif - } - static void - close_library(HMODULE lib) - { -#ifdef WINDOWS_STATIC_LINK -#else - FreeLibrary(lib); -#endif - } + +/* XXX Need to decide how to do dynamic name lookup on Windows */ +static const char DefaultDriverName[] = "TBD"; + +typedef HMODULE lib_handle; + +static HMODULE +open_library(const char *filename) +{ + return LoadLibrary(filename); +} + +static void +close_library(HMODULE lib) +{ + FreeLibrary(lib); +} + #elif defined(_EGL_PLATFORM_X) - static const char *DefaultDriverName = "egl_softpipe"; - typedef void * lib_handle; - static void * - open_library(const char *filename) - { - return dlopen(filename, RTLD_LAZY); - } +static const char DefaultDriverName[] = "egl_softpipe"; + +typedef void * lib_handle; + +static void * +open_library(const char *filename) +{ + return dlopen(filename, RTLD_LAZY); +} + +static void +close_library(void *lib) +{ + dlclose(lib); +} + +#else /* _EGL_PLATFORM_NO_OS */ + +static const char DefaultDriverName[] = "builtin"; + +typedef void *lib_handle; + +static INLINE void * +open_library(const char *filename) +{ + return (void *) filename; +} + +static INLINE void +close_library(void *lib) +{ +} + - static void - close_library(void *lib) - { - dlclose(lib); - } - #endif @@ -96,14 +107,20 @@ _eglChooseDriver(_EGLDisplay *dpy, char **argsRet) path = _eglstrdup(path); #if defined(_EGL_PLATFORM_X) - if (!path && dpy->NativeDisplay) { + if (!path && dpy && dpy->NativeDisplay) { /* assume (wrongly!) that the native display is a display string */ path = _eglSplitDisplayString((const char *) dpy->NativeDisplay, &args); } suffix = "so"; #elif defined(_EGL_PLATFORM_WINDOWS) suffix = "dll"; -#endif /* _EGL_PLATFORM_X */ +#else /* _EGL_PLATFORM_NO_OS */ + if (path) { + free(path); + path = NULL; + } + suffix = NULL; +#endif if (!path) path = _eglstrdup(DefaultDriverName); @@ -143,11 +160,6 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) assert(driverPath); #if defined(_EGL_PLATFORM_WINDOWS) -/* Use static linking on Windows for now */ -#ifdef WINDOWS_STATIC_LINK - lib = 0; - mainFunc = (_EGLMain_t)_eglMain; -#else /* XXX untested */ _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath); lib = open_library(driverPath); @@ -157,7 +169,6 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) return NULL; } mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); -#endif #elif defined(_EGL_PLATFORM_X) _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath); lib = open_library(driverPath); @@ -170,6 +181,13 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) return NULL; } mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); +#else /* _EGL_PLATFORM_NO_OS */ + lib = 0; + /* must be default driver name */ + if (strcmp(driverPath, DefaultDriverName) == 0) + mainFunc = (_EGLMain_t) _eglMain; + else + mainFunc = NULL; #endif if (!mainFunc) { @@ -195,11 +213,7 @@ _eglLoadDriver(char *path, char *args) lib_handle lib; _EGLDriver *drv = NULL; - /* temporary hack */ - (void) _eglOpenLibrary; - mainFunc = _eglMain; - lib = (lib_handle) 0; - + mainFunc = _eglOpenLibrary(path, &lib); if (!mainFunc) return NULL; @@ -438,6 +452,11 @@ _eglFindAPIs(void) const char *es2_libname = "libGLESv2.so"; const char *gl_libname = "libGL.so"; const char *vg_libname = "libOpenVG.so"; +#else /* _EGL_PLATFORM_NO_OS */ + const char *es1_libname = NULL; + const char *es2_libname = NULL; + const char *gl_libname = NULL; + const char *vg_libname = NULL; #endif if ((lib = open_library(es1_libname))) { diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index 1d7a0a388c6..23eb523eebe 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -21,11 +21,7 @@ static EGLint ReportingLevel = -1; static void log_level_initialize(void) { -#if defined(_EGL_PLATFORM_X) char *log_env = getenv("EGL_LOG_LEVEL"); -#else - char *log_env = NULL; -#endif if (log_env == NULL) { ReportingLevel = FALLBACK_LOG_LEVEL; -- 2.11.0