Bug 1865986 - Remove ScopedLockTexture r=gfx-reviewers,lsalzman

ScopedLockTexture is not used.

Differential Revision: https://phabricator.services.mozilla.com/D194330
This commit is contained in:
sotaro 2023-11-22 08:04:52 +00:00
parent bc4be37a4b
commit b0e7e3f3ea

View File

@ -147,83 +147,6 @@ SharedSurface_ANGLEShareHandle::ToSurfaceDescriptor() {
gfx::ColorRange::FULL, /* hasKeyedMutex */ !!mKeyedMutex));
}
class ScopedLockTexture final {
public:
explicit ScopedLockTexture(ID3D11Texture2D* texture, bool* succeeded)
: mIsLocked(false), mTexture(texture) {
MOZ_ASSERT(NS_IsMainThread(),
"Must be on the main thread to use d3d11 immediate context");
MOZ_ASSERT(mTexture);
MOZ_ASSERT(succeeded);
*succeeded = false;
HRESULT hr;
mTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex));
if (mMutex) {
hr = mMutex->AcquireSync(0, 10000);
if (hr == WAIT_TIMEOUT) {
MOZ_CRASH("GFX: ANGLE scoped lock timeout");
}
if (FAILED(hr)) {
NS_WARNING("Failed to lock the texture");
return;
}
}
RefPtr<ID3D11Device> device =
gfx::DeviceManagerDx::Get()->GetContentDevice();
if (!device) {
return;
}
device->GetImmediateContext(getter_AddRefs(mDeviceContext));
mTexture->GetDesc(&mDesc);
mDesc.BindFlags = 0;
mDesc.Usage = D3D11_USAGE_STAGING;
mDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
mDesc.MiscFlags = 0;
hr = device->CreateTexture2D(&mDesc, nullptr,
getter_AddRefs(mCopiedTexture));
if (FAILED(hr)) {
return;
}
mDeviceContext->CopyResource(mCopiedTexture, mTexture);
hr = mDeviceContext->Map(mCopiedTexture, 0, D3D11_MAP_READ, 0,
&mSubresource);
if (FAILED(hr)) {
return;
}
*succeeded = true;
mIsLocked = true;
}
~ScopedLockTexture() {
mDeviceContext->Unmap(mCopiedTexture, 0);
if (mMutex) {
HRESULT hr = mMutex->ReleaseSync(0);
if (FAILED(hr)) {
NS_WARNING("Failed to unlock the texture");
}
}
mIsLocked = false;
}
bool mIsLocked;
RefPtr<ID3D11Texture2D> mTexture;
RefPtr<ID3D11Texture2D> mCopiedTexture;
RefPtr<IDXGIKeyedMutex> mMutex;
RefPtr<ID3D11DeviceContext> mDeviceContext;
D3D11_TEXTURE2D_DESC mDesc;
D3D11_MAPPED_SUBRESOURCE mSubresource;
};
////////////////////////////////////////////////////////////////////////////////
// Factory