egl/main: no longer export internal function
[mesa.git] / src / egl / main / eglconfig.h
1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 *
28 **************************************************************************/
29
30
31 #ifndef EGLCONFIG_INCLUDED
32 #define EGLCONFIG_INCLUDED
33
34
35 #include <assert.h>
36 #include <stddef.h>
37 #include "c99_compat.h"
38
39 #include "egltypedefs.h"
40
41
42 /* update _eglValidationTable and _eglOffsetOfConfig before updating this
43 * struct */
44 struct _egl_config
45 {
46 _EGLDisplay *Display;
47
48 /* core */
49 EGLint BufferSize;
50 EGLint AlphaSize;
51 EGLint BlueSize;
52 EGLint GreenSize;
53 EGLint RedSize;
54 EGLint DepthSize;
55 EGLint StencilSize;
56 EGLint ConfigCaveat;
57 EGLint ConfigID;
58 EGLint Level;
59 EGLint MaxPbufferHeight;
60 EGLint MaxPbufferPixels;
61 EGLint MaxPbufferWidth;
62 EGLint NativeRenderable;
63 EGLint NativeVisualID;
64 EGLint NativeVisualType;
65 EGLint Samples;
66 EGLint SampleBuffers;
67 EGLint SurfaceType;
68 EGLint TransparentType;
69 EGLint TransparentBlueValue;
70 EGLint TransparentGreenValue;
71 EGLint TransparentRedValue;
72 EGLint BindToTextureRGB;
73 EGLint BindToTextureRGBA;
74 EGLint MinSwapInterval;
75 EGLint MaxSwapInterval;
76 EGLint LuminanceSize;
77 EGLint AlphaMaskSize;
78 EGLint ColorBufferType;
79 EGLint RenderableType;
80 EGLint MatchNativePixmap;
81 EGLint Conformant;
82
83 /* extensions */
84 EGLint YInvertedNOK;
85 };
86
87
88 /**
89 * Map an EGL attribute enum to the offset of the member in _EGLConfig.
90 */
91 static inline EGLint
92 _eglOffsetOfConfig(EGLint attr)
93 {
94 switch (attr) {
95 #define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
96 /* core */
97 ATTRIB_MAP(EGL_BUFFER_SIZE, BufferSize);
98 ATTRIB_MAP(EGL_ALPHA_SIZE, AlphaSize);
99 ATTRIB_MAP(EGL_BLUE_SIZE, BlueSize);
100 ATTRIB_MAP(EGL_GREEN_SIZE, GreenSize);
101 ATTRIB_MAP(EGL_RED_SIZE, RedSize);
102 ATTRIB_MAP(EGL_DEPTH_SIZE, DepthSize);
103 ATTRIB_MAP(EGL_STENCIL_SIZE, StencilSize);
104 ATTRIB_MAP(EGL_CONFIG_CAVEAT, ConfigCaveat);
105 ATTRIB_MAP(EGL_CONFIG_ID, ConfigID);
106 ATTRIB_MAP(EGL_LEVEL, Level);
107 ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT, MaxPbufferHeight);
108 ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS, MaxPbufferPixels);
109 ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH, MaxPbufferWidth);
110 ATTRIB_MAP(EGL_NATIVE_RENDERABLE, NativeRenderable);
111 ATTRIB_MAP(EGL_NATIVE_VISUAL_ID, NativeVisualID);
112 ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE, NativeVisualType);
113 ATTRIB_MAP(EGL_SAMPLES, Samples);
114 ATTRIB_MAP(EGL_SAMPLE_BUFFERS, SampleBuffers);
115 ATTRIB_MAP(EGL_SURFACE_TYPE, SurfaceType);
116 ATTRIB_MAP(EGL_TRANSPARENT_TYPE, TransparentType);
117 ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE, TransparentBlueValue);
118 ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE, TransparentGreenValue);
119 ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE, TransparentRedValue);
120 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB, BindToTextureRGB);
121 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA, BindToTextureRGBA);
122 ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL, MinSwapInterval);
123 ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL, MaxSwapInterval);
124 ATTRIB_MAP(EGL_LUMINANCE_SIZE, LuminanceSize);
125 ATTRIB_MAP(EGL_ALPHA_MASK_SIZE, AlphaMaskSize);
126 ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE, ColorBufferType);
127 ATTRIB_MAP(EGL_RENDERABLE_TYPE, RenderableType);
128 ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP, MatchNativePixmap);
129 ATTRIB_MAP(EGL_CONFORMANT, Conformant);
130 /* extensions */
131 ATTRIB_MAP(EGL_Y_INVERTED_NOK, YInvertedNOK);
132 #undef ATTRIB_MAP
133 default:
134 return -1;
135 }
136 }
137
138
139 /**
140 * Update a config for a given key.
141 *
142 * Note that a valid key is not necessarily a valid attribute. There are gaps
143 * in the attribute enums. The separation is to catch application errors.
144 * Drivers should never set a key that is an invalid attribute.
145 */
146 static inline void
147 _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
148 {
149 EGLint offset = _eglOffsetOfConfig(key);
150 assert(offset >= 0);
151 *((EGLint *) ((char *) conf + offset)) = val;
152 }
153
154
155 /**
156 * Return the value for a given key.
157 */
158 static inline EGLint
159 _eglGetConfigKey(const _EGLConfig *conf, EGLint key)
160 {
161 EGLint offset = _eglOffsetOfConfig(key);
162 assert(offset >= 0);
163 return *((EGLint *) ((char *) conf + offset));
164 }
165
166
167 extern void
168 _eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);
169
170
171 extern EGLConfig
172 _eglLinkConfig(_EGLConfig *conf);
173
174
175 extern _EGLConfig *
176 _eglLookupConfig(EGLConfig config, _EGLDisplay *dpy);
177
178
179 /**
180 * Return the handle of a linked config.
181 */
182 static inline EGLConfig
183 _eglGetConfigHandle(_EGLConfig *conf)
184 {
185 return (EGLConfig) conf;
186 }
187
188
189 extern EGLBoolean
190 _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);
191
192
193 extern EGLBoolean
194 _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);
195
196
197 extern EGLBoolean
198 _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
199 const EGLint *attrib_list);
200
201
202 extern EGLint
203 _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
204 const _EGLConfig *criteria, EGLBoolean compare_id);
205
206
207 extern EGLBoolean
208 _eglFilterConfigArray(_EGLArray *array, EGLConfig *configs,
209 EGLint config_size, EGLint *num_configs,
210 EGLBoolean (*match)(const _EGLConfig *, void *),
211 EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
212 void *),
213 void *filter_data);
214
215
216 extern EGLBoolean
217 _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
218
219
220 extern EGLBoolean
221 _eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value);
222
223
224 extern EGLBoolean
225 _eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
226
227
228 #endif /* EGLCONFIG_INCLUDED */