summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/x11
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-06-29 14:58:33 +0800
committerChia-I Wu <[email protected]>2010-06-29 17:16:20 +0800
commitd5ab243d5a5bacbd2ba615d40f13c8ab37364745 (patch)
treebbf3c92d3c512e0d12eab3a7036c60c8e2cf7171 /src/gallium/state_trackers/egl/x11
parentd8e0e114567ec19fd59f974080a418dc959cc9b6 (diff)
st/egl: Move module loading code to targets.
Several changes are made. libegl.a no longer defines _eglMain. It defines functions to create and destroy a _EGLDriver instead. The creation function is called by the targets. It takes an egl_g3d_loader as its argument. The loader is defined by the targets and is in charge of creating st_api and pipe_screen. This allows us to move the module loading code to targets. Lastly, the modules are now loaded as the respective contexts are created.
Diffstat (limited to 'src/gallium/state_trackers/egl/x11')
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c15
-rw-r--r--src/gallium/state_trackers/egl/x11/native_x11.c37
-rw-r--r--src/gallium/state_trackers/egl/x11/native_x11.h6
-rw-r--r--src/gallium/state_trackers/egl/x11/native_ximage.c7
4 files changed, 27 insertions, 38 deletions
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 7464354fe61..1bef59d864f 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -692,7 +692,6 @@ static boolean
dri2_display_init_screen(struct native_display *ndpy)
{
struct dri2_display *dri2dpy = dri2_display(ndpy);
- const char *driver = driver_descriptor.name;
int fd;
if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) ||
@@ -703,19 +702,15 @@ dri2_display_init_screen(struct native_display *ndpy)
dri2dpy->dri_driver = x11_screen_probe_dri2(dri2dpy->xscr,
&dri2dpy->dri_major, &dri2dpy->dri_minor);
- if (!dri2dpy->dri_driver || !driver ||
- strcmp(dri2dpy->dri_driver, driver) != 0) {
- _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s",
- dri2dpy->dri_driver, driver);
- return FALSE;
- }
fd = x11_screen_enable_dri2(dri2dpy->xscr,
dri2_display_invalidate_buffers, &dri2dpy->base);
if (fd < 0)
return FALSE;
- dri2dpy->base.screen = driver_descriptor.create_screen(fd);
+ dri2dpy->base.screen =
+ dri2dpy->event_handler->new_drm_screen(&dri2dpy->base,
+ dri2dpy->dri_driver, fd);
if (!dri2dpy->base.screen) {
_eglLog(_EGL_WARNING, "failed to create DRM screen");
return FALSE;
@@ -739,7 +734,8 @@ dri2_display_hash_table_compare(void *key1, void *key2)
struct native_display *
x11_create_dri2_display(Display *dpy,
- struct native_event_handler *event_handler)
+ struct native_event_handler *event_handler,
+ void *user_data)
{
struct dri2_display *dri2dpy;
@@ -748,6 +744,7 @@ x11_create_dri2_display(Display *dpy,
return NULL;
dri2dpy->event_handler = event_handler;
+ dri2dpy->base.user_data = user_data;
dri2dpy->dpy = dpy;
if (!dri2dpy->dpy) {
diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c
index 7eec563bdfe..f0519405d3d 100644
--- a/src/gallium/state_trackers/egl/x11/native_x11.c
+++ b/src/gallium/state_trackers/egl/x11/native_x11.c
@@ -23,7 +23,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <string.h>
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
@@ -107,50 +106,38 @@ x11_get_probe_result(struct native_probe *nprobe)
}
static struct native_display *
-native_create_display(void *dpy, struct native_event_handler *event_handler)
+native_create_display(void *dpy, struct native_event_handler *event_handler,
+ void *user_data)
{
struct native_display *ndpy = NULL;
boolean force_sw;
force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
- if (!driver_descriptor.create_screen)
- force_sw = TRUE;
-
if (!force_sw) {
- ndpy = x11_create_dri2_display((Display *) dpy, event_handler);
+ ndpy = x11_create_dri2_display((Display *) dpy,
+ event_handler, user_data);
}
if (!ndpy) {
EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
_eglLog(level, "use software fallback");
- ndpy = x11_create_ximage_display((Display *) dpy, event_handler);
+ ndpy = x11_create_ximage_display((Display *) dpy,
+ event_handler, user_data);
}
return ndpy;
}
-static void
-x11_init_platform(struct native_platform *nplat)
-{
- static char x11_name[32];
-
- if (nplat->name)
- return;
-
- util_snprintf(x11_name, sizeof(x11_name), "X11/%s", driver_descriptor.name);
-
- nplat->name = x11_name;
- nplat->create_probe = x11_create_probe;
- nplat->get_probe_result = x11_get_probe_result;
- nplat->create_display = native_create_display;
-}
-
-static struct native_platform x11_platform;
+static const struct native_platform x11_platform = {
+ "X11", /* name */
+ x11_create_probe,
+ x11_get_probe_result,
+ native_create_display
+};
const struct native_platform *
native_get_x11_platform(void)
{
- x11_init_platform(&x11_platform);
return &x11_platform;
}
diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h
index a1c32c3455a..0b47837e1b5 100644
--- a/src/gallium/state_trackers/egl/x11/native_x11.h
+++ b/src/gallium/state_trackers/egl/x11/native_x11.h
@@ -30,10 +30,12 @@
struct native_display *
x11_create_ximage_display(Display *dpy,
- struct native_event_handler *event_handler);
+ struct native_event_handler *event_handler,
+ void *user_data);
struct native_display *
x11_create_dri2_display(Display *dpy,
- struct native_event_handler *event_handler);
+ struct native_event_handler *event_handler,
+ void *user_data);
#endif /* _NATIVE_X11_H_ */
diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
index ee10a04cfb2..4b32f6e36e0 100644
--- a/src/gallium/state_trackers/egl/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
@@ -442,7 +442,8 @@ ximage_display_destroy(struct native_display *ndpy)
struct native_display *
x11_create_ximage_display(Display *dpy,
- struct native_event_handler *event_handler)
+ struct native_event_handler *event_handler,
+ void *user_data)
{
struct ximage_display *xdpy;
struct sw_winsys *winsys = NULL;
@@ -462,6 +463,7 @@ x11_create_ximage_display(Display *dpy,
}
xdpy->event_handler = event_handler;
+ xdpy->base.user_data = user_data;
xdpy->xscr_number = DefaultScreen(xdpy->dpy);
xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
@@ -472,7 +474,8 @@ x11_create_ximage_display(Display *dpy,
if (!winsys)
goto fail;
- xdpy->base.screen = native_create_sw_screen(winsys);
+ xdpy->base.screen =
+ xdpy->event_handler->new_sw_screen(&xdpy->base, winsys);
if (!xdpy->base.screen)
goto fail;