Bug 1048099 - Check that the d3d9 wasn't lost before providing access to it in CompositorD3D9. r=Bas, a=sledru
authorNicolas Silva <nsilva@mozilla.com>
Wed, 06 Aug 2014 14:39:58 +0200
changeset 217513 d880059c952ecc82a9d1b3503788a711f96029ef
parent 217512 8bcaa2c7dab7df62ef08306059a8409077430736
child 217514 eb429fd7d9c2778fdcac6b254947c5e746b6b0db
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, sledru
bugs1048099
milestone33.0a2
Bug 1048099 - Check that the d3d9 wasn't lost before providing access to it in CompositorD3D9. r=Bas, a=sledru
gfx/layers/d3d9/CompositorD3D9.h
--- a/gfx/layers/d3d9/CompositorD3D9.h
+++ b/gfx/layers/d3d9/CompositorD3D9.h
@@ -84,17 +84,20 @@ public:
   virtual LayersBackend GetBackendType() const MOZ_OVERRIDE {
     return LayersBackend::LAYERS_D3D9;
   }
 
   virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; }
 
   IDirect3DDevice9* device() const
   {
-    return mDeviceManager
+    // If the reset counts don't match it means the device was lost and we are
+    // in the process of recreating a new one or will be soon.
+    // cf. comment in EnsureSwapChain.
+    return mDeviceManager && mDeviceResetCount == mDeviceManager->GetDeviceResetCount()
            ? mDeviceManager->device()
            : nullptr;
   }
 
   /**
    * Returns true if the Compositor is ready to go.
    * D3D9 devices can be awkward and there is a bunch of logic around
    * resetting/recreating devices and swap chains. That is handled by this method.