summaryrefslogtreecommitdiff
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c82
-rw-r--r--src/egl/main/SConscript49
-rw-r--r--src/egl/main/eglapi.c4
-rw-r--r--src/egl/main/eglcompiler.h16
-rw-r--r--src/egl/main/egldriver.c12
-rw-r--r--src/egl/main/egllog.c3
-rw-r--r--src/egl/main/eglmisc.c4
-rw-r--r--src/egl/main/eglstring.c2
-rw-r--r--src/egl/main/eglstring.h9
9 files changed, 130 insertions, 51 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index eb9a6510ed..aa384cb117 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -628,40 +628,12 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
return EGL_TRUE;
}
-/**
- * Called via eglInitialize(), GLX_drv->API.Initialize().
- */
static EGLBoolean
-dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
- EGLint *major, EGLint *minor)
+dri2_load_driver(_EGLDisplay *disp)
{
+ struct dri2_egl_display *dri2_dpy = disp->DriverData;
const __DRIextension **extensions;
- struct dri2_egl_display *dri2_dpy;
char path[PATH_MAX], *search_paths, *p, *next, *end;
- unsigned int api_mask;
-
- dri2_dpy = malloc(sizeof *dri2_dpy);
- if (!dri2_dpy)
- return _eglError(EGL_BAD_ALLOC, "eglInitialize");
-
- disp->DriverData = (void *) dri2_dpy;
- if (disp->NativeDisplay == NULL) {
- dri2_dpy->conn = xcb_connect(0, 0);
- if (!dri2_dpy->conn) {
- _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
- goto cleanup_dpy;
- }
- } else {
- dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
- }
-
- if (dri2_dpy->conn == NULL)
- goto cleanup_conn;
-
- if (dri2_dpy->conn) {
- if (!dri2_connect(dri2_dpy))
- goto cleanup_conn;
- }
search_paths = NULL;
if (geteuid() == getuid()) {
@@ -698,7 +670,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
_eglLog(_EGL_WARNING,
"DRI2: failed to open any driver (search paths %s)",
search_paths);
- goto cleanup_conn;
+ return EGL_FALSE;
}
_eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path);
@@ -706,11 +678,53 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (extensions == NULL) {
_eglLog(_EGL_WARNING,
"DRI2: driver exports no extensions (%s)", dlerror());
- goto cleanup_driver;
+ dlclose(dri2_dpy->driver);
+ return EGL_FALSE;
}
- if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions))
- goto cleanup_driver;
+ if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions)) {
+ dlclose(dri2_dpy->driver);
+ return EGL_FALSE;
+ }
+
+ return EGL_TRUE;
+}
+
+
+/**
+ * Called via eglInitialize(), GLX_drv->API.Initialize().
+ */
+static EGLBoolean
+dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
+ EGLint *major, EGLint *minor)
+{
+ const __DRIextension **extensions;
+ struct dri2_egl_display *dri2_dpy;
+ unsigned int api_mask;
+
+ dri2_dpy = malloc(sizeof *dri2_dpy);
+ if (!dri2_dpy)
+ return _eglError(EGL_BAD_ALLOC, "eglInitialize");
+
+ disp->DriverData = (void *) dri2_dpy;
+ if (disp->NativeDisplay == NULL) {
+ dri2_dpy->conn = xcb_connect(0, 0);
+ } else {
+ dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
+ }
+
+ if (xcb_connection_has_error(dri2_dpy->conn)) {
+ _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
+ goto cleanup_dpy;
+ }
+
+ if (dri2_dpy->conn) {
+ if (!dri2_connect(dri2_dpy))
+ goto cleanup_conn;
+ }
+
+ if (!dri2_load_driver(disp))
+ goto cleanup_conn;
dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR);
if (dri2_dpy->fd == -1) {
diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript
new file mode 100644
index 0000000000..f3fe9966b3
--- /dev/null
+++ b/src/egl/main/SConscript
@@ -0,0 +1,49 @@
+#######################################################################
+# SConscript for EGL
+
+
+Import('*')
+
+if env['platform'] != 'winddk':
+
+ env = env.Clone()
+
+ env.Append(CPPDEFINES = [
+ '_EGL_DEFAULT_DISPLAY=\\"gdi\\"',
+ '_EGL_DRIVER_SEARCH_DIR=\\"\\"',
+ '_EGL_PLATFORM_WINDOWS',
+ 'KHRONOS_DLL_EXPORTS',
+ ])
+
+ env.Append(CPPPATH = [
+ '#/include',
+ ])
+
+ egl_sources = [
+ 'eglapi.c',
+ 'eglconfig.c',
+ 'eglconfigutil.c',
+ 'eglcontext.c',
+ 'eglcurrent.c',
+ 'egldisplay.c',
+ 'egldriver.c',
+ 'eglglobals.c',
+ 'eglimage.c',
+ 'egllog.c',
+ 'eglmisc.c',
+ 'eglmode.c',
+ 'eglscreen.c',
+ 'eglstring.c',
+ 'eglsurface.c',
+ ]
+
+ egl = env.SharedLibrary(
+ target = 'libEGL',
+ source = egl_sources,
+ )
+
+ env.InstallSharedLibrary(egl, version=(1, 4, 0))
+
+ egl = [env.FindIxes(egl, 'LIBPREFIX', 'LIBSUFFIX')]
+
+ Export('egl')
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 1a533e0880..9912043e06 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -56,6 +56,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include "eglstring.h"
#include "eglcontext.h"
#include "egldisplay.h"
#include "egltypedefs.h"
@@ -284,7 +286,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
disp->APImajor = major_int;
disp->APIminor = minor_int;
- snprintf(disp->Version, sizeof(disp->Version),
+ _eglsnprintf(disp->Version, sizeof(disp->Version),
"%d.%d (%s)", major_int, minor_int, drv->Name);
/* limit to APIs supported by core */
diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h
index 401a9cf56a..90c75e84b2 100644
--- a/src/egl/main/eglcompiler.h
+++ b/src/egl/main/eglcompiler.h
@@ -12,9 +12,7 @@
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
-# ifndef __eglplatform_h_
- typedef __int32 int32_t;
-# endif
+ typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
@@ -64,10 +62,14 @@
/**
* Function visibility
*/
-#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
-# define PUBLIC __attribute__((visibility("default")))
-#else
-# define PUBLIC
+#ifndef PUBLIC
+# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define PUBLIC __attribute__((visibility("default")))
+# elif defined(_MSC_VER)
+# define PUBLIC __declspec(dllexport)
+# else
+# define PUBLIC
+# endif
#endif
/**
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 566554d51d..631a8710ac 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+
+#include "eglstring.h"
#include "eglconfig.h"
#include "eglcontext.h"
#include "egldefines.h"
@@ -36,8 +38,8 @@
/* XXX Need to decide how to do dynamic name lookup on Windows */
-static const char DefaultDriverNames[] = {
- "TBD",
+static const char *DefaultDriverNames[] = {
+ "egl_gdi_swrast"
};
typedef HMODULE lib_handle;
@@ -411,7 +413,7 @@ _eglGetSearchPath(void)
#endif /* _EGL_PLATFORM_POSIX */
if (p) {
- ret = snprintf(buffer, sizeof(buffer),
+ ret = _eglsnprintf(buffer, sizeof(buffer),
"%s:%s", p, _EGL_DRIVER_SEARCH_DIR);
if (ret > 0 && ret < sizeof(buffer))
search_path = buffer;
@@ -483,7 +485,7 @@ _eglPreloadDisplayDrivers(void)
if (!dpy || !dpy[0])
return EGL_FALSE;
- ret = snprintf(prefix, sizeof(prefix), "egl_%s_", dpy);
+ ret = _eglsnprintf(prefix, sizeof(prefix), "egl_%s_", dpy);
if (ret < 0 || ret >= sizeof(prefix))
return EGL_FALSE;
@@ -571,7 +573,7 @@ _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor)
_eglUnlockMutex(_eglGlobal.Mutex);
- return drv;
+ return _eglGlobal.NumDrivers > 0 ? drv : NULL;
}
diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
index 11a9bf7275..8f3bae2243 100644
--- a/src/egl/main/egllog.c
+++ b/src/egl/main/egllog.c
@@ -11,6 +11,7 @@
#include <string.h>
#include "egllog.h"
+#include "eglstring.h"
#include "eglmutex.h"
#define MAXSTRING 1000
@@ -116,7 +117,7 @@ _eglInitLogger(void)
log_env = getenv("EGL_LOG_LEVEL");
if (log_env) {
for (i = 0; level_strings[i]; i++) {
- if (strcasecmp(log_env, level_strings[i]) == 0) {
+ if (_eglstrcasecmp(log_env, level_strings[i]) == 0) {
level = i;
break;
}
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index e62a9e7de8..4652969659 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -45,7 +45,7 @@ static EGLint
_eglAppendExtension(char **str, const char *ext)
{
char *s = *str;
- EGLint len = strlen(ext);
+ size_t len = strlen(ext);
if (s) {
memcpy(s, ext, len);
@@ -58,7 +58,7 @@ _eglAppendExtension(char **str, const char *ext)
len++;
}
- return len;
+ return (EGLint) len;
}
diff --git a/src/egl/main/eglstring.c b/src/egl/main/eglstring.c
index ba7406158c..e4ab19136f 100644
--- a/src/egl/main/eglstring.c
+++ b/src/egl/main/eglstring.c
@@ -11,7 +11,7 @@ char *
_eglstrdup(const char *s)
{
if (s) {
- int l = strlen(s);
+ size_t l = strlen(s);
char *s2 = malloc(l + 1);
if (s2)
strcpy(s2, s);
diff --git a/src/egl/main/eglstring.h b/src/egl/main/eglstring.h
index 10468636e8..bebb758dd8 100644
--- a/src/egl/main/eglstring.h
+++ b/src/egl/main/eglstring.h
@@ -1,6 +1,15 @@
#ifndef EGLSTRING_INCLUDED
#define EGLSTRING_INCLUDED
+#include <string.h>
+
+#ifdef _EGL_PLATFORM_WINDOWS
+#define _eglstrcasecmp _stricmp
+#define _eglsnprintf _snprintf
+#else
+#define _eglstrcasecmp strcasecmp
+#define _eglsnprintf snprintf
+#endif
extern char *
_eglstrdup(const char *s);