/**
- * Link a config to a display and return the handle of the link.
+ * Link a config to its display and return the handle of the link.
* The handle can be passed to client directly.
*
* Note that we just save the ptr to the config (we don't copy the config).
*/
-EGLConfig
-_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
+PUBLIC EGLConfig
+_eglLinkConfig(_EGLConfig *conf)
{
+ _EGLDisplay *dpy = conf->Display;
+
/* sanity check */
- assert(conf->ConfigID > 0);
+ assert(dpy && conf->ConfigID > 0);
if (!dpy->Configs) {
dpy->Configs = _eglCreateArray("Config", 16);
return (EGLConfig) NULL;
}
- conf->Display = dpy;
_eglAppendArray(dpy->Configs, (void *) conf);
return (EGLConfig) conf;
}
-EGLBoolean
-_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
+/**
+ * Lookup a handle to find the linked config.
+ * Return NULL if the handle has no corresponding linked config.
+ */
+_EGLConfig *
+_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy)
{
_EGLConfig *conf;
+ if (!dpy)
+ return NULL;
+
conf = (_EGLConfig *) _eglFindArray(dpy->Configs, (void *) config);
if (conf)
assert(conf->Display == dpy);
- return (conf != NULL);
+ return conf;
}
* Return EGL_FALSE if any of the attribute is invalid.
*/
EGLBoolean
-_eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list)
+_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
+ const EGLint *attrib_list)
{
EGLint attr, val, i;
+ _eglInitConfig(conf, dpy, EGL_DONT_CARE);
+
/* reset to default values */
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) {
attr = _eglValidationTable[i].attr;
return EGL_FALSE;
/* ignore other attributes when EGL_CONFIG_ID is given */
- if (conf->ConfigID > 0) {
+ if (conf->ConfigID != EGL_DONT_CARE) {
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) {
attr = _eglValidationTable[i].attr;
if (attr != EGL_CONFIG_ID)
if (!num_configs)
return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs");
- _eglInitConfig(&criteria, disp, 0);
- if (!_eglParseConfigAttribList(&criteria, attrib_list))
+ if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
configList = (_EGLConfig **) _eglFilterArray(disp->Configs, &count,
PUBLIC EGLConfig
-_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf);
+_eglLinkConfig(_EGLConfig *conf);
-extern EGLBoolean
-_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy);
-
-
-/**
- * Lookup a handle to find the linked config.
- * Return NULL if the handle has no corresponding linked config.
- */
-static INLINE _EGLConfig *
-_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy)
-{
- _EGLConfig *conf = (_EGLConfig *) config;
- if (!dpy || !_eglCheckConfigHandle(config, dpy))
- conf = NULL;
- return conf;
-}
+extern _EGLConfig *
+_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy);
/**
- * Return the handle of a linked config, or NULL.
+ * Return the handle of a linked config.
*/
static INLINE EGLConfig
_eglGetConfigHandle(_EGLConfig *conf)
{
- return (EGLConfig) ((conf && conf->Display) ? conf : NULL);
+ return (EGLConfig) conf;
}
PUBLIC EGLBoolean
-_eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list);
+_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
+ const EGLint *attrib_list);
PUBLIC EGLint