diff options
author | Chia-I Wu <[email protected]> | 2009-09-25 22:54:34 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-09-29 08:10:47 -0600 |
commit | 358c5a8fd1d518930c3e87316a2c743a661ac553 (patch) | |
tree | 4512d0167ce7a3e478885fde2c1126ee14149c7e /src/egl/main/eglconfig.h | |
parent | 7cda8ea44c2b65265cefa79bd29a4990ac81cee6 (diff) |
egl: Introduce config keys.
Config keys are almost config attributes. A valid config attribute is a
valid config key, but a valid config key may not be a valid config
attribute.
This commit does not distinguish the differences.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/egl/main/eglconfig.h')
-rw-r--r-- | src/egl/main/eglconfig.h | 86 |
1 files changed, 74 insertions, 12 deletions
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 36ed96ae956..b07632a92ef 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -2,27 +2,93 @@ #define EGLCONFIG_INCLUDED +#include <assert.h> #include "egltypedefs.h" -#include <GLES/gl.h> -#define MAX_ATTRIBS 128 -#define FIRST_ATTRIB EGL_BUFFER_SIZE +#define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE +#define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT +#define _EGL_CONFIG_NUM_ATTRIBS \ + (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1) + +#define _EGL_CONFIG_STORAGE_SIZE _EGL_CONFIG_NUM_ATTRIBS struct _egl_config { EGLConfig Handle; /* the public/opaque handle which names this config */ - EGLint Attrib[MAX_ATTRIBS]; + EGLint Storage[_EGL_CONFIG_STORAGE_SIZE]; }; -#define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) \ - assert((ATTR) - FIRST_ATTRIB < MAX_ATTRIBS); \ - ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB] = VAL) +#define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) _eglSetConfigKey(CONF, ATTR, VAL) +#define GET_CONFIG_ATTRIB(CONF, ATTR) _eglGetConfigKey(CONF, ATTR) -#define GET_CONFIG_ATTRIB(CONF, ATTR) ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB]) +/** + * Given a key, return an index into the storage of the config. + * Return -1 if the key is invalid. + */ +static INLINE EGLint +_eglIndexConfig(const _EGLConfig *conf, EGLint key) +{ + (void) conf; + if (key >= _EGL_CONFIG_FIRST_ATTRIB && + key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_ATTRIBS) + return key - _EGL_CONFIG_FIRST_ATTRIB; + else + return -1; +} + + +/** + * Reset all keys in the config to a given value. + */ +static INLINE void +_eglResetConfigKeys(_EGLConfig *conf, EGLint val) +{ + EGLint i; + for (i = 0; i < _EGL_CONFIG_NUM_ATTRIBS; i++) + conf->Storage[i] = val; +} + + +/** + * Update a config for a given key. + */ +static INLINE void +_eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) +{ + EGLint idx = _eglIndexConfig(conf, key); + assert(idx >= 0); + conf->Storage[idx] = val; +} + + +/** + * Return the value for a given key. + */ +static INLINE EGLint +_eglGetConfigKey(const _EGLConfig *conf, EGLint key) +{ + EGLint idx = _eglIndexConfig(conf, key); + assert(idx >= 0); + return conf->Storage[idx]; +} + + +/** + * Set a given attribute. + * + * Because _eglGetConfigAttrib is already used as a fallback driver + * function, this function is not considered to have a good name. + * SET_CONFIG_ATTRIB is preferred over this function. + */ +static INLINE void +_eglSetConfigAttrib(_EGLConfig *conf, EGLint attr, EGLint val) +{ + SET_CONFIG_ATTRIB(conf, attr, val); +} extern void @@ -57,8 +123,4 @@ extern EGLBoolean _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); -extern void -_eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val); - - #endif /* EGLCONFIG_INCLUDED */ |