1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
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:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
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.
28 **************************************************************************/
31 #ifndef EGLCONFIG_INCLUDED
32 #define EGLCONFIG_INCLUDED
37 #include "c99_compat.h"
39 #include "egltypedefs.h"
46 /* update _eglValidationTable and _eglOffsetOfConfig before updating this
63 EGLint MaxPbufferHeight
;
64 EGLint MaxPbufferPixels
;
65 EGLint MaxPbufferWidth
;
66 EGLint NativeRenderable
;
67 EGLint NativeVisualID
;
68 EGLint NativeVisualType
;
72 EGLint TransparentType
;
73 EGLint TransparentBlueValue
;
74 EGLint TransparentGreenValue
;
75 EGLint TransparentRedValue
;
76 EGLint BindToTextureRGB
;
77 EGLint BindToTextureRGBA
;
78 EGLint MinSwapInterval
;
79 EGLint MaxSwapInterval
;
82 EGLint ColorBufferType
;
83 EGLint RenderableType
;
84 EGLint MatchNativePixmap
;
89 EGLint FramebufferTargetAndroid
;
90 EGLint RecordableAndroid
;
96 * Map an EGL attribute enum to the offset of the member in _EGLConfig.
99 _eglOffsetOfConfig(EGLint attr
)
102 #define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
104 ATTRIB_MAP(EGL_BUFFER_SIZE
, BufferSize
);
105 ATTRIB_MAP(EGL_ALPHA_SIZE
, AlphaSize
);
106 ATTRIB_MAP(EGL_BLUE_SIZE
, BlueSize
);
107 ATTRIB_MAP(EGL_GREEN_SIZE
, GreenSize
);
108 ATTRIB_MAP(EGL_RED_SIZE
, RedSize
);
109 ATTRIB_MAP(EGL_DEPTH_SIZE
, DepthSize
);
110 ATTRIB_MAP(EGL_STENCIL_SIZE
, StencilSize
);
111 ATTRIB_MAP(EGL_CONFIG_CAVEAT
, ConfigCaveat
);
112 ATTRIB_MAP(EGL_CONFIG_ID
, ConfigID
);
113 ATTRIB_MAP(EGL_LEVEL
, Level
);
114 ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT
, MaxPbufferHeight
);
115 ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS
, MaxPbufferPixels
);
116 ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH
, MaxPbufferWidth
);
117 ATTRIB_MAP(EGL_NATIVE_RENDERABLE
, NativeRenderable
);
118 ATTRIB_MAP(EGL_NATIVE_VISUAL_ID
, NativeVisualID
);
119 ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE
, NativeVisualType
);
120 ATTRIB_MAP(EGL_SAMPLES
, Samples
);
121 ATTRIB_MAP(EGL_SAMPLE_BUFFERS
, SampleBuffers
);
122 ATTRIB_MAP(EGL_SURFACE_TYPE
, SurfaceType
);
123 ATTRIB_MAP(EGL_TRANSPARENT_TYPE
, TransparentType
);
124 ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE
, TransparentBlueValue
);
125 ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE
, TransparentGreenValue
);
126 ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE
, TransparentRedValue
);
127 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB
, BindToTextureRGB
);
128 ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA
, BindToTextureRGBA
);
129 ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL
, MinSwapInterval
);
130 ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL
, MaxSwapInterval
);
131 ATTRIB_MAP(EGL_LUMINANCE_SIZE
, LuminanceSize
);
132 ATTRIB_MAP(EGL_ALPHA_MASK_SIZE
, AlphaMaskSize
);
133 ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE
, ColorBufferType
);
134 ATTRIB_MAP(EGL_RENDERABLE_TYPE
, RenderableType
);
135 ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP
, MatchNativePixmap
);
136 ATTRIB_MAP(EGL_CONFORMANT
, Conformant
);
138 ATTRIB_MAP(EGL_Y_INVERTED_NOK
, YInvertedNOK
);
139 ATTRIB_MAP(EGL_FRAMEBUFFER_TARGET_ANDROID
, FramebufferTargetAndroid
);
140 ATTRIB_MAP(EGL_RECORDABLE_ANDROID
, RecordableAndroid
);
141 ATTRIB_MAP(EGL_COLOR_COMPONENT_TYPE_EXT
, ComponentType
);
150 * Update a config for a given key.
152 * Note that a valid key is not necessarily a valid attribute. There are gaps
153 * in the attribute enums. The separation is to catch application errors.
154 * Drivers should never set a key that is an invalid attribute.
157 _eglSetConfigKey(_EGLConfig
*conf
, EGLint key
, EGLint val
)
159 EGLint offset
= _eglOffsetOfConfig(key
);
161 *((EGLint
*) ((char *) conf
+ offset
)) = val
;
166 * Return the value for a given key.
169 _eglGetConfigKey(const _EGLConfig
*conf
, EGLint key
)
171 EGLint offset
= _eglOffsetOfConfig(key
);
173 return *((EGLint
*) ((char *) conf
+ offset
));
178 _eglInitConfig(_EGLConfig
*config
, _EGLDisplay
*disp
, EGLint id
);
182 _eglLinkConfig(_EGLConfig
*conf
);
186 _eglLookupConfig(EGLConfig config
, _EGLDisplay
*disp
);
190 * Return the handle of a linked config.
192 static inline EGLConfig
193 _eglGetConfigHandle(_EGLConfig
*conf
)
195 return (EGLConfig
) conf
;
200 _eglValidateConfig(const _EGLConfig
*conf
, EGLBoolean for_matching
);
204 _eglMatchConfig(const _EGLConfig
*conf
, const _EGLConfig
*criteria
);
208 _eglParseConfigAttribList(_EGLConfig
*conf
, _EGLDisplay
*disp
,
209 const EGLint
*attrib_list
);
213 _eglCompareConfigs(const _EGLConfig
*conf1
, const _EGLConfig
*conf2
,
214 const _EGLConfig
*criteria
, EGLBoolean compare_id
);
218 _eglFilterConfigArray(_EGLArray
*array
, EGLConfig
*configs
,
219 EGLint config_size
, EGLint
*num_configs
,
220 EGLBoolean (*match
)(const _EGLConfig
*, void *),
221 EGLint (*compare
)(const _EGLConfig
*, const _EGLConfig
*,
227 _eglChooseConfig(_EGLDriver
*drv
, _EGLDisplay
*disp
, const EGLint
*attrib_list
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
231 _eglGetConfigAttrib(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLConfig
*conf
, EGLint attribute
, EGLint
*value
);
235 _eglGetConfigs(_EGLDriver
*drv
, _EGLDisplay
*disp
, EGLConfig
*configs
, EGLint config_size
, EGLint
*num_config
);
242 #endif /* EGLCONFIG_INCLUDED */