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) |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 30 | : mRenderTargetFormat(desc.renderTargetFormat), mDepthStencilFormat(desc.depthStencilFormat), mMultiSample(desc.multiSample) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 31 | { |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 32 | mBindToTextureRGB = EGL_FALSE; |
| 33 | mBindToTextureRGBA = 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: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | mBufferSize = 16; |
| 38 | mRedSize = 5; |
| 39 | mGreenSize = 5; |
| 40 | mBlueSize = 5; |
| 41 | mAlphaSize = 1; |
| 42 | break; |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 43 | case GL_BGR5_A1_ANGLEX: |
| 44 | mBufferSize = 16; |
| 45 | mRedSize = 5; |
| 46 | mGreenSize = 5; |
| 47 | mBlueSize = 5; |
| 48 | mAlphaSize = 1; |
| 49 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 50 | case GL_RGBA8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 51 | mBufferSize = 32; |
| 52 | mRedSize = 8; |
| 53 | mGreenSize = 8; |
| 54 | mBlueSize = 8; |
| 55 | mAlphaSize = 8; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 56 | mBindToTextureRGBA = 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: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 59 | mBufferSize = 16; |
| 60 | mRedSize = 5; |
| 61 | mGreenSize = 6; |
| 62 | mBlueSize = 5; |
| 63 | mAlphaSize = 0; |
| 64 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 65 | case GL_RGB8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | mBufferSize = 32; |
| 67 | mRedSize = 8; |
| 68 | mGreenSize = 8; |
| 69 | mBlueSize = 8; |
| 70 | mAlphaSize = 0; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 71 | mBindToTextureRGB = 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: |
| 74 | mBufferSize = 32; |
| 75 | mRedSize = 8; |
| 76 | mGreenSize = 8; |
| 77 | mBlueSize = 8; |
| 78 | mAlphaSize = 8; |
| 79 | mBindToTextureRGBA = true; |
| 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 | |
| 85 | mLuminanceSize = 0; |
| 86 | mAlphaMaskSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 87 | mColorBufferType = EGL_RGB_BUFFER; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 88 | mConfigCaveat = (desc.fastConfig) ? EGL_NONE : EGL_SLOW_CONFIG; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 89 | mConfigID = 0; |
Austin Kinross | aed9f94 | 2014-10-23 14:31:03 -0700 | [diff] [blame] | 90 | mConformant = 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: |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 95 | mDepthSize = 0; |
| 96 | mStencilSize = 0; |
| 97 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 98 | case GL_DEPTH_COMPONENT32_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 99 | mDepthSize = 32; |
| 100 | mStencilSize = 0; |
| 101 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 102 | case GL_DEPTH24_STENCIL8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 103 | mDepthSize = 24; |
| 104 | mStencilSize = 8; |
| 105 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 106 | case GL_DEPTH_COMPONENT24_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 107 | mDepthSize = 24; |
| 108 | mStencilSize = 0; |
| 109 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 110 | case GL_DEPTH_COMPONENT16: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 111 | mDepthSize = 16; |
| 112 | mStencilSize = 0; |
| 113 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | default: |
| 115 | UNREACHABLE(); |
| 116 | } |
| 117 | |
| 118 | mLevel = 0; |
| 119 | mMatchNativePixmap = EGL_NONE; |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 120 | mMaxPBufferWidth = texWidth; |
| 121 | mMaxPBufferHeight = texHeight; |
| 122 | mMaxPBufferPixels = texWidth*texHeight; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | mMaxSwapInterval = maxInterval; |
| 124 | mMinSwapInterval = minInterval; |
| 125 | mNativeRenderable = EGL_FALSE; |
| 126 | mNativeVisualID = 0; |
| 127 | mNativeVisualType = 0; |
| 128 | mRenderableType = EGL_OPENGL_ES2_BIT; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 129 | mSampleBuffers = desc.multiSample ? 1 : 0; |
| 130 | mSamples = desc.multiSample; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 131 | mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; |
| 132 | mTransparentType = EGL_NONE; |
| 133 | mTransparentRedValue = 0; |
| 134 | mTransparentGreenValue = 0; |
| 135 | mTransparentBlueValue = 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 | { |
| 139 | mConformant = EGL_OPENGL_ES2_BIT; |
| 140 | } |
| 141 | |
shannon.woods%transgaming.com@gtempaccount.com | dcf33d5 | 2013-04-13 03:33:11 +0000 | [diff] [blame] | 142 | if (desc.es3Capable) |
| 143 | { |
| 144 | mRenderableType |= EGL_OPENGL_ES3_BIT_KHR; |
| 145 | mConformant |= EGL_OPENGL_ES3_BIT_KHR; |
| 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); |
| 155 | copyConfig.mConfigID = id; |
| 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); |
| 213 | SORT(mConfigCaveat); |
| 214 | |
| 215 | META_ASSERT(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); |
| 216 | SORT(mColorBufferType); |
| 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 | |
| 226 | SORT(mBufferSize); |
| 227 | SORT(mSampleBuffers); |
| 228 | SORT(mSamples); |
| 229 | SORT(mDepthSize); |
| 230 | SORT(mStencilSize); |
| 231 | SORT(mAlphaMaskSize); |
| 232 | SORT(mNativeVisualType); |
| 233 | SORT(mConfigID); |
| 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 | |
| 268 | if (mWantRed) total += config.mRedSize; |
| 269 | if (mWantGreen) total += config.mGreenSize; |
| 270 | if (mWantBlue) total += config.mBlueSize; |
| 271 | if (mWantAlpha) total += config.mAlphaSize; |
| 272 | if (mWantLuminance) total += config.mLuminanceSize; |
| 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 | { |
| 301 | case EGL_BUFFER_SIZE: match = config.mBufferSize >= attributeValue; break; |
| 302 | case EGL_ALPHA_SIZE: match = config.mAlphaSize >= attributeValue; break; |
| 303 | case EGL_BLUE_SIZE: match = config.mBlueSize >= attributeValue; break; |
| 304 | case EGL_GREEN_SIZE: match = config.mGreenSize >= attributeValue; break; |
| 305 | case EGL_RED_SIZE: match = config.mRedSize >= attributeValue; break; |
| 306 | case EGL_DEPTH_SIZE: match = config.mDepthSize >= attributeValue; break; |
| 307 | case EGL_STENCIL_SIZE: match = config.mStencilSize >= attributeValue; break; |
| 308 | case EGL_CONFIG_CAVEAT: match = config.mConfigCaveat == (EGLenum)attributeValue; break; |
| 309 | case EGL_CONFIG_ID: match = config.mConfigID == attributeValue; break; |
| 310 | case EGL_LEVEL: match = config.mLevel >= attributeValue; break; |
| 311 | case EGL_NATIVE_RENDERABLE: match = config.mNativeRenderable == (EGLBoolean)attributeValue; break; |
| 312 | case EGL_NATIVE_VISUAL_TYPE: match = config.mNativeVisualType == attributeValue; break; |
| 313 | case EGL_SAMPLES: match = config.mSamples >= attributeValue; break; |
| 314 | case EGL_SAMPLE_BUFFERS: match = config.mSampleBuffers >= attributeValue; break; |
| 315 | case EGL_SURFACE_TYPE: match = (config.mSurfaceType & attributeValue) == attributeValue; break; |
| 316 | case EGL_TRANSPARENT_TYPE: match = config.mTransparentType == (EGLenum)attributeValue; break; |
| 317 | case EGL_TRANSPARENT_BLUE_VALUE: match = config.mTransparentBlueValue == attributeValue; break; |
| 318 | case EGL_TRANSPARENT_GREEN_VALUE: match = config.mTransparentGreenValue == attributeValue; break; |
| 319 | case EGL_TRANSPARENT_RED_VALUE: match = config.mTransparentRedValue == attributeValue; break; |
| 320 | case EGL_BIND_TO_TEXTURE_RGB: match = config.mBindToTextureRGB == (EGLBoolean)attributeValue; break; |
| 321 | case EGL_BIND_TO_TEXTURE_RGBA: match = config.mBindToTextureRGBA == (EGLBoolean)attributeValue; break; |
| 322 | case EGL_MIN_SWAP_INTERVAL: match = config.mMinSwapInterval == attributeValue; break; |
| 323 | case EGL_MAX_SWAP_INTERVAL: match = config.mMaxSwapInterval == attributeValue; break; |
| 324 | case EGL_LUMINANCE_SIZE: match = config.mLuminanceSize >= attributeValue; break; |
| 325 | case EGL_ALPHA_MASK_SIZE: match = config.mAlphaMaskSize >= attributeValue; break; |
| 326 | case EGL_COLOR_BUFFER_TYPE: match = config.mColorBufferType == (EGLenum)attributeValue; break; |
| 327 | case EGL_RENDERABLE_TYPE: match = (config.mRenderableType & attributeValue) == attributeValue; break; |
| 328 | case EGL_MATCH_NATIVE_PIXMAP: match = false; UNIMPLEMENTED(); break; |
| 329 | case EGL_CONFORMANT: match = (config.mConformant & attributeValue) == attributeValue; break; |
| 330 | case EGL_MAX_PBUFFER_WIDTH: match = config.mMaxPBufferWidth >= attributeValue; break; |
| 331 | case EGL_MAX_PBUFFER_HEIGHT: match = config.mMaxPBufferHeight >= attributeValue; break; |
| 332 | case EGL_MAX_PBUFFER_PIXELS: match = config.mMaxPBufferPixels >= attributeValue; break; |
| 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 | } |