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 **************************************************************************/
32 * EGL Configuration (pixel format) functions.
39 #include "c99_compat.h"
40 #include "util/macros.h"
42 #include "eglconfig.h"
43 #include "egldisplay.h"
44 #include "eglcurrent.h"
51 * Init the given _EGLconfig to default values.
52 * \param id the configuration's ID.
54 * Note that id must be positive for the config to be valid.
55 * It is also recommended that when there are N configs, their
56 * IDs are from 1 to N respectively.
59 _eglInitConfig(_EGLConfig
*conf
, _EGLDisplay
*disp
, EGLint id
)
61 memset(conf
, 0, sizeof(*conf
));
65 /* some attributes take non-zero default values */
67 conf
->ConfigCaveat
= EGL_NONE
;
68 conf
->TransparentType
= EGL_NONE
;
69 conf
->NativeVisualType
= EGL_NONE
;
70 conf
->ColorBufferType
= EGL_RGB_BUFFER
;
71 conf
->ComponentType
= EGL_COLOR_COMPONENT_TYPE_FIXED_EXT
;
76 * Link a config to its display and return the handle of the link.
77 * The handle can be passed to client directly.
79 * Note that we just save the ptr to the config (we don't copy the config).
82 _eglLinkConfig(_EGLConfig
*conf
)
84 _EGLDisplay
*disp
= conf
->Display
;
88 assert(conf
->ConfigID
> 0);
91 disp
->Configs
= _eglCreateArray("Config", 16);
93 return (EGLConfig
) NULL
;
96 _eglAppendArray(disp
->Configs
, (void *) conf
);
98 return (EGLConfig
) conf
;
103 * Lookup a handle to find the linked config.
104 * Return NULL if the handle has no corresponding linked config.
107 _eglLookupConfig(EGLConfig config
, _EGLDisplay
*disp
)
114 conf
= (_EGLConfig
*) _eglFindArray(disp
->Configs
, (void *) config
);
116 assert(conf
->Display
== disp
);
127 ATTRIB_TYPE_PSEUDO
, /* non-queryable */
128 ATTRIB_TYPE_PLATFORM
, /* platform-dependent */
132 ATTRIB_CRITERION_EXACT
,
133 ATTRIB_CRITERION_ATLEAST
,
134 ATTRIB_CRITERION_MASK
,
135 ATTRIB_CRITERION_SPECIAL
,
136 ATTRIB_CRITERION_IGNORE
140 /* EGL spec Table 3.1 and 3.4 */
141 static const struct {
144 enum criterion criterion
;
145 EGLint default_value
;
146 } _eglValidationTable
[] =
149 { EGL_BUFFER_SIZE
, ATTRIB_TYPE_INTEGER
,
150 ATTRIB_CRITERION_ATLEAST
,
152 { EGL_RED_SIZE
, ATTRIB_TYPE_INTEGER
,
153 ATTRIB_CRITERION_ATLEAST
,
155 { EGL_GREEN_SIZE
, ATTRIB_TYPE_INTEGER
,
156 ATTRIB_CRITERION_ATLEAST
,
158 { EGL_BLUE_SIZE
, ATTRIB_TYPE_INTEGER
,
159 ATTRIB_CRITERION_ATLEAST
,
161 { EGL_LUMINANCE_SIZE
, ATTRIB_TYPE_INTEGER
,
162 ATTRIB_CRITERION_ATLEAST
,
164 { EGL_ALPHA_SIZE
, ATTRIB_TYPE_INTEGER
,
165 ATTRIB_CRITERION_ATLEAST
,
167 { EGL_ALPHA_MASK_SIZE
, ATTRIB_TYPE_INTEGER
,
168 ATTRIB_CRITERION_ATLEAST
,
170 { EGL_BIND_TO_TEXTURE_RGB
, ATTRIB_TYPE_BOOLEAN
,
171 ATTRIB_CRITERION_EXACT
,
173 { EGL_BIND_TO_TEXTURE_RGBA
, ATTRIB_TYPE_BOOLEAN
,
174 ATTRIB_CRITERION_EXACT
,
176 { EGL_COLOR_BUFFER_TYPE
, ATTRIB_TYPE_ENUM
,
177 ATTRIB_CRITERION_EXACT
,
179 { EGL_CONFIG_CAVEAT
, ATTRIB_TYPE_ENUM
,
180 ATTRIB_CRITERION_EXACT
,
182 { EGL_CONFIG_ID
, ATTRIB_TYPE_INTEGER
,
183 ATTRIB_CRITERION_EXACT
,
185 { EGL_CONFORMANT
, ATTRIB_TYPE_BITMASK
,
186 ATTRIB_CRITERION_MASK
,
188 { EGL_DEPTH_SIZE
, ATTRIB_TYPE_INTEGER
,
189 ATTRIB_CRITERION_ATLEAST
,
191 { EGL_LEVEL
, ATTRIB_TYPE_PLATFORM
,
192 ATTRIB_CRITERION_EXACT
,
194 { EGL_MAX_PBUFFER_WIDTH
, ATTRIB_TYPE_INTEGER
,
195 ATTRIB_CRITERION_IGNORE
,
197 { EGL_MAX_PBUFFER_HEIGHT
, ATTRIB_TYPE_INTEGER
,
198 ATTRIB_CRITERION_IGNORE
,
200 { EGL_MAX_PBUFFER_PIXELS
, ATTRIB_TYPE_INTEGER
,
201 ATTRIB_CRITERION_IGNORE
,
203 { EGL_MAX_SWAP_INTERVAL
, ATTRIB_TYPE_INTEGER
,
204 ATTRIB_CRITERION_EXACT
,
206 { EGL_MIN_SWAP_INTERVAL
, ATTRIB_TYPE_INTEGER
,
207 ATTRIB_CRITERION_EXACT
,
209 { EGL_NATIVE_RENDERABLE
, ATTRIB_TYPE_BOOLEAN
,
210 ATTRIB_CRITERION_EXACT
,
212 { EGL_NATIVE_VISUAL_ID
, ATTRIB_TYPE_PLATFORM
,
213 ATTRIB_CRITERION_IGNORE
,
215 { EGL_NATIVE_VISUAL_TYPE
, ATTRIB_TYPE_PLATFORM
,
216 ATTRIB_CRITERION_EXACT
,
218 { EGL_RENDERABLE_TYPE
, ATTRIB_TYPE_BITMASK
,
219 ATTRIB_CRITERION_MASK
,
221 { EGL_SAMPLE_BUFFERS
, ATTRIB_TYPE_INTEGER
,
222 ATTRIB_CRITERION_ATLEAST
,
224 { EGL_SAMPLES
, ATTRIB_TYPE_INTEGER
,
225 ATTRIB_CRITERION_ATLEAST
,
227 { EGL_STENCIL_SIZE
, ATTRIB_TYPE_INTEGER
,
228 ATTRIB_CRITERION_ATLEAST
,
230 { EGL_SURFACE_TYPE
, ATTRIB_TYPE_BITMASK
,
231 ATTRIB_CRITERION_MASK
,
233 { EGL_TRANSPARENT_TYPE
, ATTRIB_TYPE_ENUM
,
234 ATTRIB_CRITERION_EXACT
,
236 { EGL_TRANSPARENT_RED_VALUE
, ATTRIB_TYPE_INTEGER
,
237 ATTRIB_CRITERION_EXACT
,
239 { EGL_TRANSPARENT_GREEN_VALUE
, ATTRIB_TYPE_INTEGER
,
240 ATTRIB_CRITERION_EXACT
,
242 { EGL_TRANSPARENT_BLUE_VALUE
, ATTRIB_TYPE_INTEGER
,
243 ATTRIB_CRITERION_EXACT
,
245 { EGL_MATCH_NATIVE_PIXMAP
, ATTRIB_TYPE_PSEUDO
,
246 ATTRIB_CRITERION_SPECIAL
,
249 { EGL_Y_INVERTED_NOK
, ATTRIB_TYPE_BOOLEAN
,
250 ATTRIB_CRITERION_EXACT
,
252 { EGL_FRAMEBUFFER_TARGET_ANDROID
, ATTRIB_TYPE_BOOLEAN
,
253 ATTRIB_CRITERION_EXACT
,
255 { EGL_RECORDABLE_ANDROID
, ATTRIB_TYPE_BOOLEAN
,
256 ATTRIB_CRITERION_EXACT
,
258 { EGL_COLOR_COMPONENT_TYPE_EXT
, ATTRIB_TYPE_ENUM
,
259 ATTRIB_CRITERION_EXACT
,
260 EGL_COLOR_COMPONENT_TYPE_FIXED_EXT
},
261 { EGL_CONFIG_SELECT_GROUP_MESA
, ATTRIB_TYPE_INTEGER
,
262 ATTRIB_CRITERION_IGNORE
,
268 * Return true if a config is valid. When for_matching is true,
269 * EGL_DONT_CARE is accepted as a valid attribute value, and checks
270 * for conflicting attribute values are skipped.
272 * Note that some attributes are platform-dependent and are not
276 _eglValidateConfig(const _EGLConfig
*conf
, EGLBoolean for_matching
)
278 _EGLDisplay
*disp
= conf
->Display
;
280 EGLBoolean valid
= EGL_TRUE
;
282 /* check attributes by their types */
283 for (i
= 0; i
< ARRAY_SIZE(_eglValidationTable
); i
++) {
286 attr
= _eglValidationTable
[i
].attr
;
287 val
= _eglGetConfigKey(conf
, attr
);
289 switch (_eglValidationTable
[i
].type
) {
290 case ATTRIB_TYPE_INTEGER
:
293 /* config id must be positive */
297 case EGL_SAMPLE_BUFFERS
:
298 /* there can be at most 1 sample buffer */
299 if (val
> 1 || val
< 0)
302 case EGL_CONFIG_SELECT_GROUP_MESA
:
310 case ATTRIB_TYPE_BOOLEAN
:
311 if (val
!= EGL_TRUE
&& val
!= EGL_FALSE
)
314 case ATTRIB_TYPE_ENUM
:
316 case EGL_CONFIG_CAVEAT
:
317 if (val
!= EGL_NONE
&& val
!= EGL_SLOW_CONFIG
&&
318 val
!= EGL_NON_CONFORMANT_CONFIG
)
321 case EGL_TRANSPARENT_TYPE
:
322 if (val
!= EGL_NONE
&& val
!= EGL_TRANSPARENT_RGB
)
325 case EGL_COLOR_BUFFER_TYPE
:
326 if (val
!= EGL_RGB_BUFFER
&& val
!= EGL_LUMINANCE_BUFFER
)
329 case EGL_COLOR_COMPONENT_TYPE_EXT
:
330 if (val
!= EGL_COLOR_COMPONENT_TYPE_FIXED_EXT
&&
331 val
!= EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT
)
335 unreachable("check _eglValidationTable[]");
339 case ATTRIB_TYPE_BITMASK
:
341 case EGL_SURFACE_TYPE
:
342 mask
= EGL_PBUFFER_BIT
|
345 EGL_VG_COLORSPACE_LINEAR_BIT
|
346 EGL_VG_ALPHA_FORMAT_PRE_BIT
|
347 EGL_MULTISAMPLE_RESOLVE_BOX_BIT
|
348 EGL_SWAP_BEHAVIOR_PRESERVED_BIT
;
349 if (disp
->Extensions
.KHR_mutable_render_buffer
)
350 mask
|= EGL_MUTABLE_RENDER_BUFFER_BIT_KHR
;
352 case EGL_RENDERABLE_TYPE
:
354 mask
= EGL_OPENGL_ES_BIT
|
357 EGL_OPENGL_ES3_BIT_KHR
|
361 unreachable("check _eglValidationTable[]");
368 case ATTRIB_TYPE_PLATFORM
:
369 /* unable to check platform-dependent attributes here */
371 case ATTRIB_TYPE_PSEUDO
:
372 /* pseudo attributes should not be set */
378 if (!valid
&& for_matching
) {
379 /* accept EGL_DONT_CARE as a valid value */
380 if (val
== EGL_DONT_CARE
)
382 if (_eglValidationTable
[i
].criterion
== ATTRIB_CRITERION_SPECIAL
)
387 "attribute 0x%04x has an invalid value 0x%x", attr
, val
);
392 /* any invalid attribute value should have been catched */
393 if (!valid
|| for_matching
)
396 /* now check for conflicting attribute values */
398 switch (conf
->ColorBufferType
) {
400 if (conf
->LuminanceSize
)
402 if (conf
->RedSize
+ conf
->GreenSize
+
403 conf
->BlueSize
+ conf
->AlphaSize
!= conf
->BufferSize
)
406 case EGL_LUMINANCE_BUFFER
:
407 if (conf
->RedSize
|| conf
->GreenSize
|| conf
->BlueSize
)
409 if (conf
->LuminanceSize
+ conf
->AlphaSize
!= conf
->BufferSize
)
414 _eglLog(_EGL_DEBUG
, "conflicting color buffer type and channel sizes");
418 if (!conf
->SampleBuffers
&& conf
->Samples
)
421 _eglLog(_EGL_DEBUG
, "conflicting samples and sample buffers");
425 if (!(conf
->SurfaceType
& EGL_WINDOW_BIT
)) {
426 if (conf
->NativeVisualID
!= 0 || conf
->NativeVisualType
!= EGL_NONE
)
429 if (!(conf
->SurfaceType
& EGL_PBUFFER_BIT
)) {
430 if (conf
->BindToTextureRGB
|| conf
->BindToTextureRGBA
)
434 _eglLog(_EGL_DEBUG
, "conflicting surface type and native visual/texture binding");
443 * Return true if a config matches the criteria. This and
444 * _eglParseConfigAttribList together implement the algorithm
445 * described in "Selection of EGLConfigs".
447 * Note that attributes that are special (currently, only
448 * EGL_MATCH_NATIVE_PIXMAP) are ignored.
451 _eglMatchConfig(const _EGLConfig
*conf
, const _EGLConfig
*criteria
)
454 EGLBoolean matched
= EGL_TRUE
;
456 for (i
= 0; i
< ARRAY_SIZE(_eglValidationTable
); i
++) {
458 if (_eglValidationTable
[i
].criterion
== ATTRIB_CRITERION_IGNORE
)
461 attr
= _eglValidationTable
[i
].attr
;
462 cmp
= _eglGetConfigKey(criteria
, attr
);
463 if (cmp
== EGL_DONT_CARE
)
466 val
= _eglGetConfigKey(conf
, attr
);
467 switch (_eglValidationTable
[i
].criterion
) {
468 case ATTRIB_CRITERION_EXACT
:
472 case ATTRIB_CRITERION_ATLEAST
:
476 case ATTRIB_CRITERION_MASK
:
477 if ((val
& cmp
) != cmp
)
480 case ATTRIB_CRITERION_SPECIAL
:
483 case ATTRIB_CRITERION_IGNORE
:
484 unreachable("already handled above");
490 /* only print the common errors when DEBUG is not defined */
491 if (attr
!= EGL_RENDERABLE_TYPE
)
495 "the value (0x%x) of attribute 0x%04x did not meet the criteria (0x%x)",
504 static inline EGLBoolean
505 _eglIsConfigAttribValid(_EGLConfig
*conf
, EGLint attr
)
507 if (_eglOffsetOfConfig(attr
) < 0)
511 case EGL_Y_INVERTED_NOK
:
512 return conf
->Display
->Extensions
.NOK_texture_from_pixmap
;
513 case EGL_FRAMEBUFFER_TARGET_ANDROID
:
514 return conf
->Display
->Extensions
.ANDROID_framebuffer_target
;
515 case EGL_RECORDABLE_ANDROID
:
516 return conf
->Display
->Extensions
.ANDROID_recordable
;
525 * Initialize a criteria config from the given attribute list.
526 * Return EGL_FALSE if any of the attribute is invalid.
529 _eglParseConfigAttribList(_EGLConfig
*conf
, _EGLDisplay
*disp
,
530 const EGLint
*attrib_list
)
534 _eglInitConfig(conf
, disp
, EGL_DONT_CARE
);
536 /* reset to default values */
537 for (i
= 0; i
< ARRAY_SIZE(_eglValidationTable
); i
++) {
538 attr
= _eglValidationTable
[i
].attr
;
539 val
= _eglValidationTable
[i
].default_value
;
540 _eglSetConfigKey(conf
, attr
, val
);
544 for (i
= 0; attrib_list
&& attrib_list
[i
] != EGL_NONE
; i
+= 2) {
545 attr
= attrib_list
[i
];
546 val
= attrib_list
[i
+ 1];
548 if (!_eglIsConfigAttribValid(conf
, attr
))
551 _eglSetConfigKey(conf
, attr
, val
);
554 if (!_eglValidateConfig(conf
, EGL_TRUE
))
557 /* EGL_LEVEL and EGL_MATCH_NATIVE_PIXMAP cannot be EGL_DONT_CARE */
558 if (conf
->Level
== EGL_DONT_CARE
||
559 conf
->MatchNativePixmap
== EGL_DONT_CARE
)
562 /* ignore other attributes when EGL_CONFIG_ID is given */
563 if (conf
->ConfigID
!= EGL_DONT_CARE
) {
564 for (i
= 0; i
< ARRAY_SIZE(_eglValidationTable
); i
++) {
565 attr
= _eglValidationTable
[i
].attr
;
566 if (attr
!= EGL_CONFIG_ID
)
567 _eglSetConfigKey(conf
, attr
, EGL_DONT_CARE
);
571 if (!(conf
->SurfaceType
& EGL_WINDOW_BIT
))
572 conf
->NativeVisualType
= EGL_DONT_CARE
;
574 if (conf
->TransparentType
== EGL_NONE
) {
575 conf
->TransparentRedValue
= EGL_DONT_CARE
;
576 conf
->TransparentGreenValue
= EGL_DONT_CARE
;
577 conf
->TransparentBlueValue
= EGL_DONT_CARE
;
586 * Decide the ordering of conf1 and conf2, under the given criteria.
587 * When compare_id is true, this implements the algorithm described
588 * in "Sorting of EGLConfigs". When compare_id is false,
589 * EGL_CONFIG_ID is not compared.
591 * It returns a negative integer if conf1 is considered to come
592 * before conf2; a positive integer if conf2 is considered to come
593 * before conf1; zero if the ordering cannot be decided.
595 * Note that EGL_NATIVE_VISUAL_TYPE is platform-dependent and is
599 _eglCompareConfigs(const _EGLConfig
*conf1
, const _EGLConfig
*conf2
,
600 const _EGLConfig
*criteria
, EGLBoolean compare_id
)
602 const EGLint compare_attribs
[] = {
616 val1
= conf1
->ConfigSelectGroup
- conf2
->ConfigSelectGroup
;
620 /* the enum values have the desired ordering */
621 STATIC_ASSERT(EGL_NONE
< EGL_SLOW_CONFIG
);
622 STATIC_ASSERT(EGL_SLOW_CONFIG
< EGL_NON_CONFORMANT_CONFIG
);
623 val1
= conf1
->ConfigCaveat
- conf2
->ConfigCaveat
;
627 /* the enum values have the desired ordering */
628 STATIC_ASSERT(EGL_RGB_BUFFER
< EGL_LUMINANCE_BUFFER
);
629 val1
= conf1
->ColorBufferType
- conf2
->ColorBufferType
;
635 if (conf1
->ColorBufferType
== EGL_RGB_BUFFER
) {
636 if (criteria
->RedSize
> 0) {
637 val1
+= conf1
->RedSize
;
638 val2
+= conf2
->RedSize
;
640 if (criteria
->GreenSize
> 0) {
641 val1
+= conf1
->GreenSize
;
642 val2
+= conf2
->GreenSize
;
644 if (criteria
->BlueSize
> 0) {
645 val1
+= conf1
->BlueSize
;
646 val2
+= conf2
->BlueSize
;
650 if (criteria
->LuminanceSize
> 0) {
651 val1
+= conf1
->LuminanceSize
;
652 val2
+= conf2
->LuminanceSize
;
655 if (criteria
->AlphaSize
> 0) {
656 val1
+= conf1
->AlphaSize
;
657 val2
+= conf2
->AlphaSize
;
661 /* assume the default criteria, which gives no specific ordering */
665 /* for color bits, larger one is preferred */
667 return (val2
- val1
);
669 for (i
= 0; i
< ARRAY_SIZE(compare_attribs
); i
++) {
670 val1
= _eglGetConfigKey(conf1
, compare_attribs
[i
]);
671 val2
= _eglGetConfigKey(conf2
, compare_attribs
[i
]);
673 return (val1
- val2
);
676 /* EGL_NATIVE_VISUAL_TYPE cannot be compared here */
678 return (compare_id
) ? (conf1
->ConfigID
- conf2
->ConfigID
) : 0;
683 void _eglSwapConfigs(const _EGLConfig
**conf1
, const _EGLConfig
**conf2
)
685 const _EGLConfig
*tmp
= *conf1
;
692 * Quick sort an array of configs. This differs from the standard
693 * qsort() in that the compare function accepts an additional
697 _eglSortConfigs(const _EGLConfig
**configs
, EGLint count
,
698 EGLint (*compare
)(const _EGLConfig
*, const _EGLConfig
*,
702 const EGLint pivot
= 0;
708 _eglSwapConfigs(&configs
[pivot
], &configs
[count
/ 2]);
712 while (i
< count
&& compare(configs
[i
], configs
[pivot
], priv_data
) < 0)
714 while (compare(configs
[j
], configs
[pivot
], priv_data
) > 0)
717 _eglSwapConfigs(&configs
[i
], &configs
[j
]);
727 _eglSwapConfigs(&configs
[pivot
], &configs
[j
]);
729 _eglSortConfigs(configs
, j
, compare
, priv_data
);
730 _eglSortConfigs(configs
+ i
, count
- i
, compare
, priv_data
);
735 * A helper function for implementing eglChooseConfig. See _eglFilterArray and
736 * _eglSortConfigs for the meanings of match and compare.
739 _eglFilterConfigArray(_EGLArray
*array
, EGLConfig
*configs
,
740 EGLint config_size
, EGLint
*num_configs
,
741 EGLBoolean (*match
)(const _EGLConfig
*, void *),
742 EGLint (*compare
)(const _EGLConfig
*, const _EGLConfig
*,
746 _EGLConfig
**configList
;
749 /* get the number of matched configs */
750 count
= _eglFilterArray(array
, NULL
, 0,
751 (_EGLArrayForEach
) match
, priv_data
);
753 *num_configs
= count
;
757 configList
= malloc(sizeof(*configList
) * count
);
759 return _eglError(EGL_BAD_ALLOC
, "eglChooseConfig(out of memory)");
761 /* get the matched configs */
762 _eglFilterArray(array
, (void **) configList
, count
,
763 (_EGLArrayForEach
) match
, priv_data
);
765 /* perform sorting of configs */
766 if (configs
&& count
) {
767 _eglSortConfigs((const _EGLConfig
**) configList
, count
,
769 count
= MIN2(count
, config_size
);
770 for (i
= 0; i
< count
; i
++)
771 configs
[i
] = _eglGetConfigHandle(configList
[i
]);
776 *num_configs
= count
;
783 _eglFallbackMatch(const _EGLConfig
*conf
, void *priv_data
)
785 return _eglMatchConfig(conf
, (const _EGLConfig
*) priv_data
);
790 _eglFallbackCompare(const _EGLConfig
*conf1
, const _EGLConfig
*conf2
,
793 return _eglCompareConfigs(conf1
, conf2
,
794 (const _EGLConfig
*) priv_data
, EGL_TRUE
);
799 * Typical fallback routine for eglChooseConfig
802 _eglChooseConfig(_EGLDriver
*drv
, _EGLDisplay
*disp
, const EGLint
*attrib_list
,
803 EGLConfig
*configs
, EGLint config_size
, EGLint
*num_configs
)
807 if (!_eglParseConfigAttribList(&criteria
, disp
, attrib_list
))
808 return _eglError(EGL_BAD_ATTRIBUTE
, "eglChooseConfig");
810 return _eglFilterConfigArray(disp
->Configs
,
811 configs
, config_size
, num_configs
,
812 _eglFallbackMatch
, _eglFallbackCompare
,
818 * Fallback for eglGetConfigAttrib.
821 _eglGetConfigAttrib(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLConfig
*conf
,
822 EGLint attribute
, EGLint
*value
)
824 if (!_eglIsConfigAttribValid(conf
, attribute
))
825 return _eglError(EGL_BAD_ATTRIBUTE
, "eglGetConfigAttrib");
827 /* nonqueryable attributes */
829 case EGL_MATCH_NATIVE_PIXMAP
:
830 return _eglError(EGL_BAD_ATTRIBUTE
, "eglGetConfigAttrib");
837 return _eglError(EGL_BAD_PARAMETER
, "eglGetConfigAttrib");
839 *value
= _eglGetConfigKey(conf
, attribute
);
845 _eglFlattenConfig(void *elem
, void *buffer
)
847 _EGLConfig
*conf
= (_EGLConfig
*) elem
;
848 EGLConfig
*handle
= (EGLConfig
*) buffer
;
849 *handle
= _eglGetConfigHandle(conf
);
854 * Fallback for eglGetConfigs.
857 _eglGetConfigs(_EGLDriver
*drv
, _EGLDisplay
*disp
, EGLConfig
*configs
,
858 EGLint config_size
, EGLint
*num_config
)
860 *num_config
= _eglFlattenArray(disp
->Configs
, (void *) configs
,
861 sizeof(configs
[0]), config_size
, _eglFlattenConfig
);