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. |
| 9 | // [EGL 1.4] section 3.4 page 15. |
| 10 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | #include "libEGL/Config.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12 | |
| 13 | #include <algorithm> |
| 14 | #include <vector> |
| 15 | |
shannon.woods%transgaming.com@gtempaccount.com | f26ddae | 2013-04-13 03:29:13 +0000 | [diff] [blame] | 16 | #include <GLES3/gl3.h> |
| 17 | #include <GLES3/gl3ext.h> |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 18 | #include <GLES2/gl2.h> |
| 19 | #include <GLES2/gl2ext.h> |
| 20 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 21 | #include "common/debug.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 22 | |
| 23 | using namespace std; |
| 24 | |
| 25 | namespace egl |
| 26 | { |
daniel@transgaming.com | 76d3e6e | 2012-10-31 19:55:33 +0000 | [diff] [blame] | 27 | 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] | 28 | : mRenderTargetFormat(desc.renderTargetFormat), mDepthStencilFormat(desc.depthStencilFormat), mMultiSample(desc.multiSample) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 29 | { |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 30 | mBindToTextureRGB = EGL_FALSE; |
| 31 | mBindToTextureRGBA = EGL_FALSE; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 32 | switch (desc.renderTargetFormat) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 33 | { |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 34 | case GL_RGB5_A1: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 35 | mBufferSize = 16; |
| 36 | mRedSize = 5; |
| 37 | mGreenSize = 5; |
| 38 | mBlueSize = 5; |
| 39 | mAlphaSize = 1; |
| 40 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 41 | case GL_RGBA8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | mBufferSize = 32; |
| 43 | mRedSize = 8; |
| 44 | mGreenSize = 8; |
| 45 | mBlueSize = 8; |
| 46 | mAlphaSize = 8; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 47 | mBindToTextureRGBA = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 48 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 49 | case GL_RGB565: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 50 | mBufferSize = 16; |
| 51 | mRedSize = 5; |
| 52 | mGreenSize = 6; |
| 53 | mBlueSize = 5; |
| 54 | mAlphaSize = 0; |
| 55 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 56 | case GL_RGB8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 57 | mBufferSize = 32; |
| 58 | mRedSize = 8; |
| 59 | mGreenSize = 8; |
| 60 | mBlueSize = 8; |
| 61 | mAlphaSize = 0; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 62 | mBindToTextureRGB = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 63 | break; |
shannon.woods@transgaming.com | c60c521 | 2013-01-25 21:54:01 +0000 | [diff] [blame] | 64 | case GL_BGRA8_EXT: |
| 65 | mBufferSize = 32; |
| 66 | mRedSize = 8; |
| 67 | mGreenSize = 8; |
| 68 | mBlueSize = 8; |
| 69 | mAlphaSize = 8; |
| 70 | mBindToTextureRGBA = true; |
| 71 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 72 | default: |
| 73 | UNREACHABLE(); // Other formats should not be valid |
| 74 | } |
| 75 | |
| 76 | mLuminanceSize = 0; |
| 77 | mAlphaMaskSize = 0; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 78 | mColorBufferType = EGL_RGB_BUFFER; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 79 | mConfigCaveat = (desc.fastConfig) ? EGL_NONE : EGL_SLOW_CONFIG; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 80 | mConfigID = 0; |
| 81 | mConformant = EGL_OPENGL_ES2_BIT; |
| 82 | |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 83 | switch (desc.depthStencilFormat) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 84 | { |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 85 | case GL_NONE: |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 86 | mDepthSize = 0; |
| 87 | mStencilSize = 0; |
| 88 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 89 | case GL_DEPTH_COMPONENT32_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 90 | mDepthSize = 32; |
| 91 | mStencilSize = 0; |
| 92 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 93 | case GL_DEPTH24_STENCIL8_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 94 | mDepthSize = 24; |
| 95 | mStencilSize = 8; |
| 96 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 97 | case GL_DEPTH_COMPONENT24_OES: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 98 | mDepthSize = 24; |
| 99 | mStencilSize = 0; |
| 100 | break; |
daniel@transgaming.com | 106e1f7 | 2012-10-31 18:38:36 +0000 | [diff] [blame] | 101 | case GL_DEPTH_COMPONENT16: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 102 | mDepthSize = 16; |
| 103 | mStencilSize = 0; |
| 104 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 105 | default: |
| 106 | UNREACHABLE(); |
| 107 | } |
| 108 | |
| 109 | mLevel = 0; |
| 110 | mMatchNativePixmap = EGL_NONE; |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 111 | mMaxPBufferWidth = texWidth; |
| 112 | mMaxPBufferHeight = texHeight; |
| 113 | mMaxPBufferPixels = texWidth*texHeight; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | mMaxSwapInterval = maxInterval; |
| 115 | mMinSwapInterval = minInterval; |
| 116 | mNativeRenderable = EGL_FALSE; |
| 117 | mNativeVisualID = 0; |
| 118 | mNativeVisualType = 0; |
| 119 | mRenderableType = EGL_OPENGL_ES2_BIT; |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 120 | mSampleBuffers = desc.multiSample ? 1 : 0; |
| 121 | mSamples = desc.multiSample; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 122 | mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; |
| 123 | mTransparentType = EGL_NONE; |
| 124 | mTransparentRedValue = 0; |
| 125 | mTransparentGreenValue = 0; |
| 126 | mTransparentBlueValue = 0; |
| 127 | } |
| 128 | |
| 129 | EGLConfig Config::getHandle() const |
| 130 | { |
| 131 | return (EGLConfig)(size_t)mConfigID; |
| 132 | } |
| 133 | |
| 134 | SortConfig::SortConfig(const EGLint *attribList) |
| 135 | : mWantRed(false), mWantGreen(false), mWantBlue(false), mWantAlpha(false), mWantLuminance(false) |
| 136 | { |
| 137 | scanForWantedComponents(attribList); |
| 138 | } |
| 139 | |
| 140 | void SortConfig::scanForWantedComponents(const EGLint *attribList) |
| 141 | { |
| 142 | // [EGL] section 3.4.1 page 24 |
| 143 | // Sorting rule #3: by larger total number of color bits, not considering |
| 144 | // components that are 0 or don't-care. |
| 145 | for (const EGLint *attr = attribList; attr[0] != EGL_NONE; attr += 2) |
| 146 | { |
| 147 | if (attr[1] != 0 && attr[1] != EGL_DONT_CARE) |
| 148 | { |
| 149 | switch (attr[0]) |
| 150 | { |
| 151 | case EGL_RED_SIZE: mWantRed = true; break; |
| 152 | case EGL_GREEN_SIZE: mWantGreen = true; break; |
| 153 | case EGL_BLUE_SIZE: mWantBlue = true; break; |
| 154 | case EGL_ALPHA_SIZE: mWantAlpha = true; break; |
| 155 | case EGL_LUMINANCE_SIZE: mWantLuminance = true; break; |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | EGLint SortConfig::wantedComponentsSize(const Config &config) const |
| 162 | { |
| 163 | EGLint total = 0; |
| 164 | |
| 165 | if (mWantRed) total += config.mRedSize; |
| 166 | if (mWantGreen) total += config.mGreenSize; |
| 167 | if (mWantBlue) total += config.mBlueSize; |
| 168 | if (mWantAlpha) total += config.mAlphaSize; |
| 169 | if (mWantLuminance) total += config.mLuminanceSize; |
| 170 | |
| 171 | return total; |
| 172 | } |
| 173 | |
| 174 | bool SortConfig::operator()(const Config *x, const Config *y) const |
| 175 | { |
| 176 | return (*this)(*x, *y); |
| 177 | } |
| 178 | |
| 179 | bool SortConfig::operator()(const Config &x, const Config &y) const |
| 180 | { |
| 181 | #define SORT(attribute) \ |
| 182 | if (x.attribute != y.attribute) \ |
| 183 | { \ |
| 184 | return x.attribute < y.attribute; \ |
| 185 | } |
| 186 | |
| 187 | META_ASSERT(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG); |
| 188 | SORT(mConfigCaveat); |
| 189 | |
| 190 | META_ASSERT(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); |
| 191 | SORT(mColorBufferType); |
| 192 | |
| 193 | // By larger total number of color bits, only considering those that are requested to be > 0. |
| 194 | EGLint xComponentsSize = wantedComponentsSize(x); |
| 195 | EGLint yComponentsSize = wantedComponentsSize(y); |
| 196 | if (xComponentsSize != yComponentsSize) |
| 197 | { |
| 198 | return xComponentsSize > yComponentsSize; |
| 199 | } |
| 200 | |
| 201 | SORT(mBufferSize); |
| 202 | SORT(mSampleBuffers); |
| 203 | SORT(mSamples); |
| 204 | SORT(mDepthSize); |
| 205 | SORT(mStencilSize); |
| 206 | SORT(mAlphaMaskSize); |
| 207 | SORT(mNativeVisualType); |
| 208 | SORT(mConfigID); |
| 209 | |
| 210 | #undef SORT |
| 211 | |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | // We'd like to use SortConfig to also eliminate duplicate configs. |
| 216 | // This works as long as we never have two configs with different per-RGB-component layouts, |
| 217 | // but the same total. |
| 218 | // 5551 and 565 are different because R+G+B is different. |
| 219 | // 5551 and 555 are different because bufferSize is different. |
| 220 | const EGLint ConfigSet::mSortAttribs[] = |
| 221 | { |
| 222 | EGL_RED_SIZE, 1, |
| 223 | EGL_GREEN_SIZE, 1, |
| 224 | EGL_BLUE_SIZE, 1, |
| 225 | EGL_LUMINANCE_SIZE, 1, |
| 226 | // BUT NOT ALPHA |
| 227 | EGL_NONE |
| 228 | }; |
| 229 | |
| 230 | ConfigSet::ConfigSet() |
| 231 | : mSet(SortConfig(mSortAttribs)) |
| 232 | { |
| 233 | } |
| 234 | |
daniel@transgaming.com | 76d3e6e | 2012-10-31 19:55:33 +0000 | [diff] [blame] | 235 | void ConfigSet::add(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 236 | { |
daniel@transgaming.com | 3281f97 | 2012-10-31 18:38:51 +0000 | [diff] [blame] | 237 | Config config(desc, minSwapInterval, maxSwapInterval, texWidth, texHeight); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 238 | mSet.insert(config); |
| 239 | } |
| 240 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 241 | size_t ConfigSet::size() const |
| 242 | { |
| 243 | return mSet.size(); |
| 244 | } |
| 245 | |
| 246 | bool ConfigSet::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig) |
| 247 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 248 | vector<const Config*> passed; |
| 249 | passed.reserve(mSet.size()); |
| 250 | |
| 251 | for (Iterator config = mSet.begin(); config != mSet.end(); config++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 252 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 253 | bool match = true; |
| 254 | const EGLint *attribute = attribList; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 255 | |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 256 | while (attribute[0] != EGL_NONE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 257 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 258 | switch (attribute[0]) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 259 | { |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 260 | case EGL_BUFFER_SIZE: match = config->mBufferSize >= attribute[1]; break; |
| 261 | case EGL_ALPHA_SIZE: match = config->mAlphaSize >= attribute[1]; break; |
| 262 | case EGL_BLUE_SIZE: match = config->mBlueSize >= attribute[1]; break; |
| 263 | case EGL_GREEN_SIZE: match = config->mGreenSize >= attribute[1]; break; |
| 264 | case EGL_RED_SIZE: match = config->mRedSize >= attribute[1]; break; |
| 265 | case EGL_DEPTH_SIZE: match = config->mDepthSize >= attribute[1]; break; |
| 266 | case EGL_STENCIL_SIZE: match = config->mStencilSize >= attribute[1]; break; |
apatrick@chromium.org | 9c3a393 | 2012-01-30 20:03:32 +0000 | [diff] [blame] | 267 | case EGL_CONFIG_CAVEAT: match = config->mConfigCaveat == (EGLenum) attribute[1]; break; |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 268 | case EGL_CONFIG_ID: match = config->mConfigID == attribute[1]; break; |
| 269 | case EGL_LEVEL: match = config->mLevel >= attribute[1]; break; |
apatrick@chromium.org | 9c3a393 | 2012-01-30 20:03:32 +0000 | [diff] [blame] | 270 | case EGL_NATIVE_RENDERABLE: match = config->mNativeRenderable == (EGLBoolean) attribute[1]; break; |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 271 | case EGL_NATIVE_VISUAL_TYPE: match = config->mNativeVisualType == attribute[1]; break; |
| 272 | case EGL_SAMPLES: match = config->mSamples >= attribute[1]; break; |
| 273 | case EGL_SAMPLE_BUFFERS: match = config->mSampleBuffers >= attribute[1]; break; |
| 274 | case EGL_SURFACE_TYPE: match = (config->mSurfaceType & attribute[1]) == attribute[1]; break; |
apatrick@chromium.org | 9c3a393 | 2012-01-30 20:03:32 +0000 | [diff] [blame] | 275 | case EGL_TRANSPARENT_TYPE: match = config->mTransparentType == (EGLenum) attribute[1]; break; |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 276 | case EGL_TRANSPARENT_BLUE_VALUE: match = config->mTransparentBlueValue == attribute[1]; break; |
| 277 | case EGL_TRANSPARENT_GREEN_VALUE: match = config->mTransparentGreenValue == attribute[1]; break; |
| 278 | case EGL_TRANSPARENT_RED_VALUE: match = config->mTransparentRedValue == attribute[1]; break; |
apatrick@chromium.org | 9c3a393 | 2012-01-30 20:03:32 +0000 | [diff] [blame] | 279 | case EGL_BIND_TO_TEXTURE_RGB: match = config->mBindToTextureRGB == (EGLBoolean) attribute[1]; break; |
| 280 | case EGL_BIND_TO_TEXTURE_RGBA: match = config->mBindToTextureRGBA == (EGLBoolean) attribute[1]; break; |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 281 | case EGL_MIN_SWAP_INTERVAL: match = config->mMinSwapInterval == attribute[1]; break; |
| 282 | case EGL_MAX_SWAP_INTERVAL: match = config->mMaxSwapInterval == attribute[1]; break; |
| 283 | case EGL_LUMINANCE_SIZE: match = config->mLuminanceSize >= attribute[1]; break; |
| 284 | case EGL_ALPHA_MASK_SIZE: match = config->mAlphaMaskSize >= attribute[1]; break; |
apatrick@chromium.org | 9c3a393 | 2012-01-30 20:03:32 +0000 | [diff] [blame] | 285 | case EGL_COLOR_BUFFER_TYPE: match = config->mColorBufferType == (EGLenum) attribute[1]; break; |
daniel@transgaming.com | 178adff | 2010-05-18 18:52:04 +0000 | [diff] [blame] | 286 | case EGL_RENDERABLE_TYPE: match = (config->mRenderableType & attribute[1]) == attribute[1]; break; |
| 287 | case EGL_MATCH_NATIVE_PIXMAP: match = false; UNIMPLEMENTED(); break; |
| 288 | case EGL_CONFORMANT: match = (config->mConformant & attribute[1]) == attribute[1]; break; |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 289 | case EGL_MAX_PBUFFER_WIDTH: match = config->mMaxPBufferWidth >= attribute[1]; break; |
| 290 | case EGL_MAX_PBUFFER_HEIGHT: match = config->mMaxPBufferHeight >= attribute[1]; break; |
| 291 | case EGL_MAX_PBUFFER_PIXELS: match = config->mMaxPBufferPixels >= attribute[1]; break; |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 292 | default: |
| 293 | return false; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 294 | } |
| 295 | |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 296 | if (!match) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 297 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 298 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 299 | } |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 300 | |
| 301 | attribute += 2; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 302 | } |
| 303 | |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 304 | if (match) |
| 305 | { |
| 306 | passed.push_back(&*config); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | if (configs) |
| 311 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 312 | sort(passed.begin(), passed.end(), SortConfig(attribList)); |
| 313 | |
| 314 | EGLint index; |
| 315 | for (index = 0; index < configSize && index < static_cast<EGLint>(passed.size()); index++) |
| 316 | { |
| 317 | configs[index] = passed[index]->getHandle(); |
| 318 | } |
| 319 | |
| 320 | *numConfig = index; |
| 321 | } |
| 322 | else |
| 323 | { |
daniel@transgaming.com | 6a94b97 | 2010-05-13 02:02:34 +0000 | [diff] [blame] | 324 | *numConfig = passed.size(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | const egl::Config *ConfigSet::get(EGLConfig configHandle) |
| 331 | { |
| 332 | for (Iterator config = mSet.begin(); config != mSet.end(); config++) |
| 333 | { |
| 334 | if (config->getHandle() == configHandle) |
| 335 | { |
| 336 | return &(*config); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return NULL; |
| 341 | } |
| 342 | } |