1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #2393 - Part 5 - Extract D3D11MTAutoEnter and reuse

This commit is contained in:
trav90
2023-11-28 14:44:29 -06:00
committed by roytam1
parent 6807675123
commit 04f124b105
3 changed files with 21 additions and 26 deletions
+3 -19
View File
@@ -71,7 +71,7 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
return false;
}
mt->Enter();
D3D11MTAutoEnter mtAutoEnter(mt.forget());
RefPtr<ID3D11DeviceContext> ctx;
allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
@@ -99,9 +99,7 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
aData.mCbCrStride,
aData.mCbCrStride * aData.mCbCrSize.height);
mt->Leave();
return true;
return true;
}
IntSize
@@ -162,21 +160,7 @@ D3D11YCbCrImage::GetAsSourceSurface()
return nullptr;
}
class D3D11MTAutoEnter
{
public:
explicit D3D11MTAutoEnter(already_AddRefed<ID3D10Multithread> aMT)
: mMT(aMT)
{
mMT->Enter();
}
~D3D11MTAutoEnter()
{
mMT->Leave();
}
private:
RefPtr<ID3D10Multithread> mMT;
} mtAutoEnter(mt.forget());
D3D11MTAutoEnter mtAutoEnter(mt.forget());
texY->GetDesc(&desc);
desc.BindFlags = 0;
+4 -7
View File
@@ -201,11 +201,10 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
return mTextureClient;
}
RefPtr<ID3D11Device> device =
gfx::DeviceManagerDx::Get()->GetContentDevice();
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetContentDevice();
if (!device) {
device =
gfx::DeviceManagerDx::Get()->GetCompositorDevice();
device = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
}
LayersBackend backend = aForwarder->GetCompositorBackendType();
@@ -274,7 +273,7 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
AutoLockD3D11Texture lockCr(textureCr);
AutoLockD3D11Texture lockCb(textureCb);
mt->Enter();
D3D11MTAutoEnter mtAutoEnter(mt.forget());
RefPtr<ID3D11DeviceContext> ctx;
device->GetImmediateContext((ID3D11DeviceContext**)getter_AddRefs(ctx));
@@ -290,8 +289,6 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
box.bottom = mData.mCbCrSize.height;
ctx->UpdateSubresource(textureCb, 0, &box, mData.mCbChannel, mData.mCbCrStride, 0);
ctx->UpdateSubresource(textureCr, 0, &box, mData.mCrChannel, mData.mCbCrStride, 0);
mt->Leave();
}
mTextureClient = TextureClient::CreateWithData(
+14
View File
@@ -461,6 +461,20 @@ private:
RefPtr<IDXGIKeyedMutex> mMutex;
};
class D3D11MTAutoEnter
{
public:
explicit D3D11MTAutoEnter(already_AddRefed<ID3D10Multithread> aMT)
: mMT(aMT)
{
mMT->Enter();
}
~D3D11MTAutoEnter() { mMT->Leave(); }
private:
RefPtr<ID3D10Multithread> mMT;
};
}
}