Bug 1521774 - Part 2: Ensure a device is available when attempting to create a device context. r=rhunt a=lizzard
authorBas Schouten <bschouten@mozilla.com>
Mon, 04 Mar 2019 10:33:19 +0100
changeset 516306 067b9599e2aa2f1ec5fdfb76b14753435fd65f93
parent 516305 cc6fc6015015707bdacbeaf206679df6ff78b6d2
child 516307 5e58a2a1528ccc45528f74abd64433889db4909b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt, lizzard
bugs1521774
milestone66.0
Bug 1521774 - Part 2: Ensure a device is available when attempting to create a device context. r=rhunt a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D21899
gfx/2d/Factory.cpp
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -866,18 +866,24 @@ RefPtr<ID2D1DeviceContext> Factory::GetD
   } else {
     ptr = &mOffMTDC;
   }
 
   if (*ptr) {
     return *ptr;
   }
 
+  RefPtr<ID2D1Device> device = GetD2D1Device();
+
+  if (!device) {
+    return nullptr;
+  }
+
   RefPtr<ID2D1DeviceContext> dc;
-  HRESULT hr = mD2D1Device->CreateDeviceContext(
+  HRESULT hr = device->CreateDeviceContext(
       D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS,
       getter_AddRefs(dc));
 
   if (FAILED(hr)) {
     gfxCriticalError() << "Failed to create global device context";
     return nullptr;
   }