Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2008 VMware, Inc. |
Chia-I Wu | f2001df | 2011-07-02 17:57:30 +0900 | [diff] [blame] | 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 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 31 | #ifndef EGLCONFIG_INCLUDED |
| 32 | #define EGLCONFIG_INCLUDED |
| 33 | |
| 34 | |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 35 | #include <assert.h> |
José Fonseca | 601498a | 2010-11-01 13:30:22 +0000 | [diff] [blame] | 36 | #include <stddef.h> |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 37 | #include "c99_compat.h" |
| 38 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 39 | #include "egltypedefs.h" |
| 40 | |
| 41 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 42 | #ifdef __cplusplus |
| 43 | extern "C" { |
| 44 | #endif |
| 45 | |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 46 | /* update _eglValidationTable and _eglOffsetOfConfig before updating this |
| 47 | * struct */ |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 48 | struct _egl_config |
| 49 | { |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 50 | _EGLDisplay *Display; |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 51 | |
| 52 | /* core */ |
| 53 | EGLint BufferSize; |
| 54 | EGLint AlphaSize; |
| 55 | EGLint BlueSize; |
| 56 | EGLint GreenSize; |
| 57 | EGLint RedSize; |
| 58 | EGLint DepthSize; |
| 59 | EGLint StencilSize; |
| 60 | EGLint ConfigCaveat; |
| 61 | EGLint ConfigID; |
| 62 | EGLint Level; |
| 63 | EGLint MaxPbufferHeight; |
| 64 | EGLint MaxPbufferPixels; |
| 65 | EGLint MaxPbufferWidth; |
| 66 | EGLint NativeRenderable; |
| 67 | EGLint NativeVisualID; |
| 68 | EGLint NativeVisualType; |
| 69 | EGLint Samples; |
| 70 | EGLint SampleBuffers; |
| 71 | EGLint SurfaceType; |
| 72 | EGLint TransparentType; |
| 73 | EGLint TransparentBlueValue; |
| 74 | EGLint TransparentGreenValue; |
| 75 | EGLint TransparentRedValue; |
| 76 | EGLint BindToTextureRGB; |
| 77 | EGLint BindToTextureRGBA; |
| 78 | EGLint MinSwapInterval; |
| 79 | EGLint MaxSwapInterval; |
| 80 | EGLint LuminanceSize; |
| 81 | EGLint AlphaMaskSize; |
| 82 | EGLint ColorBufferType; |
| 83 | EGLint RenderableType; |
| 84 | EGLint MatchNativePixmap; |
| 85 | EGLint Conformant; |
| 86 | |
| 87 | /* extensions */ |
| 88 | EGLint YInvertedNOK; |
Rob Herring | 8975527 | 2016-02-02 14:23:07 -0600 | [diff] [blame] | 89 | EGLint FramebufferTargetAndroid; |
Rob Herring | e21e81a | 2016-02-02 14:23:08 -0600 | [diff] [blame] | 90 | EGLint RecordableAndroid; |
Tapani Pälli | 41f7de4 | 2017-10-31 10:57:42 +0200 | [diff] [blame] | 91 | EGLint ComponentType; |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | |
Chia-I Wu | a37dc17 | 2010-02-05 13:33:55 +0800 | [diff] [blame] | 95 | /** |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 96 | * Map an EGL attribute enum to the offset of the member in _EGLConfig. |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 97 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 98 | static inline EGLint |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 99 | _eglOffsetOfConfig(EGLint attr) |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 100 | { |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 101 | switch (attr) { |
| 102 | #define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb) |
| 103 | /* core */ |
| 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); |
| 137 | /* extensions */ |
| 138 | ATTRIB_MAP(EGL_Y_INVERTED_NOK, YInvertedNOK); |
Rob Herring | 8975527 | 2016-02-02 14:23:07 -0600 | [diff] [blame] | 139 | ATTRIB_MAP(EGL_FRAMEBUFFER_TARGET_ANDROID, FramebufferTargetAndroid); |
Rob Herring | e21e81a | 2016-02-02 14:23:08 -0600 | [diff] [blame] | 140 | ATTRIB_MAP(EGL_RECORDABLE_ANDROID, RecordableAndroid); |
Tapani Pälli | 41f7de4 | 2017-10-31 10:57:42 +0200 | [diff] [blame] | 141 | ATTRIB_MAP(EGL_COLOR_COMPONENT_TYPE_EXT, ComponentType); |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 142 | #undef ATTRIB_MAP |
Kristian Høgsberg | 5dc0f49 | 2010-05-06 22:40:25 -0400 | [diff] [blame] | 143 | default: |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 144 | return -1; |
Kristian Høgsberg | 5dc0f49 | 2010-05-06 22:40:25 -0400 | [diff] [blame] | 145 | } |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | |
| 149 | /** |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 150 | * Update a config for a given key. |
Chia-I Wu | a37dc17 | 2010-02-05 13:33:55 +0800 | [diff] [blame] | 151 | * |
| 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. |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 155 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 156 | static inline void |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 157 | _eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) |
| 158 | { |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 159 | EGLint offset = _eglOffsetOfConfig(key); |
| 160 | assert(offset >= 0); |
| 161 | *((EGLint *) ((char *) conf + offset)) = val; |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | |
| 165 | /** |
| 166 | * Return the value for a given key. |
| 167 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 168 | static inline EGLint |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 169 | _eglGetConfigKey(const _EGLConfig *conf, EGLint key) |
| 170 | { |
Chia-I Wu | 282e514 | 2010-10-14 16:25:30 +0800 | [diff] [blame] | 171 | EGLint offset = _eglOffsetOfConfig(key); |
| 172 | assert(offset >= 0); |
| 173 | return *((EGLint *) ((char *) conf + offset)); |
Chia-I Wu | 358c5a8 | 2009-09-25 22:54:34 +0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 177 | extern void |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 178 | _eglInitConfig(_EGLConfig *config, _EGLDisplay *disp, EGLint id); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 179 | |
| 180 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 181 | extern EGLConfig |
Chia-I Wu | 8a6bdf3 | 2010-10-23 00:47:22 +0800 | [diff] [blame] | 182 | _eglLinkConfig(_EGLConfig *conf); |
Brian Paul | 721ba15 | 2008-05-27 14:33:54 -0600 | [diff] [blame] | 183 | |
| 184 | |
Chia-I Wu | 8a6bdf3 | 2010-10-23 00:47:22 +0800 | [diff] [blame] | 185 | extern _EGLConfig * |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 186 | _eglLookupConfig(EGLConfig config, _EGLDisplay *disp); |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 187 | |
| 188 | |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 189 | /** |
Chia-I Wu | 8a6bdf3 | 2010-10-23 00:47:22 +0800 | [diff] [blame] | 190 | * Return the handle of a linked config. |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 191 | */ |
Emil Velikov | 7bd1693 | 2015-02-28 16:35:22 +0000 | [diff] [blame] | 192 | static inline EGLConfig |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 193 | _eglGetConfigHandle(_EGLConfig *conf) |
| 194 | { |
Chia-I Wu | 8a6bdf3 | 2010-10-23 00:47:22 +0800 | [diff] [blame] | 195 | return (EGLConfig) conf; |
Chia-I Wu | 56822b0 | 2009-09-25 23:43:49 +0800 | [diff] [blame] | 196 | } |
Brian Paul | c22990c | 2005-05-04 03:33:21 +0000 | [diff] [blame] | 197 | |
| 198 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 199 | extern EGLBoolean |
Chia-I Wu | 95cdd69 | 2009-09-25 23:24:03 +0800 | [diff] [blame] | 200 | _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching); |
| 201 | |
| 202 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 203 | extern EGLBoolean |
Chia-I Wu | 95cdd69 | 2009-09-25 23:24:03 +0800 | [diff] [blame] | 204 | _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria); |
| 205 | |
| 206 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 207 | extern EGLBoolean |
Eric Engestrom | 54fa5ec | 2019-02-02 11:38:45 +0000 | [diff] [blame] | 208 | _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *disp, |
Chia-I Wu | 8a6bdf3 | 2010-10-23 00:47:22 +0800 | [diff] [blame] | 209 | const EGLint *attrib_list); |
Chia-I Wu | 95cdd69 | 2009-09-25 23:24:03 +0800 | [diff] [blame] | 210 | |
| 211 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 212 | extern EGLint |
Chia-I Wu | 95cdd69 | 2009-09-25 23:24:03 +0800 | [diff] [blame] | 213 | _eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, |
| 214 | const _EGLConfig *criteria, EGLBoolean compare_id); |
| 215 | |
| 216 | |
Emil Velikov | dd438ae | 2015-02-28 17:20:01 +0000 | [diff] [blame] | 217 | extern EGLBoolean |
Chia-I Wu | 3152054 | 2011-06-25 17:32:15 +0900 | [diff] [blame] | 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 *, |
| 222 | void *), |
| 223 | void *filter_data); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 224 | |
| 225 | |
| 226 | extern EGLBoolean |
Eric Engestrom | 0345a61 | 2018-05-21 19:48:13 +0100 | [diff] [blame] | 227 | _eglChooseConfig(_EGLDisplay *disp, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 228 | |
| 229 | |
| 230 | extern EGLBoolean |
Eric Engestrom | 0345a61 | 2018-05-21 19:48:13 +0100 | [diff] [blame] | 231 | _eglGetConfigAttrib(_EGLDisplay *disp, _EGLConfig *conf, EGLint attribute, EGLint *value); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 232 | |
| 233 | |
| 234 | extern EGLBoolean |
Eric Engestrom | 0345a61 | 2018-05-21 19:48:13 +0100 | [diff] [blame] | 235 | _eglGetConfigs(_EGLDisplay *disp, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 236 | |
| 237 | |
Alexander von Gluck IV | 8362068 | 2015-05-13 17:13:37 -0500 | [diff] [blame] | 238 | #ifdef __cplusplus |
| 239 | } |
| 240 | #endif |
| 241 | |
Brian Paul | adbff7e | 2005-04-22 21:09:39 +0000 | [diff] [blame] | 242 | #endif /* EGLCONFIG_INCLUDED */ |