daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Config.cpp: Implements the egl::Config class, describing the format, type |
| 8 | // and size for an egl::Surface. Implements EGLConfig and related functionality. |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 9 | // [EGL 1.5] section 3.4 page 19. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 10 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 11 | #include "libANGLE/Config.h" |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 12 | #include "libANGLE/AttributeMap.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 13 | |
| 14 | #include <algorithm> |
| 15 | #include <vector> |
| 16 | |
Jamie Madill | f51639a | 2014-06-25 16:04:57 -0400 | [diff] [blame] | 17 | #include "angle_gl.h" |
shannon.woods%transgaming.com@gtempaccount.com | dcf33d5 | 2013-04-13 03:33:11 +0000 | [diff] [blame] | 18 | #include <EGL/eglext.h> |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 19 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 20 | #include "common/debug.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 22 | namespace egl |
| 23 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 24 | |
| 25 | Config::Config() |
| 26 | { |
| 27 | } |
| 28 | |
daniel@transgaming.com | 76d3e6e | 2012-10-31 19:55:33 +0000 | [diff] [blame] | 29 | Config::Config(rx::ConfigDesc desc, EGLint minInterval, EGLint maxInterval, EGLint texWidth, EGLint texHeight) |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 30 | : renderTargetFormat(desc.renderTargetFormat), depthStencilFormat(desc.depthStencilFormat), multiSample(desc.multiSample) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 31 | { |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 32 | bindToTextureRGB = EGL_FALSE; |
| 33 | bindToTextureRGBA = EGL_FALSE; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 34 | switch (desc.renderTargetFormat) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 35 | { |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 36 | case GL_RGB5_A1: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 37 | bufferSize = 16; |
| 38 | redSize = 5; |
| 39 | greenSize = 5; |
| 40 | blueSize = 5; |
| 41 | alphaSize = 1; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | break; |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 43 | case GL_BGR5_A1_ANGLEX: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 44 | bufferSize = 16; |
| 45 | redSize = 5; |
| 46 | greenSize = 5; |
| 47 | blueSize = 5; |
| 48 | alphaSize = 1; |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 49 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 50 | case GL_RGBA8_OES: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 51 | bufferSize = 32; |
| 52 | redSize = 8; |
| 53 | greenSize = 8; |
| 54 | blueSize = 8; |
| 55 | alphaSize = 8; |
| 56 | bindToTextureRGBA = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 57 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 58 | case GL_RGB565: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 59 | bufferSize = 16; |
| 60 | redSize = 5; |
| 61 | greenSize = 6; |
| 62 | blueSize = 5; |
| 63 | alphaSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 64 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 65 | case GL_RGB8_OES: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 66 | bufferSize = 32; |
| 67 | redSize = 8; |
| 68 | greenSize = 8; |
| 69 | blueSize = 8; |
| 70 | alphaSize = 0; |
| 71 | bindToTextureRGB = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 72 | break; |
shannon.woods@transgaming.com | c60c521 | 2013-01-25 21:54:01 +0000 | [diff] [blame] | 73 | case GL_BGRA8_EXT: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 74 | bufferSize = 32; |
| 75 | redSize = 8; |
| 76 | greenSize = 8; |
| 77 | blueSize = 8; |
| 78 | alphaSize = 8; |
| 79 | bindToTextureRGBA = true; |
shannon.woods@transgaming.com | c60c521 | 2013-01-25 21:54:01 +0000 | [diff] [blame] | 80 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 81 | default: |
| 82 | UNREACHABLE(); // Other formats should not be valid |
| 83 | } |
| 84 | |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 85 | luminanceSize = 0; |
| 86 | alphaMaskSize = 0; |
| 87 | colorBufferType = EGL_RGB_BUFFER; |
| 88 | configCaveat = (desc.fastConfig) ? EGL_NONE : EGL_SLOW_CONFIG; |
| 89 | configID = 0; |
| 90 | conformant = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 91 | |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 92 | switch (desc.depthStencilFormat) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 93 | { |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 94 | case GL_NONE: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 95 | depthSize = 0; |
| 96 | stencilSize = 0; |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 97 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 98 | case GL_DEPTH_COMPONENT32_OES: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 99 | depthSize = 32; |
| 100 | stencilSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 101 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 102 | case GL_DEPTH24_STENCIL8_OES: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 103 | depthSize = 24; |
| 104 | stencilSize = 8; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 105 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 106 | case GL_DEPTH_COMPONENT24_OES: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 107 | depthSize = 24; |
| 108 | stencilSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 109 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 110 | case GL_DEPTH_COMPONENT16: |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 111 | depthSize = 16; |
| 112 | stencilSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 113 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | default: |
| 115 | UNREACHABLE(); |
| 116 | } |
| 117 | |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 118 | level = 0; |
| 119 | matchNativePixmap = EGL_NONE; |
| 120 | maxPBufferWidth = texWidth; |
| 121 | maxPBufferHeight = texHeight; |
| 122 | maxPBufferPixels = texWidth*texHeight; |
| 123 | maxSwapInterval = maxInterval; |
| 124 | minSwapInterval = minInterval; |
| 125 | nativeRenderable = EGL_FALSE; |
| 126 | nativeVisualID = 0; |
| 127 | nativeVisualType = 0; |
| 128 | renderableType = EGL_OPENGL_ES2_BIT; |
| 129 | sampleBuffers = desc.multiSample ? 1 : 0; |
| 130 | samples = desc.multiSample; |
| 131 | surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; |
| 132 | transparentType = EGL_NONE; |
| 133 | transparentRedValue = 0; |
| 134 | transparentGreenValue = 0; |
| 135 | transparentBlueValue = 0; |
shannon.woods%transgaming.com@gtempaccount.com | dcf33d5 | 2013-04-13 03:33:11 +0000 | [diff] [blame] | 136 | |
Austin Kinross | aed9f94 | 2014-10-23 14:31:03 -0700 | [diff] [blame] | 137 | if (desc.es2Conformant) |
| 138 | { |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 139 | conformant = EGL_OPENGL_ES2_BIT; |
Austin Kinross | aed9f94 | 2014-10-23 14:31:03 -0700 | [diff] [blame] | 140 | } |
| 141 | |
shannon.woods%transgaming.com@gtempaccount.com | dcf33d5 | 2013-04-13 03:33:11 +0000 | [diff] [blame] | 142 | if (desc.es3Capable) |
| 143 | { |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 144 | renderableType |= EGL_OPENGL_ES3_BIT_KHR; |
| 145 | conformant |= EGL_OPENGL_ES3_BIT_KHR; |
shannon.woods%transgaming.com@gtempaccount.com | dcf33d5 | 2013-04-13 03:33:11 +0000 | [diff] [blame] | 146 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 149 | EGLint ConfigSet::add(const Config &config) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 150 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 151 | // Set the config's ID to a small number that starts at 1 ([EGL 1.5] section 3.4) |
| 152 | EGLint id = mConfigs.size() + 1; |
| 153 | |
| 154 | Config copyConfig(config); |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 155 | copyConfig.configID = id; |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 156 | mConfigs.insert(std::make_pair(id, copyConfig)); |
| 157 | |
| 158 | return id; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 161 | const Config &ConfigSet::get(EGLint id) const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 162 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 163 | return mConfigs.at(id); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 166 | void ConfigSet::clear() |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 167 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 168 | mConfigs.clear(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 169 | } |
| 170 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 171 | size_t ConfigSet::size() const |
| 172 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 173 | return mConfigs.size(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 176 | bool ConfigSet::contains(const Config *config) const |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 177 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 178 | for (auto i = mConfigs.begin(); i != mConfigs.end(); i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 179 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 180 | const Config &item = i->second; |
| 181 | if (config == &item) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 182 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 183 | return true; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return false; |
| 188 | } |
| 189 | |
| 190 | // Function object used by STL sorting routines for ordering Configs according to [EGL 1.5] section 3.4.1.2 page 28. |
| 191 | class ConfigSorter |
| 192 | { |
| 193 | public: |
| 194 | explicit ConfigSorter(const AttributeMap &attributeMap) |
| 195 | { |
| 196 | scanForWantedComponents(attributeMap); |
| 197 | } |
| 198 | |
| 199 | bool operator()(const Config *x, const Config *y) const |
| 200 | { |
| 201 | return (*this)(*x, *y); |
| 202 | } |
| 203 | |
| 204 | bool operator()(const Config &x, const Config &y) const |
| 205 | { |
| 206 | #define SORT(attribute) \ |
| 207 | if (x.attribute != y.attribute) \ |
| 208 | { \ |
| 209 | return x.attribute < y.attribute; \ |
| 210 | } |
| 211 | |
| 212 | META_ASSERT(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG); |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 213 | SORT(configCaveat); |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 214 | |
| 215 | META_ASSERT(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 216 | SORT(colorBufferType); |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 217 | |
| 218 | // By larger total number of color bits, only considering those that are requested to be > 0. |
| 219 | EGLint xComponentsSize = wantedComponentsSize(x); |
| 220 | EGLint yComponentsSize = wantedComponentsSize(y); |
| 221 | if (xComponentsSize != yComponentsSize) |
| 222 | { |
| 223 | return xComponentsSize > yComponentsSize; |
| 224 | } |
| 225 | |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 226 | SORT(bufferSize); |
| 227 | SORT(sampleBuffers); |
| 228 | SORT(samples); |
| 229 | SORT(depthSize); |
| 230 | SORT(stencilSize); |
| 231 | SORT(alphaMaskSize); |
| 232 | SORT(nativeVisualType); |
| 233 | SORT(configID); |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 234 | |
| 235 | #undef SORT |
| 236 | |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | private: |
| 241 | void scanForWantedComponents(const AttributeMap &attributeMap) |
| 242 | { |
| 243 | // [EGL 1.5] section 3.4.1.2 page 30 |
| 244 | // Sorting rule #3: by larger total number of color bits, not considering |
| 245 | // components that are 0 or don't-care. |
| 246 | for (auto attribIter = attributeMap.begin(); attribIter != attributeMap.end(); attribIter++) |
| 247 | { |
| 248 | EGLint attributeKey = attribIter->first; |
| 249 | EGLint attributeValue = attribIter->second; |
| 250 | if (attributeKey != 0 && attributeValue != EGL_DONT_CARE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 251 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 252 | switch (attributeKey) |
| 253 | { |
| 254 | case EGL_RED_SIZE: mWantRed = true; break; |
| 255 | case EGL_GREEN_SIZE: mWantGreen = true; break; |
| 256 | case EGL_BLUE_SIZE: mWantBlue = true; break; |
| 257 | case EGL_ALPHA_SIZE: mWantAlpha = true; break; |
| 258 | case EGL_LUMINANCE_SIZE: mWantLuminance = true; break; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | EGLint wantedComponentsSize(const Config &config) const |
| 265 | { |
| 266 | EGLint total = 0; |
| 267 | |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 268 | if (mWantRed) total += config.redSize; |
| 269 | if (mWantGreen) total += config.greenSize; |
| 270 | if (mWantBlue) total += config.blueSize; |
| 271 | if (mWantAlpha) total += config.alphaSize; |
| 272 | if (mWantLuminance) total += config.luminanceSize; |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 273 | |
| 274 | return total; |
| 275 | } |
| 276 | |
| 277 | bool mWantRed; |
| 278 | bool mWantGreen; |
| 279 | bool mWantBlue; |
| 280 | bool mWantAlpha; |
| 281 | bool mWantLuminance; |
| 282 | }; |
| 283 | |
| 284 | std::vector<const Config*> ConfigSet::filter(const AttributeMap &attributeMap) const |
| 285 | { |
| 286 | std::vector<const Config*> result; |
| 287 | result.reserve(mConfigs.size()); |
| 288 | |
| 289 | for (auto configIter = mConfigs.begin(); configIter != mConfigs.end(); configIter++) |
| 290 | { |
| 291 | const Config &config = configIter->second; |
| 292 | bool match = true; |
| 293 | |
| 294 | for (auto attribIter = attributeMap.begin(); attribIter != attributeMap.end(); attribIter++) |
| 295 | { |
| 296 | EGLint attributeKey = attribIter->first; |
| 297 | EGLint attributeValue = attribIter->second; |
| 298 | |
| 299 | switch (attributeKey) |
| 300 | { |
Geoff Lang | c223dc6 | 2015-01-09 13:10:01 -0500 | [diff] [blame^] | 301 | case EGL_BUFFER_SIZE: match = config.bufferSize >= attributeValue; break; |
| 302 | case EGL_ALPHA_SIZE: match = config.alphaSize >= attributeValue; break; |
| 303 | case EGL_BLUE_SIZE: match = config.blueSize >= attributeValue; break; |
| 304 | case EGL_GREEN_SIZE: match = config.greenSize >= attributeValue; break; |
| 305 | case EGL_RED_SIZE: match = config.redSize >= attributeValue; break; |
| 306 | case EGL_DEPTH_SIZE: match = config.depthSize >= attributeValue; break; |
| 307 | case EGL_STENCIL_SIZE: match = config.stencilSize >= attributeValue; break; |
| 308 | case EGL_CONFIG_CAVEAT: match = config.configCaveat == (EGLenum)attributeValue; break; |
| 309 | case EGL_CONFIG_ID: match = config.configID == attributeValue; break; |
| 310 | case EGL_LEVEL: match = config.level >= attributeValue; break; |
| 311 | case EGL_NATIVE_RENDERABLE: match = config.nativeRenderable == (EGLBoolean)attributeValue; break; |
| 312 | case EGL_NATIVE_VISUAL_TYPE: match = config.nativeVisualType == attributeValue; break; |
| 313 | case EGL_SAMPLES: match = config.samples >= attributeValue; break; |
| 314 | case EGL_SAMPLE_BUFFERS: match = config.sampleBuffers >= attributeValue; break; |
| 315 | case EGL_SURFACE_TYPE: match = (config.surfaceType & attributeValue) == attributeValue; break; |
| 316 | case EGL_TRANSPARENT_TYPE: match = config.transparentType == (EGLenum)attributeValue; break; |
| 317 | case EGL_TRANSPARENT_BLUE_VALUE: match = config.transparentBlueValue == attributeValue; break; |
| 318 | case EGL_TRANSPARENT_GREEN_VALUE: match = config.transparentGreenValue == attributeValue; break; |
| 319 | case EGL_TRANSPARENT_RED_VALUE: match = config.transparentRedValue == attributeValue; break; |
| 320 | case EGL_BIND_TO_TEXTURE_RGB: match = config.bindToTextureRGB == (EGLBoolean)attributeValue; break; |
| 321 | case EGL_BIND_TO_TEXTURE_RGBA: match = config.bindToTextureRGBA == (EGLBoolean)attributeValue; break; |
| 322 | case EGL_MIN_SWAP_INTERVAL: match = config.minSwapInterval == attributeValue; break; |
| 323 | case EGL_MAX_SWAP_INTERVAL: match = config.maxSwapInterval == attributeValue; break; |
| 324 | case EGL_LUMINANCE_SIZE: match = config.luminanceSize >= attributeValue; break; |
| 325 | case EGL_ALPHA_MASK_SIZE: match = config.alphaMaskSize >= attributeValue; break; |
| 326 | case EGL_COLOR_BUFFER_TYPE: match = config.colorBufferType == (EGLenum)attributeValue; break; |
| 327 | case EGL_RENDERABLE_TYPE: match = (config.renderableType & attributeValue) == attributeValue; break; |
| 328 | case EGL_MATCH_NATIVE_PIXMAP: match = false; UNIMPLEMENTED(); break; |
| 329 | case EGL_CONFORMANT: match = (config.conformant & attributeValue) == attributeValue; break; |
| 330 | case EGL_MAX_PBUFFER_WIDTH: match = config.maxPBufferWidth >= attributeValue; break; |
| 331 | case EGL_MAX_PBUFFER_HEIGHT: match = config.maxPBufferHeight >= attributeValue; break; |
| 332 | case EGL_MAX_PBUFFER_PIXELS: match = config.maxPBufferPixels >= attributeValue; break; |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 333 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 334 | } |
| 335 | |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 336 | if (!match) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 337 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 338 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 342 | if (match) |
| 343 | { |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 344 | result.push_back(&config); |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 348 | // Sort the result |
| 349 | std::sort(result.begin(), result.end(), ConfigSorter(attributeMap)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 350 | |
Geoff Lang | 6812a55 | 2015-01-06 17:26:42 -0500 | [diff] [blame] | 351 | return result; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 352 | } |
| 353 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 354 | } |