summaryrefslogtreecommitdiff
path: root/src/egl/main/eglconfig.h
blob: 892815fa6310b9caf055fb3d628266ba687cd32e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#ifndef EGLCONFIG_INCLUDED
#define EGLCONFIG_INCLUDED


#include <assert.h>
#include "egltypedefs.h"


/* update _eglValidationTable and _eglOffsetOfConfig before updating this
 * struct */
struct _egl_config
{
   _EGLDisplay *Display;

   /* core */
   EGLint BufferSize;
   EGLint AlphaSize;
   EGLint BlueSize;
   EGLint GreenSize;
   EGLint RedSize;
   EGLint DepthSize;
   EGLint StencilSize;
   EGLint ConfigCaveat;
   EGLint ConfigID;
   EGLint Level;
   EGLint MaxPbufferHeight;
   EGLint MaxPbufferPixels;
   EGLint MaxPbufferWidth;
   EGLint NativeRenderable;
   EGLint NativeVisualID;
   EGLint NativeVisualType;
   EGLint Samples;
   EGLint SampleBuffers;
   EGLint SurfaceType;
   EGLint TransparentType;
   EGLint TransparentBlueValue;
   EGLint TransparentGreenValue;
   EGLint TransparentRedValue;
   EGLint BindToTextureRGB;
   EGLint BindToTextureRGBA;
   EGLint MinSwapInterval;
   EGLint MaxSwapInterval;
   EGLint LuminanceSize;
   EGLint AlphaMaskSize;
   EGLint ColorBufferType;
   EGLint RenderableType;
   EGLint MatchNativePixmap;
   EGLint Conformant;

   /* extensions */
   EGLint YInvertedNOK;
};


/**
 * Map an EGL attribute enum to the offset of the member in _EGLConfig.
 */
static INLINE EGLint
_eglOffsetOfConfig(EGLint attr)
{
   switch (attr) {
#define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb)
   /* core */
   ATTRIB_MAP(EGL_BUFFER_SIZE,               BufferSize);
   ATTRIB_MAP(EGL_ALPHA_SIZE,                AlphaSize);
   ATTRIB_MAP(EGL_BLUE_SIZE,                 BlueSize);
   ATTRIB_MAP(EGL_GREEN_SIZE,                GreenSize);
   ATTRIB_MAP(EGL_RED_SIZE,                  RedSize);
   ATTRIB_MAP(EGL_DEPTH_SIZE,                DepthSize);
   ATTRIB_MAP(EGL_STENCIL_SIZE,              StencilSize);
   ATTRIB_MAP(EGL_CONFIG_CAVEAT,             ConfigCaveat);
   ATTRIB_MAP(EGL_CONFIG_ID,                 ConfigID);
   ATTRIB_MAP(EGL_LEVEL,                     Level);
   ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT,        MaxPbufferHeight);
   ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS,        MaxPbufferPixels);
   ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH,         MaxPbufferWidth);
   ATTRIB_MAP(EGL_NATIVE_RENDERABLE,         NativeRenderable);
   ATTRIB_MAP(EGL_NATIVE_VISUAL_ID,          NativeVisualID);
   ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE,        NativeVisualType);
   ATTRIB_MAP(EGL_SAMPLES,                   Samples);
   ATTRIB_MAP(EGL_SAMPLE_BUFFERS,            SampleBuffers);
   ATTRIB_MAP(EGL_SURFACE_TYPE,              SurfaceType);
   ATTRIB_MAP(EGL_TRANSPARENT_TYPE,          TransparentType);
   ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE,    TransparentBlueValue);
   ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE,   TransparentGreenValue);
   ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE,     TransparentRedValue);
   ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB,       BindToTextureRGB);
   ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA,      BindToTextureRGBA);
   ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL,         MinSwapInterval);
   ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL,         MaxSwapInterval);
   ATTRIB_MAP(EGL_LUMINANCE_SIZE,            LuminanceSize);
   ATTRIB_MAP(EGL_ALPHA_MASK_SIZE,           AlphaMaskSize);
   ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE,         ColorBufferType);
   ATTRIB_MAP(EGL_RENDERABLE_TYPE,           RenderableType);
   ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP,       MatchNativePixmap);
   ATTRIB_MAP(EGL_CONFORMANT,                Conformant);
   /* extensions */
   ATTRIB_MAP(EGL_Y_INVERTED_NOK,            YInvertedNOK);
#undef ATTRIB_MAP
   default:
      return -1;
   }
}


/**
 * Update a config for a given key.
 *
 * Note that a valid key is not necessarily a valid attribute.  There are gaps
 * in the attribute enums.  The separation is to catch application errors.
 * Drivers should never set a key that is an invalid attribute.
 */
static INLINE void
_eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val)
{
   EGLint offset = _eglOffsetOfConfig(key);
   assert(offset >= 0);
   *((EGLint *) ((char *) conf + offset)) = val;
}


/**
 * Return the value for a given key.
 */
static INLINE EGLint
_eglGetConfigKey(const _EGLConfig *conf, EGLint key)
{
   EGLint offset = _eglOffsetOfConfig(key);
   assert(offset >= 0);
   return *((EGLint *) ((char *) conf + offset));
}


PUBLIC void
_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id);


PUBLIC EGLConfig
_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf);


extern EGLBoolean
_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy);


/**
 * Lookup a handle to find the linked config.
 * Return NULL if the handle has no corresponding linked config.
 */
static INLINE _EGLConfig *
_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy)
{
   _EGLConfig *conf = (_EGLConfig *) config;
   if (!dpy || !_eglCheckConfigHandle(config, dpy))
      conf = NULL;
   return conf;
}


/**
 * Return the handle of a linked config, or NULL.
 */
static INLINE EGLConfig
_eglGetConfigHandle(_EGLConfig *conf)
{
   return (EGLConfig) ((conf && conf->Display) ? conf : NULL);
}


PUBLIC EGLBoolean
_eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching);


PUBLIC EGLBoolean
_eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria);


PUBLIC EGLBoolean
_eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list);


PUBLIC EGLint
_eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2,
                   const _EGLConfig *criteria, EGLBoolean compare_id);


PUBLIC void
_eglSortConfigs(const _EGLConfig **configs, EGLint count,
                EGLint (*compare)(const _EGLConfig *, const _EGLConfig *,
                                  void *),
                void *priv_data);


extern EGLBoolean
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);


extern EGLBoolean
_eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value);


extern EGLBoolean
_eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);


#endif /* EGLCONFIG_INCLUDED */