Revert pending surface destruction (part of revision 632).
TRAC #16271
Signed-off-by: Daniel Koch
Author: Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@656 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/common/version.h b/src/common/version.h
index 8e3de0a..ae6342a 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 0
 #define MINOR_VERSION 0
 #define BUILD_VERSION 0
-#define BUILD_REVISION 655
+#define BUILD_REVISION 656
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/libEGL/Display.cpp b/src/libEGL/Display.cpp
index 68eef76..4dcaa0a 100644
--- a/src/libEGL/Display.cpp
+++ b/src/libEGL/Display.cpp
@@ -603,15 +603,8 @@
 
 void Display::destroySurface(egl::Surface *surface)
 {
-    if (surface == egl::getCurrentDrawSurface() || surface == egl::getCurrentReadSurface())
-    {
-        surface->setPendingDestroy();
-    }
-    else
-    {
-        delete surface;
-        mSurfaceSet.erase(surface);
-    }
+    delete surface;
+    mSurfaceSet.erase(surface);
 }
 
 void Display::destroyContext(gl::Context *context)
@@ -645,7 +638,7 @@
 
 bool Display::isValidSurface(egl::Surface *surface)
 {
-    return mSurfaceSet.find(surface) != mSurfaceSet.end() && !surface->isPendingDestroy();
+    return mSurfaceSet.find(surface) != mSurfaceSet.end();
 }
 
 bool Display::hasExistingWindowSurface(HWND window)
diff --git a/src/libEGL/Surface.cpp b/src/libEGL/Surface.cpp
index b4f6136..982ee03 100644
--- a/src/libEGL/Surface.cpp
+++ b/src/libEGL/Surface.cpp
@@ -38,8 +38,6 @@
     mSwapInterval = -1;
     setSwapInterval(1);
 
-    mIsPendingDestroy = false;
-
     subclassWindow();
 }
 
@@ -60,8 +58,6 @@
     mSwapBehavior = EGL_BUFFER_PRESERVED;
     mSwapInterval = -1;
     setSwapInterval(1);
-
-    mIsPendingDestroy = false;
 }
 
 Surface::~Surface()
@@ -324,7 +320,6 @@
     return D3DPRESENT_INTERVAL_DEFAULT;
 }
 
-
 bool Surface::swap()
 {
     if (mSwapChain)
@@ -430,13 +425,4 @@
 {
     return mConfig->mRenderTargetFormat;
 }
-
-void Surface::setPendingDestroy() {
-    mIsPendingDestroy = true;
-}
-
-bool Surface::isPendingDestroy() const {
-    return mIsPendingDestroy;
-}
-
 }
diff --git a/src/libEGL/Surface.h b/src/libEGL/Surface.h
index bbff703..99c4b67 100644
--- a/src/libEGL/Surface.h
+++ b/src/libEGL/Surface.h
@@ -61,9 +61,6 @@
     virtual void setBoundTexture(gl::Texture2D *texture);
     virtual gl::Texture2D *getBoundTexture() const;
 
-    void setPendingDestroy();
-    bool isPendingDestroy() const;
-
 private:
     DISALLOW_COPY_AND_ASSIGN(Surface);
 
@@ -74,7 +71,6 @@
     IDirect3DTexture9* mOffscreenTexture;
 
     HANDLE mShareHandle;
-    bool mIsPendingDestroy;
 
     void subclassWindow();
     void unsubclassWindow();
diff --git a/src/libEGL/libEGL.cpp b/src/libEGL/libEGL.cpp
index 418f11a..8689a4e 100644
--- a/src/libEGL/libEGL.cpp
+++ b/src/libEGL/libEGL.cpp
@@ -936,18 +936,6 @@
 
         glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
 
-        // If the previous surfaces are still current, this might just flag
-        // them as pending destruction again, deferring destruction to a future
-        // eglMakeCurrent or eglTerminate call.
-        if (previousDraw && previousDraw->isPendingDestroy())
-        {
-            eglDestroySurface(dpy, previousDraw);
-        }
-        if (previousRead && previousRead != previousDraw && previousRead->isPendingDestroy())
-        {
-            eglDestroySurface(dpy, previousRead);
-        }
-
         return success(EGL_TRUE);
     }
     catch(std::bad_alloc&)