Bug 1399247: Limit the scope of D3D11MTAutoEnter in order to avoid holding it while grabbing the D2D lock. r=mchang
MozReview-Commit-ID: KFKEIZBOIiy
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -484,36 +484,39 @@ D3D11TextureData::Create(IntSize aSize,
uploadDataPtr = &uploadData;
}
// See bug 1397040
RefPtr<ID3D10Multithread> mt;
device->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
- D3D11MTAutoEnter lock(mt.forget());
+ RefPtr<ID3D11Texture2D> texture11;
- RefPtr<ID3D11Texture2D> texture11;
- HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
+ {
+ D3D11MTAutoEnter lock(mt.forget());
+
+ HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
- if (FAILED(hr) || !texture11) {
- gfxCriticalNote << "[D3D11] 2 CreateTexture2D failure Size: " << aSize
- << "texture11: " << texture11 << " Code: " << gfx::hexa(hr);
- return nullptr;
- }
+ if (FAILED(hr) || !texture11) {
+ gfxCriticalNote << "[D3D11] 2 CreateTexture2D failure Size: " << aSize
+ << "texture11: " << texture11 << " Code: " << gfx::hexa(hr);
+ return nullptr;
+ }
- if (srcSurf && DeviceManagerDx::Get()->HasCrashyInitData()) {
- D3D11_BOX box;
- box.front = box.top = box.left = 0;
- box.back = 1;
- box.right = aSize.width;
- box.bottom = aSize.height;
- RefPtr<ID3D11DeviceContext> ctx;
- device->GetImmediateContext(getter_AddRefs(ctx));
- ctx->UpdateSubresource(texture11, 0, &box, sourceMap.mData, sourceMap.mStride, 0);
+ if (srcSurf && DeviceManagerDx::Get()->HasCrashyInitData()) {
+ D3D11_BOX box;
+ box.front = box.top = box.left = 0;
+ box.back = 1;
+ box.right = aSize.width;
+ box.bottom = aSize.height;
+ RefPtr<ID3D11DeviceContext> ctx;
+ device->GetImmediateContext(getter_AddRefs(ctx));
+ ctx->UpdateSubresource(texture11, 0, &box, sourceMap.mData, sourceMap.mStride, 0);
+ }
}
if (srcSurf) {
srcSurf->Unmap();
}
// If we created the texture with a keyed mutex, then we expect all operations
// on it to be synchronized using it. If we did an initial upload using aSurface