mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
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:
parent
bc4be37a4b
commit
b0e7e3f3ea
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user