diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 9389d24680be..05a56932262a 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -472,6 +472,9 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, } srView = static_cast(aSurface)->GetSRView(); + if (!srView) { + return; + } EnsureViews(); @@ -759,6 +762,11 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface, mDevice->Draw(4, 0); + RefPtr srView = static_cast(aSurface)->GetSRView(); + if (!srView) { + return; + } + mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()-> SetFloatVector(ShaderConstantRectD3D10(-1.0f + ((aDest.x / mSize.width) * 2.0f), 1.0f - (aDest.y / mSize.height * 2.0f), diff --git a/gfx/2d/SourceSurfaceD2DTarget.cpp b/gfx/2d/SourceSurfaceD2DTarget.cpp index 15baac42d9c8..e0009e73bb14 100644 --- a/gfx/2d/SourceSurfaceD2DTarget.cpp +++ b/gfx/2d/SourceSurfaceD2DTarget.cpp @@ -96,6 +96,11 @@ SourceSurfaceD2DTarget::GetSRView() return mSRView; } + if (!Factory::GetDirect3D10Device()) { + gfxCriticalError() << "Invalid D3D10 device in D2D target surface"; + return nullptr; + } + HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView)); if (FAILED(hr)) { diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 4eb499764e8d..1470fc9e543b 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -370,6 +370,9 @@ TextureClientD3D11::Unlock() if (NS_IsMainThread() && mReadbackSink && mTexture10) { ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + if (!device) { + return; + } D3D10_TEXTURE2D_DESC desc; mTexture10->GetDesc(&desc); @@ -588,6 +591,9 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag } } else { ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + if (!device) { + return false; + } CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1, @@ -1235,6 +1241,9 @@ SyncObjectD3D11::FinalizeFrame() if (!mD3D10Texture && mD3D10SyncedTextures.size()) { ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + if (!device) { + return; + } hr = device->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), (void**)(ID3D10Texture2D**)getter_AddRefs(mD3D10Texture)); @@ -1305,6 +1314,9 @@ SyncObjectD3D11::FinalizeFrame() box.back = box.bottom = box.right = 1; ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + if (!device) { + return; + } for (auto iter = mD3D10SyncedTextures.begin(); iter != mD3D10SyncedTextures.end(); iter++) { device->CopySubresourceRegion(mD3D10Texture, 0, 0, 0, 0, *iter, 0, &box);