summaryrefslogtreecommitdiff
path: root/src/egl/main
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2011-01-13 16:53:13 +0800
committerChia-I Wu <olv@lunarg.com>2011-01-13 17:57:38 +0800
commita4a38dcf61f141297a083ccac217200947d57b0d (patch)
tree54a4e03c9b0863fb98563e5e9824dc470a1708e2 /src/egl/main
parent47b2af2c62fec3ac0fb501a31e93fc8d00c18cb8 (diff)
egl: Cleanup _EGLDisplay initialization.
Reorder/rename and document the fields that should be set by the driver during initialization. Drop the major/minor arguments from drv->API.Initialize.
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglapi.c9
-rw-r--r--src/egl/main/eglapi.h2
-rw-r--r--src/egl/main/egldisplay.h28
-rw-r--r--src/egl/main/egldriver.c8
-rw-r--r--src/egl/main/eglmisc.c31
-rw-r--r--src/egl/main/eglstring.h1
6 files changed, 39 insertions, 40 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index efa9e97346..4e64ce6f71 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -57,7 +57,6 @@
#include <stdlib.h>
#include <string.h>
-#include "eglstring.h"
#include "eglcontext.h"
#include "egldisplay.h"
#include "egltypedefs.h"
@@ -294,16 +293,14 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
if (!_eglMatchDriver(disp, EGL_FALSE))
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
- _eglsnprintf(disp->Version, sizeof(disp->Version), "%d.%d (%s)",
- disp->APImajor, disp->APIminor, disp->Driver->Name);
/* limit to APIs supported by core */
- disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
+ disp->ClientAPIs &= _EGL_API_ALL_BITS;
}
/* Update applications version of major and minor if not NULL */
if ((major != NULL) && (minor != NULL)) {
- *major = disp->APImajor;
- *minor = disp->APIminor;
+ *major = disp->VersionMajor;
+ *minor = disp->VersionMinor;
}
RETURN_EGL_SUCCESS(disp, EGL_TRUE);
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 127becc9ac..01492082f6 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -12,7 +12,7 @@ typedef void (*_EGLProc)(void);
*/
/* driver funcs */
-typedef EGLBoolean (*Initialize_t)(_EGLDriver *, _EGLDisplay *dpy, EGLint *major, EGLint *minor);
+typedef EGLBoolean (*Initialize_t)(_EGLDriver *, _EGLDisplay *dpy);
typedef EGLBoolean (*Terminate_t)(_EGLDriver *, _EGLDisplay *dpy);
/* config funcs */
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index bcba05480a..faeb290647 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -74,8 +74,6 @@ struct _egl_extensions
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
-
- char String[_EGL_MAX_EXTENSIONS_LEN];
};
@@ -86,21 +84,23 @@ struct _egl_display
_EGLMutex Mutex;
- _EGLPlatformType Platform;
- void *PlatformDisplay;
-
- EGLBoolean Initialized; /**< True if the display is initialized */
- _EGLDriver *Driver;
- void *DriverData; /* private to driver */
+ _EGLPlatformType Platform; /**< The type of the platform display */
+ void *PlatformDisplay; /**< A pointer to the platform display */
- int APImajor, APIminor; /**< as returned by eglInitialize() */
- char Version[1000]; /**< initialized from APImajor/minor, DriverName */
+ _EGLDriver *Driver; /**< Matched driver of the display */
+ EGLBoolean Initialized; /**< True if the display is initialized */
- /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
- EGLint ClientAPIsMask;
- char ClientAPIs[1000]; /**< updated by eglQueryString */
+ /* these fields are set by the driver during init */
+ void *DriverData; /**< Driver private data */
+ EGLint VersionMajor; /**< EGL major version */
+ EGLint VersionMinor; /**< EGL minor version */
+ EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */
+ _EGLExtensions Extensions; /**< Extensions supported */
- _EGLExtensions Extensions;
+ /* these fields are derived from above */
+ char VersionString[1000]; /**< EGL_VERSION */
+ char ClientAPIsString[1000]; /**< EGL_CLIENT_APIS */
+ char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */
_EGLArray *Screens;
_EGLArray *Configs;
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 0f2e40abf5..1ae030db44 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -537,7 +537,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe)
_EGLModule *mod;
_EGLDriver *best_drv = NULL;
EGLint best_score = 0;
- EGLint major, minor, i;
+ EGLint i;
_eglLockMutex(&_eglModuleMutex);
@@ -562,7 +562,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe)
}
}
else {
- if (mod->Driver->API.Initialize(mod->Driver, dpy, &major, &minor)) {
+ if (mod->Driver->API.Initialize(mod->Driver, dpy)) {
best_drv = mod->Driver;
best_score = 100;
}
@@ -591,7 +591,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe)
mod->Driver->Probe(mod->Driver, dpy) : 1;
}
else {
- if (mod->Driver->API.Initialize(mod->Driver, dpy, &major, &minor))
+ if (mod->Driver->API.Initialize(mod->Driver, dpy))
best_score = 100;
}
@@ -621,8 +621,6 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe)
if (!use_probe) {
dpy->Driver = best_drv;
dpy->Initialized = EGL_TRUE;
- dpy->APImajor = major;
- dpy->APIminor = minor;
}
}
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index bbb96a908e..5a607dc080 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -36,6 +36,8 @@
#include "eglcurrent.h"
#include "eglmisc.h"
#include "egldisplay.h"
+#include "egldriver.h"
+#include "eglstring.h"
/**
@@ -73,11 +75,11 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
do { \
if (dpy->Extensions.ext) { \
_eglAppendExtension(&exts, "EGL_" #ext); \
- assert(exts <= dpy->Extensions.String + _EGL_MAX_EXTENSIONS_LEN); \
+ assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \
} \
} while (0)
- char *exts = dpy->Extensions.String;
+ char *exts = dpy->ExtensionsString;
if (exts[0])
return;
@@ -114,21 +116,21 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
static void
_eglUpdateAPIsString(_EGLDisplay *dpy)
{
- char *apis = dpy->ClientAPIs;
+ char *apis = dpy->ClientAPIsString;
- if (apis[0] || !dpy->ClientAPIsMask)
+ if (apis[0] || !dpy->ClientAPIs)
return;
- if (dpy->ClientAPIsMask & EGL_OPENGL_BIT)
+ if (dpy->ClientAPIs & EGL_OPENGL_BIT)
strcat(apis, "OpenGL ");
- if (dpy->ClientAPIsMask & EGL_OPENGL_ES_BIT)
+ if (dpy->ClientAPIs & EGL_OPENGL_ES_BIT)
strcat(apis, "OpenGL_ES ");
- if (dpy->ClientAPIsMask & EGL_OPENGL_ES2_BIT)
+ if (dpy->ClientAPIs & EGL_OPENGL_ES2_BIT)
strcat(apis, "OpenGL_ES2 ");
- if (dpy->ClientAPIsMask & EGL_OPENVG_BIT)
+ if (dpy->ClientAPIs & EGL_OPENVG_BIT)
strcat(apis, "OpenVG ");
assert(strlen(apis) < sizeof(dpy->ClientAPIs));
@@ -139,20 +141,21 @@ const char *
_eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name)
{
(void) drv;
- (void) dpy;
+
switch (name) {
case EGL_VENDOR:
return _EGL_VENDOR_STRING;
case EGL_VERSION:
- return dpy->Version;
+ _eglsnprintf(dpy->VersionString, sizeof(dpy->VersionString),
+ "%d.%d (%s)", dpy->VersionMajor, dpy->VersionMajor,
+ dpy->Driver->Name);
+ return dpy->VersionString;
case EGL_EXTENSIONS:
_eglUpdateExtensionsString(dpy);
- return dpy->Extensions.String;
-#ifdef EGL_VERSION_1_2
+ return dpy->ExtensionsString;
case EGL_CLIENT_APIS:
_eglUpdateAPIsString(dpy);
- return dpy->ClientAPIs;
-#endif
+ return dpy->ClientAPIsString;
default:
_eglError(EGL_BAD_PARAMETER, "eglQueryString");
return NULL;
diff --git a/src/egl/main/eglstring.h b/src/egl/main/eglstring.h
index f1d559b24a..8a8c43c1ef 100644
--- a/src/egl/main/eglstring.h
+++ b/src/egl/main/eglstring.h
@@ -4,6 +4,7 @@
#include <string.h>
#ifdef _EGL_OS_WINDOWS
+#include <stdio.h>
#define _eglstrcasecmp _stricmp
#define _eglsnprintf _snprintf
#else