scons: Revamp how to specify targets to build.
[mesa.git] / src / egl / main / eglconfig.h
1 #ifndef EGLCONFIG_INCLUDED
2 #define EGLCONFIG_INCLUDED
3
4
5 #include <assert.h>
6 #include <stddef.h>
7 #include "egltypedefs.h"
8
9
10 /* update _eglValidationTable and _eglOffsetOfConfig before updating this
11 * struct */
12 struct _egl_config
13 {
14 _EGLDisplay *Display;
15
16 /* core */
17 EGLint BufferSize;
18 EGLint AlphaSize;
19 EGLint BlueSize;
20 EGLint GreenSize;
21 EGLint RedSize;
22 EGLint DepthSize;
23 EGLint StencilSize;
24 EGLint ConfigCaveat;
25 EGLint ConfigID;
26 EGLint Level;
27 EGLint MaxPbufferHeight;
28 EGLint MaxPbufferPixels;
29 EGLint MaxPbufferWidth;
30 EGLint NativeRenderable;
31 EGLint NativeVisualID;
32 EGLint NativeVisualType;
33 EGLint Samples;
34 EGLint SampleBuffers;
35 EGLint SurfaceType;
36 EGLint TransparentType;
37 EGLint TransparentBlueValue;
38 EGLint TransparentGreenValue;
39 EGLint TransparentRedValue;
40 EGLint BindToTextureRGB;
41 EGLint BindToTextureRGBA;
42 EGLint MinSwapInterval;
43 EGLint MaxSwapInterval;
44 EGLint LuminanceSize;
45 EGLint AlphaMaskSize;
46 EGLint ColorBufferType;
47 EGLint RenderableType;
48 EGLint MatchNativePixmap;
49 EGLint Conformant;
50
51 /* extensions */
52 EGLint YInvertedNOK;
53 };
54
55
56 /**
57 * Map an EGL attribute enum to the offset of the member in _EGLConfig.
58 */
59 static INLINE EGLint
60 _eglOffsetOfConfig(EGLint attr)
61 {
62 switch (attr) {
63 #define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
64 /* core */
65 ATTRIB_MAP(EGL_BUFFER_SIZE, BufferSize);
66 ATTRIB_MAP(EGL_ALPHA_SIZE, AlphaSize);
67 ATTRIB_MAP(EGL_BLUE_SIZE, BlueSize);
68 ATTRIB_MAP(EGL_GREEN_SIZE, GreenSize);
69 ATTRIB_MAP(EGL_RED_SIZE, RedSize);
70 ATTRIB_MAP(EGL_DEPTH_SIZE, DepthSize);
71 ATTRIB_MAP(EGL_STENCIL_SIZE, StencilSize);
72 ATTRIB_MAP(EGL_CONFIG_CAVEAT, ConfigCaveat);
73 ATTRIB_MAP(EGL_CONFIG_ID, ConfigID);
74 ATTRIB_MAP(EGL_LEVEL, Level);
75 ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT, MaxPbufferHeight);
76 ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS, MaxPbufferPixels);
77 ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH, MaxPbufferWidth);
78 ATTRIB_MAP(EGL_NATIVE_RENDERABLE, NativeRenderable);
79 ATTRIB_MAP(EGL_NATIVE_VISUAL_ID, NativeVisualID);
80 ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE, NativeVisualType);
81 ATTRIB_MAP(EGL_SAMPLES, Samples);
82 ATTRIB_MAP(EGL_SAMPLE_BUFFERS, SampleBuffers);
83 ATTRIB_MAP(EGL_SURFACE_TYPE, SurfaceType);
84 ATTRIB_MAP(EGL_TRANSPARENT_TYPE, TransparentType);
85 ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE, TransparentBlueValue);
86 ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE, TransparentGreenValue);
87 ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE, TransparentRedValue);
88 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB, BindToTextureRGB);
89 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA, BindToTextureRGBA);
90 ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL, MinSwapInterval);
91 ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL, MaxSwapInterval);
92 ATTRIB_MAP(EGL_LUMINANCE_SIZE, LuminanceSize);
93 ATTRIB_MAP(EGL_ALPHA_MASK_SIZE, AlphaMaskSize);
94 ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE, ColorBufferType);
95 ATTRIB_MAP(EGL_RENDERABLE_TYPE, RenderableType);
96 ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP, MatchNativePixmap);
97 ATTRIB_MAP(EGL_CONFORMANT, Conformant);
98 /* extensions */
99 ATTRIB_MAP(EGL_Y_INVERTED_NOK, YInvertedNOK);
100 #undef ATTRIB_MAP
101 default:
102 return -1;
103 }
104 }
105
106
107 /**
108 * Update a config for a given key.
109 *
110 * Note that a valid key is not necessarily a valid attribute. There are gaps
111 * in the attribute enums. The separation is to catch application errors.
112 * Drivers should never set a key that is an invalid attribute.
113 */
114 static INLINE void
115 _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
116 {
117 EGLint offset = _eglOffsetOfConfig(key);
118 assert(offset >= 0);
119 *((EGLint *) ((char *) conf + offset)) = val;
120 }
121
122
123 /**
124 * Return the value for a given key.
125 */
126 static INLINE EGLint
127 _eglGetConfigKey(const _EGLConfig *conf, EGLint key)
128 {
129 EGLint offset = _eglOffsetOfConfig(key);
130 assert(offset >= 0);
131 return *((EGLint *) ((char *) conf + offset));
132 }
133
134
135 PUBLIC void
136 _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);
137
138
139 PUBLIC EGLConfig
140 _eglLinkConfig(_EGLConfig *conf);
141
142
143 extern _EGLConfig *
144 _eglLookupConfig(EGLConfig config, _EGLDisplay *dpy);
145
146
147 /**
148 * Return the handle of a linked config.
149 */
150 static INLINE EGLConfig
151 _eglGetConfigHandle(_EGLConfig *conf)
152 {
153 return (EGLConfig) conf;
154 }
155
156
157 PUBLIC EGLBoolean
158 _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);
159
160
161 PUBLIC EGLBoolean
162 _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);
163
164
165 PUBLIC EGLBoolean
166 _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
167 const EGLint *attrib_list);
168
169
170 PUBLIC EGLint
171 _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
172 const _EGLConfig *criteria, EGLBoolean compare_id);
173
174
175 PUBLIC void
176 _eglSortConfigs(const _EGLConfig **configs, EGLint count,
177 EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
178 void *),
179 void *priv_data);
180
181
182 extern EGLBoolean
183 _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
184
185
186 extern EGLBoolean
187 _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value);
188
189
190 extern EGLBoolean
191 _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
192
193
194 #endif /* EGLCONFIG_INCLUDED */