Give sorted configs a unique ID without changing the original set
TRAC #12323
This fixes building on Visual C++ 2010, which has const iterators for STL sets as specified by C++0x.
Signed-off-by: Shannon Woods
Singed-off-by: Daniel Koch

Author:    Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@302 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libEGL/Config.cpp b/src/libEGL/Config.cpp
index 9665e77..21d4661 100644
--- a/src/libEGL/Config.cpp
+++ b/src/libEGL/Config.cpp
@@ -296,17 +296,6 @@
     mSet.insert(config);
 }
 
-void ConfigSet::enumerate()
-{
-    EGLint index = 1;
-
-    for (Iterator config = mSet.begin(); config != mSet.end(); config++)
-    {
-        config->mConfigID = index;
-        index++;
-    }
-}
-
 size_t ConfigSet::size() const
 {
     return mSet.size();
@@ -326,35 +315,35 @@
         {
             switch (attribute[0])
             {
-              case EGL_BUFFER_SIZE:               match = config->mBufferSize >= attribute[1];                            break;
-              case EGL_ALPHA_SIZE:                match = config->mAlphaSize >= attribute[1];                            break;
-              case EGL_BLUE_SIZE:                 match = config->mBlueSize >= attribute[1];                            break;
-              case EGL_GREEN_SIZE:                match = config->mGreenSize >= attribute[1];                            break;
-              case EGL_RED_SIZE:                  match = config->mRedSize >= attribute[1];                            break;
-              case EGL_DEPTH_SIZE:                match = config->mDepthSize >= attribute[1];                            break;
-              case EGL_STENCIL_SIZE:              match = config->mStencilSize >= attribute[1];                        break;
-              case EGL_CONFIG_CAVEAT:             match = config->mConfigCaveat == attribute[1];                        break;
-              case EGL_CONFIG_ID:                 match = config->mConfigID == attribute[1];                            break;
-              case EGL_LEVEL:                     match = config->mLevel >= attribute[1];                                break;
-              case EGL_NATIVE_RENDERABLE:         match = config->mNativeRenderable == attribute[1];                    break;
-              case EGL_NATIVE_VISUAL_TYPE:        match = config->mNativeVisualType == attribute[1];                    break;
-              case EGL_SAMPLES:                   match = config->mSamples >= attribute[1];                            break;
-              case EGL_SAMPLE_BUFFERS:            match = config->mSampleBuffers >= attribute[1];                        break;
-              case EGL_SURFACE_TYPE:              match = (config->mSurfaceType & attribute[1]) == attribute[1];        break;
-              case EGL_TRANSPARENT_TYPE:          match = config->mTransparentType == attribute[1];                    break;
-              case EGL_TRANSPARENT_BLUE_VALUE:    match = config->mTransparentBlueValue == attribute[1];                break;
-              case EGL_TRANSPARENT_GREEN_VALUE:   match = config->mTransparentGreenValue == attribute[1];                break;
-              case EGL_TRANSPARENT_RED_VALUE:     match = config->mTransparentRedValue == attribute[1];                break;
-              case EGL_BIND_TO_TEXTURE_RGB:       match = config->mBindToTextureRGB == attribute[1];                    break;
-              case EGL_BIND_TO_TEXTURE_RGBA:      match = config->mBindToTextureRGBA == attribute[1];                    break;
-              case EGL_MIN_SWAP_INTERVAL:         match = config->mMinSwapInterval == attribute[1];                    break;
-              case EGL_MAX_SWAP_INTERVAL:         match = config->mMaxSwapInterval == attribute[1];                    break;
-              case EGL_LUMINANCE_SIZE:            match = config->mLuminanceSize >= attribute[1];                        break;
-              case EGL_ALPHA_MASK_SIZE:           match = config->mAlphaMaskSize >= attribute[1];                        break;
-              case EGL_COLOR_BUFFER_TYPE:         match = config->mColorBufferType == attribute[1];                    break;
-              case EGL_RENDERABLE_TYPE:           match = (config->mRenderableType & attribute[1]) == attribute[1];    break;
-              case EGL_MATCH_NATIVE_PIXMAP:       match = false; UNIMPLEMENTED();                                        break;
-              case EGL_CONFORMANT:                match = (config->mConformant & attribute[1]) == attribute[1];        break;
+              case EGL_BUFFER_SIZE:               match = config->mBufferSize >= attribute[1];                      break;
+              case EGL_ALPHA_SIZE:                match = config->mAlphaSize >= attribute[1];                       break;
+              case EGL_BLUE_SIZE:                 match = config->mBlueSize >= attribute[1];                        break;
+              case EGL_GREEN_SIZE:                match = config->mGreenSize >= attribute[1];                       break;
+              case EGL_RED_SIZE:                  match = config->mRedSize >= attribute[1];                         break;
+              case EGL_DEPTH_SIZE:                match = config->mDepthSize >= attribute[1];                       break;
+              case EGL_STENCIL_SIZE:              match = config->mStencilSize >= attribute[1];                     break;
+              case EGL_CONFIG_CAVEAT:             match = config->mConfigCaveat == attribute[1];                    break;
+              case EGL_CONFIG_ID:                 match = config->mConfigID == attribute[1];                        break;
+              case EGL_LEVEL:                     match = config->mLevel >= attribute[1];                           break;
+              case EGL_NATIVE_RENDERABLE:         match = config->mNativeRenderable == attribute[1];                break;
+              case EGL_NATIVE_VISUAL_TYPE:        match = config->mNativeVisualType == attribute[1];                break;
+              case EGL_SAMPLES:                   match = config->mSamples >= attribute[1];                         break;
+              case EGL_SAMPLE_BUFFERS:            match = config->mSampleBuffers >= attribute[1];                   break;
+              case EGL_SURFACE_TYPE:              match = (config->mSurfaceType & attribute[1]) == attribute[1];    break;
+              case EGL_TRANSPARENT_TYPE:          match = config->mTransparentType == attribute[1];                 break;
+              case EGL_TRANSPARENT_BLUE_VALUE:    match = config->mTransparentBlueValue == attribute[1];            break;
+              case EGL_TRANSPARENT_GREEN_VALUE:   match = config->mTransparentGreenValue == attribute[1];           break;
+              case EGL_TRANSPARENT_RED_VALUE:     match = config->mTransparentRedValue == attribute[1];             break;
+              case EGL_BIND_TO_TEXTURE_RGB:       match = config->mBindToTextureRGB == attribute[1];                break;
+              case EGL_BIND_TO_TEXTURE_RGBA:      match = config->mBindToTextureRGBA == attribute[1];               break;
+              case EGL_MIN_SWAP_INTERVAL:         match = config->mMinSwapInterval == attribute[1];                 break;
+              case EGL_MAX_SWAP_INTERVAL:         match = config->mMaxSwapInterval == attribute[1];                 break;
+              case EGL_LUMINANCE_SIZE:            match = config->mLuminanceSize >= attribute[1];                   break;
+              case EGL_ALPHA_MASK_SIZE:           match = config->mAlphaMaskSize >= attribute[1];                   break;
+              case EGL_COLOR_BUFFER_TYPE:         match = config->mColorBufferType == attribute[1];                 break;
+              case EGL_RENDERABLE_TYPE:           match = (config->mRenderableType & attribute[1]) == attribute[1]; break;
+              case EGL_MATCH_NATIVE_PIXMAP:       match = false; UNIMPLEMENTED();                                   break;
+              case EGL_CONFORMANT:                match = (config->mConformant & attribute[1]) == attribute[1];     break;
               default:
                 return false;
             }
diff --git a/src/libEGL/Config.h b/src/libEGL/Config.h
index d049067..b340f56 100644
--- a/src/libEGL/Config.h
+++ b/src/libEGL/Config.h
@@ -21,6 +21,8 @@
 
 namespace egl
 {
+class Display;
+
 class Config
 {
   public:
@@ -92,22 +94,23 @@
 
 class ConfigSet
 {
+    friend Display;
+
   public:
     ConfigSet();
 
     void add(D3DDISPLAYMODE displayMode, EGLint minSwapInterval, EGLint maxSwapInterval, D3DFORMAT renderTargetFormat, D3DFORMAT depthStencilFormat, EGLint multiSample);
-    void enumerate();
     size_t size() const;
     bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
     const egl::Config *get(EGLConfig configHandle);
 
+  private:
+    DISALLOW_COPY_AND_ASSIGN(ConfigSet);
+
     typedef std::set<Config, SortConfig> Set;
     typedef Set::iterator Iterator;
     Set mSet;
 
-  private:
-    DISALLOW_COPY_AND_ASSIGN(ConfigSet);
-
     static const EGLint mSortAttribs[];
 };
 }
diff --git a/src/libEGL/Display.cpp b/src/libEGL/Display.cpp
index d39a5bb..39949b2 100644
--- a/src/libEGL/Display.cpp
+++ b/src/libEGL/Display.cpp
@@ -103,6 +103,8 @@
             D3DDISPLAYMODE currentDisplayMode;
             mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
 
+            ConfigSet configSet;
+
             for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++)
             {
                 D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex];
@@ -124,15 +126,24 @@
                             {
                                 // FIXME: Enumerate multi-sampling
 
-                                mConfigSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0);
+                                configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0);
                             }
                         }
                     }
                 }
             }
-        }
 
-        mConfigSet.enumerate();
+            // Give the sorted configs a unique ID and store them internally
+            EGLint index = 1;
+            for (ConfigSet::Iterator config = configSet.mSet.begin(); config != configSet.mSet.end(); config++)
+            {
+                Config configuration = *config;
+                configuration.mConfigID = index;
+                index++;
+
+                mConfigSet.mSet.insert(configuration);
+            }
+        }
     }
 
     if (!isInitialized())