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_CONTIGUOUS_ATTRIBS \
12 (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1)
14 /* Attributes outside the contiguous block:
18 #define _EGL_CONFIG_FIRST_EXTRA_ATTRIB _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS
19 #define _EGL_CONFIG_NUM_EXTRA_ATTRIBS 1
21 #define _EGL_CONFIG_NUM_ATTRIBS \
22 _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS + _EGL_CONFIG_NUM_EXTRA_ATTRIBS
28 EGLint Storage
[_EGL_CONFIG_NUM_ATTRIBS
];
33 * Macros for source level compatibility.
35 #define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) _eglSetConfigKey(CONF, ATTR, VAL)
36 #define GET_CONFIG_ATTRIB(CONF, ATTR) _eglGetConfigKey(CONF, ATTR)
40 * Given a key, return an index into the storage of the config.
41 * Return -1 if the key is invalid.
44 _eglIndexConfig(const _EGLConfig
*conf
, EGLint key
)
47 if (key
>= _EGL_CONFIG_FIRST_ATTRIB
&&
48 key
< _EGL_CONFIG_FIRST_ATTRIB
+ _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS
)
49 return key
- _EGL_CONFIG_FIRST_ATTRIB
;
52 case EGL_Y_INVERTED_NOK
:
53 return _EGL_CONFIG_FIRST_EXTRA_ATTRIB
;
61 * Reset all keys in the config to a given value.
64 _eglResetConfigKeys(_EGLConfig
*conf
, EGLint val
)
67 for (i
= 0; i
< _EGL_CONFIG_NUM_ATTRIBS
; i
++)
68 conf
->Storage
[i
] = val
;
73 * Update a config for a given key.
75 * Note that a valid key is not necessarily a valid attribute. There are gaps
76 * in the attribute enums. The separation is to catch application errors.
77 * Drivers should never set a key that is an invalid attribute.
80 _eglSetConfigKey(_EGLConfig
*conf
, EGLint key
, EGLint val
)
82 EGLint idx
= _eglIndexConfig(conf
, key
);
84 conf
->Storage
[idx
] = val
;
89 * Return the value for a given key.
92 _eglGetConfigKey(const _EGLConfig
*conf
, EGLint key
)
94 EGLint idx
= _eglIndexConfig(conf
, key
);
96 return conf
->Storage
[idx
];
101 _eglInitConfig(_EGLConfig
*config
, _EGLDisplay
*dpy
, EGLint id
);
105 _eglAddConfig(_EGLDisplay
*dpy
, _EGLConfig
*conf
);
109 _eglCheckConfigHandle(EGLConfig config
, _EGLDisplay
*dpy
);
113 * Lookup a handle to find the linked config.
114 * Return NULL if the handle has no corresponding linked config.
116 static INLINE _EGLConfig
*
117 _eglLookupConfig(EGLConfig config
, _EGLDisplay
*dpy
)
119 _EGLConfig
*conf
= (_EGLConfig
*) config
;
120 if (!_eglCheckConfigHandle(config
, dpy
))
127 * Return the handle of a linked config, or NULL.
129 static INLINE EGLConfig
130 _eglGetConfigHandle(_EGLConfig
*conf
)
132 return (EGLConfig
) ((conf
&& conf
->Display
) ? conf
: NULL
);
137 _eglValidateConfig(const _EGLConfig
*conf
, EGLBoolean for_matching
);
141 _eglMatchConfig(const _EGLConfig
*conf
, const _EGLConfig
*criteria
);
145 _eglParseConfigAttribList(_EGLConfig
*conf
, const EGLint
*attrib_list
);
149 _eglCompareConfigs(const _EGLConfig
*conf1
, const _EGLConfig
*conf2
,
150 const _EGLConfig
*criteria
, EGLBoolean compare_id
);
154 _eglSortConfigs(const _EGLConfig
**configs
, EGLint count
,
155 EGLint (*compare
)(const _EGLConfig
*, const _EGLConfig
*,
161 _eglChooseConfig(_EGLDriver
*drv
, _EGLDisplay
*dpy
, const EGLint
*attrib_list
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
165 _eglGetConfigAttrib(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, EGLint attribute
, EGLint
*value
);
169 _eglGetConfigs(_EGLDriver
*drv
, _EGLDisplay
*dpy
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
172 #endif /* EGLCONFIG_INCLUDED */