diff options
author | Chia-I Wu <[email protected]> | 2009-08-13 13:38:24 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-08-18 08:49:09 -0600 |
commit | 5a2c9372a0d9fa1efd924f9386a4e3df47c17d0e (patch) | |
tree | 2dee512255194f0eb3eefe2a9064ece8da3b3885 /src/egl/main | |
parent | 0eaa02c836821556c1e8d0141f49f57e23f2548d (diff) |
egl: Some per-driver data should be per-display.
Move some fields of _EGLDriver to _EGLDisplay. It also becomes
unnecessary to pass _EGLDisplay to drivers when _eglMain is called.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglapi.c | 13 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 25 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 9 | ||||
-rw-r--r-- | src/egl/main/egldriver.h | 27 | ||||
-rw-r--r-- | src/egl/main/eglglobals.c | 1 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 2 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 54 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 2 | ||||
-rw-r--r-- | src/egl/main/egltypedefs.h | 2 |
9 files changed, 69 insertions, 66 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 464da00fe2c..a23b57120c4 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -87,15 +87,18 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); } - drv->APImajor = major_int; - drv->APIminor = minor_int; - snprintf(drv->Version, sizeof(drv->Version), + disp->APImajor = major_int; + disp->APIminor = minor_int; + snprintf(disp->Version, sizeof(disp->Version), "%d.%d (%s)", major_int, minor_int, drv->Name); + /* update the global notion of supported APIs */ + _eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask; + disp->Driver = drv; } else { - major_int = drv->APImajor; - minor_int = drv->APIminor; + major_int = disp->APImajor; + minor_int = disp->APIminor; } /* Update applications version of major and minor if not NULL */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 78fbf5b8401..e1cbbac837c 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -7,6 +7,19 @@ #include "egltypedefs.h" #include "eglhash.h" +#include "egldefines.h" + + +/** + * Optional EGL extensions info. + */ +struct _egl_extensions +{ + EGLBoolean MESA_screen_surface; + EGLBoolean MESA_copy_context; + + char String[_EGL_MAX_EXTENSIONS_LEN]; +}; struct _egl_display @@ -16,6 +29,18 @@ struct _egl_display const char *DriverName; _EGLDriver *Driver; + void *DriverData; /* private to driver */ + + int APImajor, APIminor; /**< as returned by eglInitialize() */ + char Version[1000]; /**< initialized from APImajor/minor, DriverName */ + + /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ + EGLint ClientAPIsMask; + char ClientAPIs[1000]; /**< updated by eglQueryString */ + + _EGLExtensions Extensions; + + int LargestPbuffer; EGLint NumScreens; _EGLScreen **Screens; /* array [NumScreens] */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 36cc2948c0e..0e6b2943859 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -245,7 +245,7 @@ _eglOpenLibrary(const char *driverName, lib_handle *handle) * owned by the driver and freed. */ static _EGLDriver * -_eglLoadDriver(_EGLDisplay *dpy, char *path, char *args) +_eglLoadDriver(char *path, char *args) { _EGLMain_t mainFunc; lib_handle lib; @@ -255,7 +255,7 @@ _eglLoadDriver(_EGLDisplay *dpy, char *path, char *args) if (!mainFunc) return NULL; - drv = mainFunc(dpy, args); + drv = mainFunc(args); if (!drv) { if (lib) close_library(lib); @@ -332,13 +332,10 @@ _eglPreloadDriver(_EGLDisplay *dpy) } } - drv = _eglLoadDriver(dpy, path, args); + drv = _eglLoadDriver(path, args); if (!drv) return NULL; - /* update the global notion of supported APIs */ - _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; - _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; return drv->Name; diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 430c0949d44..7fba9380859 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -4,19 +4,6 @@ #include "egltypedefs.h" #include "eglapi.h" -#include "egldefines.h" - - -/** - * Optional EGL extensions info. - */ -struct _egl_extensions -{ - EGLBoolean MESA_screen_surface; - EGLBoolean MESA_copy_context; - - char String[_EGL_MAX_EXTENSIONS_LEN]; -}; /** @@ -24,8 +11,6 @@ struct _egl_extensions */ struct _egl_driver { - EGLBoolean Initialized; /**< set by driver after initialized */ - void *LibHandle; /**< dlopen handle */ const char *Path; /**< path to this driver */ const char *Args; /**< args to load this driver */ @@ -36,21 +21,11 @@ struct _egl_driver /**< called before dlclose to release this driver */ void (*Unload)(_EGLDriver *drv); - int APImajor, APIminor; /**< as returned by eglInitialize() */ - char Version[1000]; /**< initialized from APImajor/minor, Name */ - - /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */ - EGLint ClientAPIsMask; - _EGLAPI API; /**< EGL API dispatch table */ - - _EGLExtensions Extensions; - - int LargestPbuffer; }; -extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args); +extern _EGLDriver *_eglMain(const char *args); extern const char * diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index a532f142b7e..8c14f9c4bf9 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -15,7 +15,6 @@ struct _egl_global _eglGlobal = &_eglGlobalMutex, /* Mutex */ 1, /* FreeScreenHandle */ 0x0, /* ClientAPIsMask */ - { 0x0 }, /* ClientAPIs */ 0, /* NumDrivers */ { NULL }, /* Drivers */ 1, /* NumAtExitCalls */ diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 1e2c6742630..d00d12afd85 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -18,8 +18,6 @@ struct _egl_global /* bitmaks of supported APIs (supported by _some_ driver) */ EGLint ClientAPIsMask; - char ClientAPIs[1000]; /**< updated by eglQueryString */ - EGLint NumDrivers; _EGLDriver *Drivers[10]; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 3440b77dd9f..b37213faf10 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -35,6 +35,7 @@ #include <string.h> #include "eglglobals.h" #include "eglmisc.h" +#include "egldisplay.h" /** @@ -42,38 +43,43 @@ * the driver's Extensions string. */ static void -_eglUpdateExtensionsString(_EGLDriver *drv) +_eglUpdateExtensionsString(_EGLDisplay *dpy) { - drv->Extensions.String[0] = 0; + char *exts = dpy->Extensions.String; - if (drv->Extensions.MESA_screen_surface) - strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); - if (drv->Extensions.MESA_copy_context) - strcat(drv->Extensions.String, "EGL_MESA_copy_context "); - assert(strlen(drv->Extensions.String) < _EGL_MAX_EXTENSIONS_LEN); + if (exts[0]) + return; + + if (dpy->Extensions.MESA_screen_surface) + strcat(exts, "EGL_MESA_screen_surface "); + if (dpy->Extensions.MESA_copy_context) + strcat(exts, "EGL_MESA_copy_context "); + assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN); } static void -_eglUpdateAPIsString(_EGLDriver *drv) +_eglUpdateAPIsString(_EGLDisplay *dpy) { - _eglGlobal.ClientAPIs[0] = 0; + char *apis = dpy->ClientAPIs; - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL "); + if (apis[0] || !dpy->ClientAPIsMask) + return; - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL_ES "); + if (dpy->ClientAPIsMask & EGL_OPENGL_BIT) + strcat(apis, "OpenGL "); - if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_ES2_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenGL_ES2 "); + if (dpy->ClientAPIsMask & EGL_OPENGL_ES_BIT) + strcat(apis, "OpenGL_ES "); - if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) - strcat(_eglGlobal.ClientAPIs, "OpenVG "); + if (dpy->ClientAPIsMask & EGL_OPENGL_ES2_BIT) + strcat(apis, "OpenGL_ES2 "); - assert(strlen(_eglGlobal.ClientAPIs) < sizeof(_eglGlobal.ClientAPIs)); -} + if (dpy->ClientAPIsMask & EGL_OPENVG_BIT) + strcat(apis, "OpenVG "); + assert(strlen(apis) < sizeof(dpy->ClientAPIs)); +} const char * @@ -85,14 +91,14 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) case EGL_VENDOR: return _EGL_VENDOR_STRING; case EGL_VERSION: - return drv->Version; + return dpy->Version; case EGL_EXTENSIONS: - _eglUpdateExtensionsString(drv); - return drv->Extensions.String; + _eglUpdateExtensionsString(dpy); + return dpy->Extensions.String; #ifdef EGL_VERSION_1_2 case EGL_CLIENT_APIS: - _eglUpdateAPIsString(drv); - return _eglGlobal.ClientAPIs; + _eglUpdateAPIsString(dpy); + return dpy->ClientAPIs; #endif default: _eglError(EGL_BAD_PARAMETER, "eglQueryString"); diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 056288c850e..adf125f88a2 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -243,7 +243,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); return EGL_TRUE; case EGL_LARGEST_PBUFFER: - *value = drv->LargestPbuffer; + *value = dpy->LargestPbuffer; return EGL_TRUE; case EGL_SURFACE_TYPE: *value = surface->Type; diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index 0a770dec0cb..4461440b9b7 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -29,7 +29,7 @@ typedef struct _egl_surface _EGLSurface; typedef struct _egl_thread_info _EGLThreadInfo; -typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args); +typedef _EGLDriver *(*_EGLMain_t)(const char *args); #endif /* EGLTYPEDEFS_INCLUDED */ |