_eglAddConfig(disp, config);
}
- drv->Initialized = EGL_TRUE;
+ /* enable supported extensions */
+ disp->Extensions.MESA_screen_surface = EGL_TRUE;
+ disp->Extensions.MESA_copy_context = EGL_TRUE;
*major = 1;
*minor = 0;
demoTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
/*DemoDriver *demo = DEMO_DRIVER(dpy);*/
- free(drv);
return EGL_TRUE;
}
}
+static void
+demoUnload(_EGLDriver *drv)
+{
+ free(drv);
+}
+
+
/**
* The bootstrap function. Return a new DemoDriver object and
* plug in API functions.
*/
_EGLDriver *
-_eglMain(_EGLDisplay *dpy, const char *args)
+_eglMain(const char *args)
{
DemoDriver *demo;
demo->Base.API.DestroySurface = demoDestroySurface;
demo->Base.API.DestroyContext = demoDestroyContext;
- /* enable supported extensions */
- demo->Base.Extensions.MESA_screen_surface = EGL_TRUE;
- demo->Base.Extensions.MESA_copy_context = EGL_TRUE;
+ demo->Base.Name = "egl/demo";
+ demo->Base.Unload = demoUnload;
return &demo->Base;
}
}
}
+ disp->ClientAPIsMask = all_apis;
+
glXQueryVersion(disp->Xdpy, &GLX_drv->glx_maj, &GLX_drv->glx_min);
- GLX_drv->Base.Initialized = EGL_TRUE;
-
GLX_drv->Base.Name = "GLX";
/* we're supporting EGL 1.4 */
{
_eglLog(_EGL_DEBUG, "GLX: eglTerminate");
+ _eglReleaseDisplayResources(drv, disp);
FreeDisplayExt(disp->Xdpy);
+ _eglCleanupDisplay(disp);
return EGL_TRUE;
}
}
+static void
+GLX_Unload(_EGLDriver *drv)
+{
+ struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
+ free(GLX_drv);
+}
+
+
/**
* This is the main entrypoint into the driver, called by libEGL.
* Create a new _EGLDriver object and init its dispatch table.
*/
_EGLDriver *
-_eglMain(_EGLDisplay *disp, const char *args)
+_eglMain(const char *args)
{
struct GLX_egl_driver *GLX_drv = CALLOC_STRUCT(GLX_egl_driver);
char *env;
GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers;
GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress;
- GLX_drv->Base.ClientAPIsMask = all_apis;
GLX_drv->Base.Name = "GLX";
+ GLX_drv->Base.Unload = GLX_Unload;
_eglLog(_EGL_DEBUG, "GLX: main(%s)", args);
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 */
#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
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] */
* 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;
if (!mainFunc)
return NULL;
- drv = mainFunc(dpy, args);
+ drv = mainFunc(args);
if (!drv) {
if (lib)
close_library(lib);
}
}
- 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;
#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];
-};
/**
*/
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 */
/**< 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 *
&_eglGlobalMutex, /* Mutex */
1, /* FreeScreenHandle */
0x0, /* ClientAPIsMask */
- { 0x0 }, /* ClientAPIs */
0, /* NumDrivers */
{ NULL }, /* Drivers */
1, /* NumAtExitCalls */
/* bitmaks of supported APIs (supported by _some_ driver) */
EGLint ClientAPIsMask;
- char ClientAPIs[1000]; /**< updated by eglQueryString */
-
EGLint NumDrivers;
_EGLDriver *Drivers[10];
#include <string.h>
#include "eglglobals.h"
#include "eglmisc.h"
+#include "egldisplay.h"
/**
* 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 *
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");
*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;
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 */
* Exported functions
*/
+static void
+drm_unload(_EGLDriver *drv)
+{
+ struct drm_device *dev = (struct drm_device *)drv;
+ dev->api->destroy(dev->api);
+ free(dev);
+}
+
/**
* The bootstrap function. Return a new drm_driver object and
* plug in API functions.
*/
_EGLDriver *
-_eglMain(_EGLDisplay *dpy, const char *args)
+_eglMain(const char *args)
{
struct drm_device *drm;
drm->base.API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa;
drm->base.API.SwapBuffers = drm_swap_buffers;
- drm->base.ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/;
drm->base.Name = "DRM/Gallium/Win";
-
- /* enable supported extensions */
- drm->base.Extensions.MESA_screen_surface = EGL_TRUE;
- drm->base.Extensions.MESA_copy_context = EGL_TRUE;
+ drm->base.Unload = drm_unload;
return &drm->base;
}
_eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
_eglAddConfig(disp, config);
- drv->Initialized = EGL_TRUE;
+ disp->ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/;
+ /* enable supported extensions */
+ disp->Extensions.MESA_screen_surface = EGL_TRUE;
+ disp->Extensions.MESA_copy_context = EGL_TRUE;
*major = 1;
*minor = 4;
struct drm_screen *screen;
int i = 0;
+ _eglReleaseDisplayResources(drv, dpy);
+
drmFreeVersion(dev->version);
for (i = 0; i < dev->count_screens; i++) {
dev->screen->destroy(dev->screen);
dev->winsys = NULL;
- dev->api->destroy(dev->api);
drmClose(dev->drmFD);
_eglCleanupDisplay(dpy);
- free(dev);
return EGL_TRUE;
}
{
_EGLDriver Base; /**< base class */
+ EGLint apis;
struct pipe_winsys *winsys;
struct pipe_screen *screen;
};
xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
EGLint *minor, EGLint *major)
{
+ struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
+
create_configs(drv, dpy);
- drv->Initialized = EGL_TRUE;
+ if (!dpy->Xdpy) {
+ dpy->Xdpy = XOpenDisplay(NULL);
+ }
+
+ dpy->ClientAPIsMask = xdrv->apis;
/* we're supporting EGL 1.4 */
*minor = 1;
static EGLBoolean
xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
+ _eglReleaseDisplayResources(drv, dpy);
+ _eglCleanupDisplay(dpy);
return EGL_TRUE;
}
}
+static void
+xlib_Unload(_EGLDriver *drv)
+{
+ struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
+ xdrv->screen->destroy(xdrv->screen);
+ free(xdrv->winsys);
+ free(xdrv);
+}
+
+
/**
* This is the main entrypoint into the driver.
* Called by libEGL to instantiate an _EGLDriver object.
*/
_EGLDriver *
-_eglMain(_EGLDisplay *dpy, const char *args)
+_eglMain(const char *args)
{
struct xlib_egl_driver *xdrv;
if (!xdrv)
return NULL;
- if (!dpy->Xdpy) {
- dpy->Xdpy = XOpenDisplay(NULL);
- }
-
_eglInitDriverFallbacks(&xdrv->Base);
xdrv->Base.API.Initialize = xlib_eglInitialize;
xdrv->Base.API.Terminate = xlib_eglTerminate;
xdrv->Base.API.MakeCurrent = xlib_eglMakeCurrent;
xdrv->Base.API.SwapBuffers = xlib_eglSwapBuffers;
- xdrv->Base.ClientAPIsMask = find_supported_apis();
- if (xdrv->Base.ClientAPIsMask == 0x0) {
+ xdrv->apis = find_supported_apis();
+ if (xdrv->apis == 0x0) {
/* the app isn't directly linked with any EGL-supprted APIs
* (such as libGLESv2.so) so use an EGL utility to see what
* APIs might be loaded dynamically on this system.
*/
- xdrv->Base.ClientAPIsMask = _eglFindAPIs();
- }
+ xdrv->apis = _eglFindAPIs();
+ }
xdrv->Base.Name = "Xlib/softpipe";
+ xdrv->Base.Unload = xlib_Unload;
/* create one winsys and use it for all contexts/surfaces */
xdrv->winsys = create_sw_winsys();