Bug 604647: Never create swap chains while the device is lost. r=jrmuizel a=blocking-final
authorBas Schouten <bschouten@mozilla.com>
Mon, 20 Dec 2010 22:35:28 +0000
changeset 59529 b71a05bcd2f5a7ae95e442fb484fb1715209c267
parent 59528 34f521036d9dc49a0fcdcfe8a711c19009915a72
child 59530 f8a49ff98d77a59a19e8a38be75b7cfee63212d6
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel, blocking-final
bugs604647
milestone2.0b9pre
Bug 604647: Never create swap chains while the device is lost. r=jrmuizel a=blocking-final
gfx/layers/d3d9/DeviceManagerD3D9.cpp
--- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp
+++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp
@@ -444,16 +444,25 @@ DeviceManagerD3D9::SetupRenderState()
   mDevice->SetSamplerState(2, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
 }
 
 already_AddRefed<SwapChainD3D9>
 DeviceManagerD3D9::CreateSwapChain(HWND hWnd)
 {
   nsRefPtr<SwapChainD3D9> swapChain = new SwapChainD3D9(this);
   
+  // See bug 604647. This line means that if we create a window while the
+  // device is lost LayerManager initialization will fail, this window
+  // will be permanently unaccelerated. This should be a rare situation
+  // though and the need for a low-risk fix for this bug outweighs the
+  // downside.
+  if (!VerifyReadyForRendering()) {
+    return nsnull;
+  }
+
   if (!swapChain->Init(hWnd)) {
     return nsnull;
   }
 
   return swapChain.forget();
 }
 
 void