mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mt->Enter();
|
D3D11MTAutoEnter mtAutoEnter(mt.forget());
|
||||||
|
|
||||||
RefPtr<ID3D11DeviceContext> ctx;
|
RefPtr<ID3D11DeviceContext> ctx;
|
||||||
allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
|
allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
|
||||||
|
|
@ -99,9 +99,7 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
|
||||||
aData.mCbCrStride,
|
aData.mCbCrStride,
|
||||||
aData.mCbCrStride * aData.mCbCrSize.height);
|
aData.mCbCrStride * aData.mCbCrSize.height);
|
||||||
|
|
||||||
mt->Leave();
|
return true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IntSize
|
IntSize
|
||||||
|
|
@ -162,21 +160,7 @@ D3D11YCbCrImage::GetAsSourceSurface()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
class D3D11MTAutoEnter
|
D3D11MTAutoEnter mtAutoEnter(mt.forget());
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit D3D11MTAutoEnter(already_AddRefed<ID3D10Multithread> aMT)
|
|
||||||
: mMT(aMT)
|
|
||||||
{
|
|
||||||
mMT->Enter();
|
|
||||||
}
|
|
||||||
~D3D11MTAutoEnter()
|
|
||||||
{
|
|
||||||
mMT->Leave();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
RefPtr<ID3D10Multithread> mMT;
|
|
||||||
} mtAutoEnter(mt.forget());
|
|
||||||
|
|
||||||
texY->GetDesc(&desc);
|
texY->GetDesc(&desc);
|
||||||
desc.BindFlags = 0;
|
desc.BindFlags = 0;
|
||||||
|
|
|
||||||
|
|
@ -201,11 +201,10 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<ID3D11Device> device =
|
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetContentDevice();
|
||||||
gfx::DeviceManagerDx::Get()->GetContentDevice();
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
device =
|
device = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
|
||||||
gfx::DeviceManagerDx::Get()->GetCompositorDevice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LayersBackend backend = aForwarder->GetCompositorBackendType();
|
LayersBackend backend = aForwarder->GetCompositorBackendType();
|
||||||
|
|
@ -274,7 +273,7 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
|
||||||
AutoLockD3D11Texture lockCr(textureCr);
|
AutoLockD3D11Texture lockCr(textureCr);
|
||||||
AutoLockD3D11Texture lockCb(textureCb);
|
AutoLockD3D11Texture lockCb(textureCb);
|
||||||
|
|
||||||
mt->Enter();
|
D3D11MTAutoEnter mtAutoEnter(mt.forget());
|
||||||
|
|
||||||
RefPtr<ID3D11DeviceContext> ctx;
|
RefPtr<ID3D11DeviceContext> ctx;
|
||||||
device->GetImmediateContext((ID3D11DeviceContext**)getter_AddRefs(ctx));
|
device->GetImmediateContext((ID3D11DeviceContext**)getter_AddRefs(ctx));
|
||||||
|
|
@ -290,8 +289,6 @@ IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
|
||||||
box.bottom = mData.mCbCrSize.height;
|
box.bottom = mData.mCbCrSize.height;
|
||||||
ctx->UpdateSubresource(textureCb, 0, &box, mData.mCbChannel, mData.mCbCrStride, 0);
|
ctx->UpdateSubresource(textureCb, 0, &box, mData.mCbChannel, mData.mCbCrStride, 0);
|
||||||
ctx->UpdateSubresource(textureCr, 0, &box, mData.mCrChannel, mData.mCbCrStride, 0);
|
ctx->UpdateSubresource(textureCr, 0, &box, mData.mCrChannel, mData.mCbCrStride, 0);
|
||||||
|
|
||||||
mt->Leave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mTextureClient = TextureClient::CreateWithData(
|
mTextureClient = TextureClient::CreateWithData(
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,20 @@ private:
|
||||||
RefPtr<IDXGIKeyedMutex> mMutex;
|
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