Bug 1407149 - Add immediate context pointer check to d3d images r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 10 Oct 2017 19:09:37 +0900
changeset 385301 42bcbbdc84f22bdd0960177066fad4382d3545bc
parent 385300 83b70c4e4ef92d28201624342098a24c1eacdca2
child 385302 36ab7e9b2f2f7b2520569203c30206d3e8313fc8
push id95961
push usersikeda@mozilla.com
push dateTue, 10 Oct 2017 10:09:57 +0000
treeherdermozilla-inbound@42bcbbdc84f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1407149
milestone58.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
Bug 1407149 - Add immediate context pointer check to d3d images r=nical
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);