summaryrefslogtreecommitdiffstats
path: root/src/egl/main/egldriver.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-01-19 18:39:59 +0800
committerChia-I Wu <[email protected]>2010-01-20 17:44:11 +0800
commitcf22fd5e5b13ccdb02ba0368ea722ede3bbc6de0 (patch)
treea0d8b791cd341b3108616c31014ef883922d12da /src/egl/main/egldriver.c
parent925f8113beba03e956351cee6780b1c7ab76add8 (diff)
egl: Improve driver matching.
Make drv->Probe return a score so that the matching can be done by finding the driver with the highest score.
Diffstat (limited to 'src/egl/main/egldriver.c')
-rw-r--r--src/egl/main/egldriver.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index dd363a18f46..ef1c366b302 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -218,32 +218,35 @@ _eglLoadDriver(const char *path, const char *args)
/**
* Match a display to a preloaded driver.
+ *
+ * The matching is done by finding the driver with the highest score.
*/
static _EGLDriver *
_eglMatchDriver(_EGLDisplay *dpy)
{
- _EGLDriver *defaultDriver = NULL;
- EGLint i;
+ _EGLDriver *best_drv = NULL;
+ EGLint best_score = -1, i;
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
_EGLDriver *drv = _eglGlobal.Drivers[i];
-
- /* display specifies a driver */
- if (dpy->DriverName) {
- if (strcmp(dpy->DriverName, drv->Name) == 0)
- return drv;
- }
- else if (drv->Probe) {
- if (drv->Probe(drv, dpy))
- return drv;
- }
- else {
- if (!defaultDriver)
- defaultDriver = drv;
+ EGLint score;
+
+ score = (drv->Probe) ? drv->Probe(drv, dpy) : 0;
+ if (score > best_score) {
+ if (best_drv) {
+ _eglLog(_EGL_DEBUG, "driver %s has higher score than %s",
+ drv->Name, best_drv->Name);
+ }
+
+ best_drv = drv;
+ best_score = score;
+ /* perfect match */
+ if (score >= 100)
+ break;
}
}
- return defaultDriver;
+ return best_drv;
}