Bug 1407149 - Add immediate context pointer check to d3d images. r=nical, a=ritu
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 10 Oct 2017 19:09:37 +0900
changeset 432442 a59416fd921a6ae31849f25238c2cb82bab3d94f
parent 432441 4522bc7343e6a569a032d95a5478192f1ca04f19
child 432443 c664599c64e8aedd257de4eb3d1ff8c9a15cafd7
push id7955
push userryanvm@gmail.com
push dateThu, 12 Oct 2017 18:26:39 +0000
treeherdermozilla-beta@c8d3b27528f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, ritu
bugs1407149
milestone57.0
Bug 1407149 - Add immediate context pointer check to d3d images. r=nical, a=ritu
gfx/layers/D3D11ShareHandleImage.cpp
gfx/layers/D3D11YCbCrImage.cpp
--- a/gfx/layers/D3D11ShareHandleImage.cpp
+++ b/gfx/layers/D3D11ShareHandleImage.cpp
@@ -123,16 +123,17 @@ D3D11ShareHandleImage::GetAsSourceSurfac
   if (FAILED(hr)) {
     NS_WARNING("Failed to create 2D staging texture.");
     return nullptr;
   }
 
   RefPtr<ID3D11DeviceContext> context;
   device->GetImmediateContext(getter_AddRefs(context));
   if (!context) {
+    gfxCriticalError() << "Failed to get immediate context.";
     return nullptr;
   }
 
   RefPtr<IDXGIKeyedMutex> mutex;
   hr = texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
 
   if (SUCCEEDED(hr) && mutex) {
     hr = mutex->AcquireSync(0, 2000);
--- a/gfx/layers/D3D11YCbCrImage.cpp
+++ b/gfx/layers/D3D11YCbCrImage.cpp
@@ -68,16 +68,20 @@ D3D11YCbCrImage::SetData(KnowsCompositor
     gfxCriticalError() << "Device used not marked as multithread-safe.";
     return false;
   }
 
   D3D11MTAutoEnter mtAutoEnter(mt.forget());
 
   RefPtr<ID3D11DeviceContext> ctx;
   allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
+  if (!ctx) {
+    gfxCriticalError() << "Failed to get immediate context.";
+    return false;
+  }
 
   AutoLockD3D11Texture lockY(textureY);
   AutoLockD3D11Texture lockCb(textureCb);
   AutoLockD3D11Texture lockCr(textureCr);
 
   ctx->UpdateSubresource(textureY,
                          0,
                          nullptr,
@@ -184,16 +188,20 @@ D3D11YCbCrImage::GetAsSourceSurface()
   desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
   desc.Usage = D3D11_USAGE_STAGING;
 
   dev->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexCb));
   dev->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexCr));
 
   RefPtr<ID3D11DeviceContext> ctx;
   dev->GetImmediateContext(getter_AddRefs(ctx));
+  if (!ctx) {
+    gfxCriticalError() << "Failed to get immediate context.";
+    return nullptr;
+  }
 
   {
     AutoLockD3D11Texture lockY(texY);
     AutoLockD3D11Texture lockCb(texCb);
     AutoLockD3D11Texture lockCr(texCr);
     ctx->CopyResource(softTexY, texY);
     ctx->CopyResource(softTexCb, texCb);
     ctx->CopyResource(softTexCr, texCr);