From 8a6bdf3979c2dda0efc6771308bf9e5c32bbdab4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Oct 2010 00:47:22 +0800 Subject: egl: Minor changes to the _EGLConfig interface. Mainly to rename _eglAddConfig to _eglLinkConfig, along with a few clean ups. --- src/egl/drivers/dri2/egl_dri2.c | 2 +- src/egl/drivers/glx/egl_glx.c | 2 +- src/egl/main/eglconfig.c | 34 ++++++++++++++++--------- src/egl/main/eglconfig.h | 27 +++++--------------- src/gallium/state_trackers/egl/common/egl_g3d.c | 2 +- 5 files changed, 32 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index eb8996f7a7..75aa29f55b 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -272,7 +272,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id, if (conf != NULL) { memcpy(&conf->base, &base, sizeof base); conf->dri_config = dri_config; - _eglAddConfig(disp, &conf->base); + _eglLinkConfig(&conf->base); } return conf; diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 9bebc61de9..256de57ed8 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -452,7 +452,7 @@ create_configs(_EGLDisplay *dpy, struct GLX_egl_display *GLX_dpy, memcpy(GLX_conf, &template, sizeof(template)); GLX_conf->index = i; - _eglAddConfig(dpy, &GLX_conf->Base); + _eglLinkConfig(&GLX_conf->Base); id++; } } diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 4d313a9bb5..fec94fb20c 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -40,16 +40,18 @@ _eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id) /** - * 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); @@ -57,23 +59,29 @@ _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf) 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; } @@ -464,10 +472,13 @@ _eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) * 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; @@ -494,7 +505,7 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) 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) @@ -683,8 +694,7 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, 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, diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 892815fa63..3457670bfa 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -136,34 +136,20 @@ _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id); 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; } @@ -176,7 +162,8 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria); PUBLIC EGLBoolean -_eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list); +_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy, + const EGLint *attrib_list); PUBLIC EGLint diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index aaa2ff6bb2..8999b86e9b 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -373,7 +373,7 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) break; } - _eglAddConfig(dpy, &gconf->base); + _eglLinkConfig(&gconf->base); id++; } } -- cgit v1.2.3