1 #ifndef EGLCONFIG_INCLUDED
2 #define EGLCONFIG_INCLUDED
6 #include "egltypedefs.h"
9 #define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE
10 #define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT
11 #define _EGL_CONFIG_NUM_ATTRIBS \
12 (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1)
14 #define _EGL_CONFIG_STORAGE_SIZE _EGL_CONFIG_NUM_ATTRIBS
20 EGLint Storage
[_EGL_CONFIG_STORAGE_SIZE
];
24 #define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) _eglSetConfigKey(CONF, ATTR, VAL)
25 #define GET_CONFIG_ATTRIB(CONF, ATTR) _eglGetConfigKey(CONF, ATTR)
29 * Given a key, return an index into the storage of the config.
30 * Return -1 if the key is invalid.
33 _eglIndexConfig(const _EGLConfig
*conf
, EGLint key
)
36 if (key
>= _EGL_CONFIG_FIRST_ATTRIB
&&
37 key
< _EGL_CONFIG_FIRST_ATTRIB
+ _EGL_CONFIG_NUM_ATTRIBS
)
38 return key
- _EGL_CONFIG_FIRST_ATTRIB
;
45 * Reset all keys in the config to a given value.
48 _eglResetConfigKeys(_EGLConfig
*conf
, EGLint val
)
51 for (i
= 0; i
< _EGL_CONFIG_NUM_ATTRIBS
; i
++)
52 conf
->Storage
[i
] = val
;
57 * Update a config for a given key.
60 _eglSetConfigKey(_EGLConfig
*conf
, EGLint key
, EGLint val
)
62 EGLint idx
= _eglIndexConfig(conf
, key
);
64 conf
->Storage
[idx
] = val
;
69 * Return the value for a given key.
72 _eglGetConfigKey(const _EGLConfig
*conf
, EGLint key
)
74 EGLint idx
= _eglIndexConfig(conf
, key
);
76 return conf
->Storage
[idx
];
81 * Set a given attribute.
83 * Because _eglGetConfigAttrib is already used as a fallback driver
84 * function, this function is not considered to have a good name.
85 * SET_CONFIG_ATTRIB is preferred over this function.
88 _eglSetConfigAttrib(_EGLConfig
*conf
, EGLint attr
, EGLint val
)
90 SET_CONFIG_ATTRIB(conf
, attr
, val
);
95 _eglInitConfig(_EGLConfig
*config
, EGLint id
);
99 _eglAddConfig(_EGLDisplay
*dpy
, _EGLConfig
*conf
);
102 #ifndef _EGL_SKIP_HANDLE_CHECK
106 _eglCheckConfigHandle(EGLConfig config
, _EGLDisplay
*dpy
);
112 static INLINE EGLBoolean
113 _eglCheckConfigHandle(EGLConfig config
, _EGLDisplay
*dpy
)
115 _EGLConfig
*conf
= (_EGLConfig
*) config
;
116 return (dpy
&& conf
&& conf
->Display
== dpy
);
120 #endif /* _EGL_SKIP_HANDLE_CHECK */
124 * Lookup a handle to find the linked config.
125 * Return NULL if the handle has no corresponding linked config.
127 static INLINE _EGLConfig
*
128 _eglLookupConfig(EGLConfig config
, _EGLDisplay
*dpy
)
130 _EGLConfig
*conf
= (_EGLConfig
*) config
;
131 if (!_eglCheckConfigHandle(config
, dpy
))
138 * Return the handle of a linked config, or NULL.
140 static INLINE EGLConfig
141 _eglGetConfigHandle(_EGLConfig
*conf
)
143 return (EGLConfig
) ((conf
&& conf
->Display
) ? conf
: NULL
);
148 _eglValidateConfig(const _EGLConfig
*conf
, EGLBoolean for_matching
);
152 _eglMatchConfig(const _EGLConfig
*conf
, const _EGLConfig
*criteria
);
156 _eglParseConfigAttribList(_EGLConfig
*conf
, const EGLint
*attrib_list
);
160 _eglCompareConfigs(const _EGLConfig
*conf1
, const _EGLConfig
*conf2
,
161 const _EGLConfig
*criteria
, EGLBoolean compare_id
);
165 _eglSortConfigs(const _EGLConfig
**configs
, EGLint count
,
166 EGLint (*compare
)(const _EGLConfig
*, const _EGLConfig
*,
172 _eglChooseConfig(_EGLDriver
*drv
, _EGLDisplay
*dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
176 _eglGetConfigAttrib(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, EGLint attribute
, EGLint
*value
);
180 _eglGetConfigs(_EGLDriver
*drv
, _EGLDisplay
*dpy
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
183 #endif /* EGLCONFIG_INCLUDED */