Notify the display of a lost device and mark all contexts lost.

TRAC #18606
Signed-off-by: Daniel Koch
Author: Shannon Woods

git-svn-id: https://angleproject.googlecode.com/svn/trunk@845 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libEGL/Display.cpp b/src/libEGL/Display.cpp
index 8ac20ab..a87f48f 100644
--- a/src/libEGL/Display.cpp
+++ b/src/libEGL/Display.cpp
@@ -88,6 +88,7 @@
     mMaxSwapInterval = 1;
     mSoftwareDevice = software;
     mDisplayId = displayId;
+    mDeviceLost = false;
 }
 
 Display::~Display()
@@ -304,7 +305,7 @@
     if (mDevice)
     {
         // If the device is lost, reset it first to prevent leaving the driver in an unstable state
-        if (isDeviceLost())
+        if (testDeviceLost())
         {
             resetDevice();
         }
@@ -459,7 +460,7 @@
     D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
 
     HRESULT result = D3D_OK;
-    bool lost = isDeviceLost();
+    bool lost = testDeviceLost();
     int attempts = 3;    
 
     while (lost && attempts > 0)
@@ -485,7 +486,7 @@
             }
         }
 
-        lost = isDeviceLost();
+        lost = testDeviceLost();
         attempts --;
     }
 
@@ -536,7 +537,7 @@
         return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
     }
 
-    if (isDeviceLost()) {
+    if (testDeviceLost()) {
         if (!restoreLostDevice())
             return EGL_NO_SURFACE;
     }
@@ -648,7 +649,7 @@
         return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
     }
 
-    if (isDeviceLost()) {
+    if (testDeviceLost()) {
         if (!restoreLostDevice())
             return EGL_NO_SURFACE;
     }
@@ -675,7 +676,7 @@
             return NULL;
         }
     }
-    else if (isDeviceLost())   // Lost device
+    else if (testDeviceLost())   // Lost device
     {
         if (!restoreLostDevice())
             return NULL;
@@ -685,6 +686,7 @@
 
     gl::Context *context = glCreateContext(config, shareContext);
     mContextSet.insert(context);
+    mDeviceLost = false;
 
     return context;
 }
@@ -724,6 +726,21 @@
     mContextSet.erase(context);
 }
 
+void Display::notifyDeviceLost()
+{
+    for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++)
+    {
+        (*context)->markContextLost();
+    }
+    mDeviceLost = true;
+    error(EGL_CONTEXT_LOST);
+}
+
+bool Display::isDeviceLost()
+{
+    return mDeviceLost;
+}
+
 bool Display::isInitialized() const
 {
     return mD3d9 != NULL && mConfigSet.size() > 0;
@@ -790,7 +807,7 @@
     return &mAdapterIdentifier;
 }
 
-bool Display::isDeviceLost()
+bool Display::testDeviceLost()
 {
     if (mDeviceEx)
     {