summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/common
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-06-17 23:21:43 +0800
committerChia-I Wu <[email protected]>2010-06-29 17:16:19 +0800
commitf66a4e20c19d55005854bbee312947ec16e287e3 (patch)
treea8d4450952da24dd3a7f7e14965a28dcea86c677 /src/gallium/state_trackers/egl/common
parentf9574c5f890f3205efa4ab4ff509223e2a7c6b74 (diff)
st/egl: Introduce native_platform.
Move native_get_name, native_create_probe, native_get_probe_result, and native_create_display into struct native_platform, and add native_get_platform to get a handle to the struct.
Diffstat (limited to 'src/gallium/state_trackers/egl/common')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c47
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.h1
-rw-r--r--src/gallium/state_trackers/egl/common/native.h26
-rw-r--r--src/gallium/state_trackers/egl/common/native_probe.h16
4 files changed, 56 insertions, 34 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index b4ca861efee..6b54ee365c6 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -63,25 +63,44 @@ egl_g3d_init_st(_EGLDriver *drv)
}
/**
- * Get the probe object of the display.
+ * Get the native platform.
+ */
+static const struct native_platform *
+egl_g3d_get_platform(_EGLDriver *drv)
+{
+ struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
+
+ if (!gdrv->platform)
+ gdrv->platform = native_get_platform();
+
+ return gdrv->platform;
+}
+
+/**
+ * Get the probe result of the display.
*
* Note that this function may be called before the display is initialized.
*/
-static struct native_probe *
-egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy)
+static enum native_probe_result
+egl_g3d_get_probe_result(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
struct native_probe *nprobe;
+ const struct native_platform *nplat;
+
+ nplat = egl_g3d_get_platform(drv);
+ if (!nplat || !nplat->create_probe)
+ return NATIVE_PROBE_UNKNOWN;
nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key);
if (!nprobe || nprobe->display != dpy->PlatformDisplay) {
if (nprobe)
nprobe->destroy(nprobe);
- nprobe = native_create_probe(dpy->PlatformDisplay);
+ nprobe = nplat->create_probe(dpy->PlatformDisplay);
_eglSetProbeCache(gdrv->probe_key, (void *) nprobe);
}
- return nprobe;
+ return nplat->get_probe_result(nprobe);
}
/**
@@ -460,10 +479,15 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
{
struct egl_g3d_driver *gdrv = egl_g3d_driver(drv);
struct egl_g3d_display *gdpy;
+ const struct native_platform *nplat;
/* the probe object is unlikely to be needed again */
egl_g3d_destroy_probe(drv, dpy);
+ nplat = egl_g3d_get_platform(drv);
+ if (!nplat)
+ return EGL_FALSE;
+
gdpy = CALLOC_STRUCT(egl_g3d_display);
if (!gdpy) {
_eglError(EGL_BAD_ALLOC, "eglInitialize");
@@ -471,7 +495,8 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
}
dpy->DriverData = gdpy;
- gdpy->native = native_create_display(dpy->PlatformDisplay,
+ _eglLog(_EGL_INFO, "use %s for display %p", nplat->name, dpy->PlatformDisplay);
+ gdpy->native = nplat->create_display(dpy->PlatformDisplay,
&egl_g3d_native_event_handler);
if (!gdpy->native) {
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
@@ -543,12 +568,10 @@ egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname)
static EGLint
egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy)
{
- struct native_probe *nprobe;
enum native_probe_result res;
EGLint score;
- nprobe = egl_g3d_get_probe(drv, dpy);
- res = native_get_probe_result(nprobe);
+ res = egl_g3d_get_probe_result(drv, dpy);
switch (res) {
case NATIVE_PROBE_UNKNOWN:
@@ -582,12 +605,8 @@ egl_g3d_unload(_EGLDriver *drv)
_EGLDriver *
_eglMain(const char *args)
{
- static char driver_name[64];
struct egl_g3d_driver *gdrv;
- util_snprintf(driver_name, sizeof(driver_name),
- "Gallium/%s", native_get_name());
-
gdrv = CALLOC_STRUCT(egl_g3d_driver);
if (!gdrv)
return NULL;
@@ -597,7 +616,7 @@ _eglMain(const char *args)
gdrv->base.API.Terminate = egl_g3d_terminate;
gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address;
- gdrv->base.Name = driver_name;
+ gdrv->base.Name = "Gallium";
gdrv->base.Probe = egl_g3d_probe;
gdrv->base.Unload = egl_g3d_unload;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h
index d516d8fe03c..26043169ff8 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.h
@@ -47,6 +47,7 @@ struct egl_g3d_driver {
struct st_api *stapis[ST_API_COUNT];
EGLint api_mask;
+ const struct native_platform *platform;
EGLint probe_key;
};
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 494becb61f2..941adfc03ff 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -207,10 +207,28 @@ native_attachment_mask_test(uint mask, enum native_attachment att)
return !!(mask & (1 << att));
}
-const char *
-native_get_name(void);
+struct native_platform {
+ const char *name;
-struct native_display *
-native_create_display(void *dpy, struct native_event_handler *handler);
+ /**
+ * Return a probe object for the given display.
+ *
+ * Note that the returned object may be cached and used by different native
+ * display modules. It allows fast probing when multiple modules probe the
+ * same display.
+ */
+ struct native_probe *(*create_probe)(void *dpy);
+
+ /**
+ * Probe the probe object.
+ */
+ enum native_probe_result (*get_probe_result)(struct native_probe *nprobe);
+
+ struct native_display *(*create_display)(void *dpy,
+ struct native_event_handler *handler);
+};
+
+const struct native_platform *
+native_get_platform(void);
#endif /* _NATIVE_H_ */
diff --git a/src/gallium/state_trackers/egl/common/native_probe.h b/src/gallium/state_trackers/egl/common/native_probe.h
index 539c4aa70d2..c0b7f2a1ff7 100644
--- a/src/gallium/state_trackers/egl/common/native_probe.h
+++ b/src/gallium/state_trackers/egl/common/native_probe.h
@@ -49,20 +49,4 @@ struct native_probe {
void (*destroy)(struct native_probe *nprobe);
};
-/**
- * Return a probe object for the given display.
- *
- * Note that the returned object may be cached and used by different native
- * display modules. It allows fast probing when multiple modules probe the
- * same display.
- */
-struct native_probe *
-native_create_probe(void *dpy);
-
-/**
- * Probe the probe object.
- */
-enum native_probe_result
-native_get_probe_result(struct native_probe *nprobe);
-
#endif /* _NATIVE_PROBE_H_ */