summaryrefslogtreecommitdiff
path: root/src/egl/main/egldriver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main/egldriver.c')
-rw-r--r--src/egl/main/egldriver.c157
1 files changed, 56 insertions, 101 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 0574f83f45..1dadbf783b 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -19,6 +19,7 @@
#include "eglscreen.h"
#include "eglstring.h"
#include "eglsurface.h"
+#include "eglimage.h"
#if defined(_EGL_PLATFORM_POSIX)
#include <dlfcn.h>
@@ -58,10 +59,24 @@ library_suffix(void)
}
+static EGLBoolean
+make_library_path(char *buf, unsigned int size, const char *name)
+{
+ EGLBoolean need_suffix;
+ const char *suffix = ".dll";
+ int ret;
+
+ need_suffix = (strchr(name, '.') == NULL);
+ ret = snprintf(buf, size, "%s%s", name, (need_suffix) ? suffix : "");
+
+ return ((unsigned int) ret < size);
+}
+
+
#elif defined(_EGL_PLATFORM_POSIX)
-static const char DefaultDriverName[] = "egl_softpipe";
+static const char DefaultDriverName[] = "egl_glx";
typedef void * lib_handle;
@@ -85,6 +100,24 @@ library_suffix(void)
}
+static EGLBoolean
+make_library_path(char *buf, unsigned int size, const char *name)
+{
+ EGLBoolean need_dir, need_suffix;
+ const char *suffix = ".so";
+ int ret;
+
+ need_dir = (strchr(name, '/') == NULL);
+ need_suffix = (strchr(name, '.') == NULL);
+
+ ret = snprintf(buf, size, "%s%s%s",
+ (need_dir) ? _EGL_DRIVER_SEARCH_DIR"/" : "", name,
+ (need_suffix) ? suffix : "");
+
+ return ((unsigned int) ret < size);
+}
+
+
#else /* _EGL_PLATFORM_NO_OS */
static const char DefaultDriverName[] = "builtin";
@@ -110,6 +143,14 @@ library_suffix(void)
}
+static EGLBoolean
+make_library_path(char *buf, unsigned int size, const char *name)
+{
+ int ret = snprintf(buf, size, name);
+ return ((unsigned int) ret < size);
+}
+
+
#endif
@@ -228,7 +269,7 @@ _eglLoadDriver(const char *path, const char *args)
*
* The matching is done by finding the driver with the highest score.
*/
-static _EGLDriver *
+_EGLDriver *
_eglMatchDriver(_EGLDisplay *dpy)
{
_EGLDriver *best_drv = NULL;
@@ -258,27 +299,6 @@ _eglMatchDriver(_EGLDisplay *dpy)
/**
- * Open a preloaded driver.
- */
-_EGLDriver *
-_eglOpenDriver(_EGLDisplay *dpy)
-{
- _EGLDriver *drv = _eglMatchDriver(dpy);
- return drv;
-}
-
-
-/**
- * Close a preloaded driver.
- */
-EGLBoolean
-_eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy)
-{
- return EGL_TRUE;
-}
-
-
-/**
* Preload a user driver.
*
* A user driver can be specified by EGL_DRIVER.
@@ -288,36 +308,21 @@ _eglPreloadUserDriver(void)
{
#if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS)
_EGLDriver *drv;
- char *env, *path;
- const char *suffix, *p;
+ char path[1024];
+ char *env;
env = getenv("EGL_DRIVER");
if (!env)
return EGL_FALSE;
- path = env;
- suffix = library_suffix();
-
- /* append suffix if there isn't */
- p = strrchr(path, '.');
- if (!p && suffix) {
- size_t len = strlen(path);
- char *tmp = malloc(len + strlen(suffix) + 2);
- if (tmp) {
- memcpy(tmp, path, len);
- tmp[len++] = '.';
- tmp[len] = '\0';
- strcat(tmp + len, suffix);
-
- path = tmp;
- }
- }
+ if (!make_library_path(path, sizeof(path), env))
+ return EGL_FALSE;
drv = _eglLoadDriver(path, NULL);
- if (path != env)
- free(path);
- if (!drv)
+ if (!drv) {
+ _eglLog(_EGL_WARNING, "EGL_DRIVER is set to an invalid driver");
return EGL_FALSE;
+ }
_eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv;
@@ -399,12 +404,9 @@ _eglPreloadDefaultDriver(void)
{
_EGLDriver *drv;
char path[1024];
- const char *suffix = library_suffix();
- if (suffix)
- snprintf(path, sizeof(path), "%s.%s", DefaultDriverName, suffix);
- else
- snprintf(path, sizeof(path), DefaultDriverName);
+ if (!make_library_path(path, sizeof(path), DefaultDriverName))
+ return EGL_FALSE;
drv = _eglLoadDriver(path, NULL);
if (!drv)
@@ -523,58 +525,11 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
#ifdef EGL_VERSION_1_2
drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer;
#endif /* EGL_VERSION_1_2 */
-}
-
-
-
-/**
- * Try to determine which EGL APIs (OpenGL, OpenGL ES, OpenVG, etc)
- * are supported on the system by looking for standard library names.
- */
-EGLint
-_eglFindAPIs(void)
-{
- EGLint mask = 0x0;
- lib_handle lib;
-#if defined(_EGL_PLATFORM_WINDOWS)
- /* XXX not sure about these names */
- const char *es1_libname = "libGLESv1_CM.dll";
- const char *es2_libname = "libGLESv2.dll";
- const char *gl_libname = "OpenGL32.dll";
- const char *vg_libname = "libOpenVG.dll";
-#elif defined(_EGL_PLATFORM_POSIX)
- const char *es1_libname = "libGLESv1_CM.so";
- const char *es2_libname = "libGLESv2.so";
- const char *gl_libname = "libGL.so";
- const char *vg_libname = "libOpenVG.so";
-#else /* _EGL_PLATFORM_NO_OS */
- const char *es1_libname = NULL;
- const char *es2_libname = NULL;
- const char *gl_libname = NULL;
- const char *vg_libname = NULL;
-#endif
-
- if ((lib = open_library(es1_libname))) {
- close_library(lib);
- mask |= EGL_OPENGL_ES_BIT;
- }
-
- if ((lib = open_library(es2_libname))) {
- close_library(lib);
- mask |= EGL_OPENGL_ES2_BIT;
- }
-
- if ((lib = open_library(gl_libname))) {
- close_library(lib);
- mask |= EGL_OPENGL_BIT;
- }
-
- if ((lib = open_library(vg_libname))) {
- close_library(lib);
- mask |= EGL_OPENVG_BIT;
- }
- return mask;
+#ifdef EGL_KHR_image_base
+ drv->API.CreateImageKHR = _eglCreateImageKHR;
+ drv->API.DestroyImageKHR = _eglDestroyImageKHR;
+#endif /* EGL_KHR_image_base */
}