Create a D3D11 content device even if D2D is blocked. (bug 1217665 part 11, r=jrmuizel)
authorDavid Anderson <danderson@mozilla.com>
Wed, 02 Dec 2015 11:31:18 -0800
changeset 309458 65f787c9fd4e5ed7013c32f26ae3f6dfcea88bd8
parent 309457 7c063ffd2e22434ae4ed66fd391c59e0650d0976
child 309459 e3ae43ee51fa19f4ab685e5dfd8d1e051d011566
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1217665
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Create a D3D11 content device even if D2D is blocked. (bug 1217665 part 11, r=jrmuizel)
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -2303,20 +2303,20 @@ gfxWindowsPlatform::AttemptD3D11ContentD
 
     DebugOnly<bool> ok = ContentAdapterIsParentAdapter(mD3D11ContentDevice);
     MOZ_ASSERT(ok);
   }
 
   mD3D11ContentDevice->SetExceptionMode(0);
 
   RefPtr<ID3D10Multithread> multi;
-  mD3D11ContentDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
-  multi->SetMultithreadProtected(TRUE);
-
-  Factory::SetDirect3D11Device(mD3D11ContentDevice);
+  hr = mD3D11ContentDevice->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
+  if (SUCCEEDED(hr) && multi) {
+    multi->SetMultithreadProtected(TRUE);
+  }
   return FeatureStatus::Available;
 }
 
 FeatureStatus
 gfxWindowsPlatform::AttemptD3D11ImageBridgeDeviceCreation()
 {
   HRESULT hr = E_INVALIDARG;
   MOZ_SEH_TRY{
@@ -2374,16 +2374,18 @@ gfxWindowsPlatform::InitializeDevices()
   // attempts to use D3D11 features.
   if (gfxPrefs::LayersPreferD3D9()) {
     mD3D11Status = FeatureStatus::Disabled;
     return;
   }
 
   // First, initialize D3D11. If this succeeds we attempt to use Direct2D.
   InitializeD3D11();
+
+  // Initialize Direct2D.
   if (mD3D11Status == FeatureStatus::Available) {
     InitializeD2D();
   }
 
   // Usually we want D2D in order to use DWrite, but if the users have it
   // forced, we'll let them have it, as unsupported configuration.
   if (gfxPrefs::DirectWriteFontRenderingForceEnabled() &&
       IsFeatureStatusFailure(mD2DStatus) &&
@@ -2495,16 +2497,21 @@ gfxWindowsPlatform::InitializeD3D11()
 
   if (CanUseD3D11ImageBridge()) {
     if (AttemptD3D11ImageBridgeDeviceCreation() == FeatureStatus::Crashed) {
       DisableD3D11AfterCrash();
       return;
     }
   }
 
+  if (AttemptD3D11ContentDeviceCreation() == FeatureStatus::Crashed) {
+    DisableD3D11AfterCrash();
+    return;
+  }
+
   // We leak these everywhere and we need them our entire runtime anyway, let's
   // leak it here as well. We keep the pointer to sD3D11CreateDeviceFn around
   // as well for D2D1 and device resets.
   d3d11Module.disown();
 }
 
 void
 gfxWindowsPlatform::DisableD3D11AfterCrash()
@@ -2637,25 +2644,24 @@ gfxWindowsPlatform::InitializeD2D1()
 {
   ScopedGfxFeatureReporter d2d1_1("D2D1.1");
 
   mD2D1Status = CheckD2D1Support();
   if (IsFeatureStatusFailure(mD2D1Status)) {
     return;
   }
 
-  mD2D1Status = AttemptD3D11ContentDeviceCreation();
-  if (IsFeatureStatusFailure(mD2D1Status)) {
-    if (mD2D1Status == FeatureStatus::Crashed) {
-      DisableD3D11AfterCrash();
-    }
+  if (!mD3D11ContentDevice) {
+    mD2D1Status = FeatureStatus::Failed;
     return;
   }
 
-  MOZ_ASSERT(mD2D1Status == FeatureStatus::Available);
+  mD2D1Status = FeatureStatus::Available;
+  Factory::SetDirect3D11Device(mD3D11ContentDevice);
+
   d2d1_1.SetSuccessful();
 }
 
 bool
 gfxWindowsPlatform::CreateD3D11DecoderDeviceHelper(
   IDXGIAdapter1* aAdapter, RefPtr<ID3D11Device>& aDevice, HRESULT& aResOut)
 {
   MOZ_SEH_TRY{