From ea05299ce54ea0463626277907cab8e849884740 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 17 Jun 2010 23:45:41 +0800 Subject: st/egl: One driver per hardware. Merge multiple egl__.so into a single egl_gallium_.so. The environment variable EGL_PLATFORM is now used to modify the return value of _eglGetNativePlatform. --- src/egl/main/Makefile | 3 --- src/egl/main/SConscript | 1 - src/egl/main/egldisplay.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/egldisplay.h | 4 ++++ src/egl/main/egldriver.c | 42 +++++------------------------------ src/egl/main/egldriver.h | 5 ----- 6 files changed, 66 insertions(+), 45 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index be27d9450f..3834a5dbfa 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -51,8 +51,6 @@ OBJECTS = $(SOURCES:.c=.o) # use dl*() to load drivers LOCAL_CFLAGS = -D_EGL_OS_UNIX=1 -EGL_DEFAULT_PLATFORM = $(firstword $(EGL_PLATFORMS)) - # translate --with-egl-platforms to _EGLPlatformType EGL_NATIVE_PLATFORM=_EGL_INVALID_PLATFORM ifeq ($(firstword $(EGL_PLATFORMS)),x11) @@ -67,7 +65,6 @@ endif LOCAL_CFLAGS += \ -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ - -D_EGL_DEFAULT_PLATFORM=\"$(EGL_DEFAULT_PLATFORM)\" \ -D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" .c.o: diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index fad0671f38..69ad873bd6 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -10,7 +10,6 @@ if env['platform'] != 'winddk': env.Append(CPPDEFINES = [ '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS', - '_EGL_DEFAULT_PLATFORM=\\"gdi\\"', '_EGL_DRIVER_SEARCH_DIR=\\"\\"', '_EGL_OS_WINDOWS', 'KHRONOS_DLL_EXPORTS', diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index d666bdabe0..9980356c4a 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -14,6 +14,62 @@ #include "egllog.h" +/** + * Return the native platform by parsing EGL_PLATFORM. + */ +static _EGLPlatformType +_eglGetNativePlatformFromEnv(void) +{ + /* map --with-egl-platforms names to platform types */ + static const struct { + _EGLPlatformType platform; + const char *name; + } egl_platforms[_EGL_NUM_PLATFORMS] = { + { _EGL_PLATFORM_WINDOWS, "gdi" }, + { _EGL_PLATFORM_X11, "x11" }, + { _EGL_PLATFORM_DRM, "kms" }, + { _EGL_PLATFORM_FBDEV, "fbdev" } + }; + _EGLPlatformType plat = _EGL_INVALID_PLATFORM; + const char *plat_name; + EGLint i; + + plat_name = getenv("EGL_PLATFORM"); + /* try deprecated env variable */ + if (!plat_name || !plat_name[0]) + plat_name = getenv("EGL_DISPLAY"); + if (!plat_name || !plat_name[0]) + return _EGL_INVALID_PLATFORM; + + for (i = 0; i < _EGL_NUM_PLATFORMS; i++) { + if (strcmp(egl_platforms[i].name, plat_name) == 0) { + plat = egl_platforms[i].platform; + break; + } + } + + return plat; +} + + +/** + * Return the native platform. It is the platform of the EGL native types. + */ +_EGLPlatformType +_eglGetNativePlatform(void) +{ + static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM; + + if (native_platform == _EGL_INVALID_PLATFORM) { + native_platform = _eglGetNativePlatformFromEnv(); + if (native_platform == _EGL_INVALID_PLATFORM) + native_platform = _EGL_NATIVE_PLATFORM; + } + + return native_platform; +} + + /** * Finish display management. */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 0b325f7cf0..5a1caa9cc6 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -101,6 +101,10 @@ struct _egl_display }; +extern _EGLPlatformType +_eglGetNativePlatform(void); + + extern void _eglFiniDisplay(void); diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index db7b4a7471..c65df28645 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -39,7 +39,7 @@ /* XXX Need to decide how to do dynamic name lookup on Windows */ static const char *DefaultDriverNames[] = { - "egl_gdi_swrast" + "egl_gallium_swrast" }; typedef HMODULE lib_handle; @@ -464,36 +464,16 @@ _eglPreloadUserDriver(void) /** - * Preload platform drivers. - * - * Platform drivers are a set of drivers that support a certain window system. - * The window system may be specified by EGL_PLATFORM. + * Preload Gallium drivers. * * FIXME This makes libEGL a memory hog if an user driver is not specified and - * there are many platform drivers. + * there are many Gallium drivers */ static EGLBoolean -_eglPreloadPlatformDrivers(void) +_eglPreloadGalliumDrivers(void) { - const char *dpy; - char prefix[32]; - int ret; - - dpy = getenv("EGL_PLATFORM"); - /* try deprecated env variable */ - if (!dpy || !dpy[0]) - dpy = getenv("EGL_DISPLAY"); - if (!dpy || !dpy[0]) - dpy = _EGL_DEFAULT_PLATFORM; - if (!dpy || !dpy[0]) - return EGL_FALSE; - - ret = _eglsnprintf(prefix, sizeof(prefix), "egl_%s_", dpy); - if (ret < 0 || ret >= sizeof(prefix)) - return EGL_FALSE; - return (_eglPreloadForEach(_eglGetSearchPath(), - _eglLoaderPattern, (void *) prefix) > 0); + _eglLoaderPattern, (void *) "egl_gallium_") > 0); } @@ -518,7 +498,7 @@ _eglPreloadDrivers(void) } loaded = (_eglPreloadUserDriver() || - _eglPreloadPlatformDrivers()); + _eglPreloadGalliumDrivers()); _eglUnlockMutex(_eglGlobal.Mutex); @@ -580,16 +560,6 @@ _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor) } -/** - * Return the native platform. It is the platform of the EGL native types. - */ -_EGLPlatformType -_eglGetNativePlatform(void) -{ - return _EGL_NATIVE_PLATFORM; -} - - /** * Plug all the available fallback routines into the given driver's * dispatch table. diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 6a52374764..8b34c43b92 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -3,7 +3,6 @@ #include "egltypedefs.h" -#include "egldisplay.h" #include "eglapi.h" @@ -89,10 +88,6 @@ extern _EGLDriver * _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor); -extern _EGLPlatformType -_eglGetNativePlatform(void); - - PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); -- cgit v1.2.3