mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
Issue #2393 - Part 5 - Extract D3D11MTAutoEnter and reuse
This commit is contained in:
parent
6807675123
commit
04f124b105
3 changed files with 21 additions and 26 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue