зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1223270: P1. Extract AutoLockD3D11Texture. r=mattwoodrow
Will be used in future code. MozReview-Commit-ID: 5ivawIIt2bu --HG-- extra : rebase_source : 1c640796907cfce1ce0c7939d0bef64f04b6b0d5
This commit is contained in:
Родитель
913aaad107
Коммит
e8d34824cb
|
@ -31,38 +31,6 @@ IMFYCbCrImage::~IMFYCbCrImage()
|
|||
}
|
||||
}
|
||||
|
||||
struct AutoLockTexture
|
||||
{
|
||||
explicit AutoLockTexture(ID3D11Texture2D* aTexture)
|
||||
{
|
||||
aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex));
|
||||
if (!mMutex) {
|
||||
return;
|
||||
}
|
||||
HRESULT hr = mMutex->AcquireSync(0, 10000);
|
||||
if (hr == WAIT_TIMEOUT) {
|
||||
MOZ_CRASH("GFX: IMFYCbCrImage timeout");
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to lock the texture");
|
||||
}
|
||||
}
|
||||
|
||||
~AutoLockTexture()
|
||||
{
|
||||
if (!mMutex) {
|
||||
return;
|
||||
}
|
||||
HRESULT hr = mMutex->ReleaseSync(0);
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to unlock the texture");
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<IDXGIKeyedMutex> mMutex;
|
||||
};
|
||||
|
||||
static already_AddRefed<IDirect3DTexture9>
|
||||
InitTextures(IDirect3DDevice9* aDevice,
|
||||
const IntSize &aSize,
|
||||
|
@ -198,9 +166,9 @@ IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize)
|
|||
// required but were added for extra security.
|
||||
|
||||
{
|
||||
AutoLockTexture lockY(textureY);
|
||||
AutoLockTexture lockCr(textureCr);
|
||||
AutoLockTexture lockCb(textureCb);
|
||||
AutoLockD3D11Texture lockY(textureY);
|
||||
AutoLockD3D11Texture lockCr(textureCr);
|
||||
AutoLockD3D11Texture lockCb(textureCb);
|
||||
|
||||
mt->Enter();
|
||||
|
||||
|
|
|
@ -1441,5 +1441,32 @@ GetMaxTextureSizeFromDevice(ID3D11Device* aDevice)
|
|||
return GetMaxTextureSizeForFeatureLevel(aDevice->GetFeatureLevel());
|
||||
}
|
||||
|
||||
AutoLockD3D11Texture::AutoLockD3D11Texture(ID3D11Texture2D* aTexture)
|
||||
{
|
||||
aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex));
|
||||
if (!mMutex) {
|
||||
return;
|
||||
}
|
||||
HRESULT hr = mMutex->AcquireSync(0, 10000);
|
||||
if (hr == WAIT_TIMEOUT) {
|
||||
MOZ_CRASH("GFX: IMFYCbCrImage timeout");
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to lock the texture");
|
||||
}
|
||||
}
|
||||
|
||||
AutoLockD3D11Texture::~AutoLockD3D11Texture()
|
||||
{
|
||||
if (!mMutex) {
|
||||
return;
|
||||
}
|
||||
HRESULT hr = mMutex->ReleaseSync(0);
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to unlock the texture");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -483,6 +483,16 @@ inline uint32_t GetMaxTextureSizeForFeatureLevel(D3D_FEATURE_LEVEL aFeatureLevel
|
|||
|
||||
uint32_t GetMaxTextureSizeFromDevice(ID3D11Device* aDevice);
|
||||
|
||||
class AutoLockD3D11Texture
|
||||
{
|
||||
public:
|
||||
explicit AutoLockD3D11Texture(ID3D11Texture2D* aTexture);
|
||||
~AutoLockD3D11Texture();
|
||||
|
||||
private:
|
||||
RefPtr<IDXGIKeyedMutex> mMutex;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче