summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2009-08-13 13:38:24 +0800
committerBrian Paul <[email protected]>2009-08-18 08:49:09 -0600
commit5a2c9372a0d9fa1efd924f9386a4e3df47c17d0e (patch)
tree2dee512255194f0eb3eefe2a9064ece8da3b3885 /src/gallium
parent0eaa02c836821556c1e8d0141f49f57e23f2548d (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/gallium')
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.c25
-rw-r--r--src/gallium/winsys/egl_xlib/egl_xlib.c36
2 files changed, 42 insertions, 19 deletions
diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c
index 107f45cbcb1..ced002c5359 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.c
+++ b/src/gallium/state_trackers/egl/egl_tracker.c
@@ -21,12 +21,20 @@ extern const struct dri_extension card_extensions[];
* 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;
@@ -53,12 +61,8 @@ _eglMain(_EGLDisplay *dpy, const char *args)
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;
}
@@ -199,7 +203,10 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
_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;
@@ -219,6 +226,8 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
struct drm_screen *screen;
int i = 0;
+ _eglReleaseDisplayResources(drv, dpy);
+
drmFreeVersion(dev->version);
for (i = 0; i < dev->count_screens; i++) {
@@ -235,12 +244,10 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
dev->screen->destroy(dev->screen);
dev->winsys = NULL;
- dev->api->destroy(dev->api);
drmClose(dev->drmFD);
_eglCleanupDisplay(dpy);
- free(dev);
return EGL_TRUE;
}
diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c
index ed7eab50dda..7a667568b8f 100644
--- a/src/gallium/winsys/egl_xlib/egl_xlib.c
+++ b/src/gallium/winsys/egl_xlib/egl_xlib.c
@@ -62,6 +62,7 @@ struct xlib_egl_driver
{
_EGLDriver Base; /**< base class */
+ EGLint apis;
struct pipe_winsys *winsys;
struct pipe_screen *screen;
};
@@ -194,9 +195,15 @@ static EGLBoolean
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;
@@ -212,6 +219,8 @@ xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
static EGLBoolean
xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
+ _eglReleaseDisplayResources(drv, dpy);
+ _eglCleanupDisplay(dpy);
return EGL_TRUE;
}
@@ -744,12 +753,22 @@ find_supported_apis(void)
}
+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;
@@ -759,10 +778,6 @@ _eglMain(_EGLDisplay *dpy, const char *args)
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;
@@ -777,16 +792,17 @@ _eglMain(_EGLDisplay *dpy, const char *args)
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();