Skip to content

Commit

Permalink
Косметика кода.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Jul 30, 2024
1 parent 1d49e08 commit 0ba241f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 14 additions & 6 deletions Source/DX9Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,27 @@ HRESULT DumpDX9Surface(IDirect3DSurface9* pSurface, const wchar_t* filename)
HRESULT hr = S_OK;

D3DSURFACE_DESC desc = {};
if (FAILED(hr = pSurface->GetDesc(&desc))) {
hr = pSurface->GetDesc(&desc);
if (FAILED(hr)) {
return hr;
};

CComPtr<IDirect3DDevice9> pDevice;
if (FAILED(hr = pSurface->GetDevice(&pDevice))) {
hr = pSurface->GetDevice(&pDevice);
if (FAILED(hr)) {
return hr;
};

CComPtr<IDirect3DSurface9> pTarget;
if (FAILED(hr = pDevice->CreateRenderTarget(desc.Width, desc.Height, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &pTarget, nullptr))
|| FAILED(hr = pDevice->StretchRect(pSurface, nullptr, pTarget, nullptr, D3DTEXF_NONE))) {
hr = pDevice->CreateRenderTarget(desc.Width, desc.Height, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_NONE, 0, TRUE, &pTarget, nullptr);
if (FAILED(hr)) {
return hr;
}
};

hr = pDevice->StretchRect(pSurface, nullptr, pTarget, nullptr, D3DTEXF_NONE);
if (FAILED(hr)) {
return hr;
};

unsigned len = desc.Width * desc.Height * 4;
std::unique_ptr<BYTE[]> dib(new(std::nothrow) BYTE[sizeof(BITMAPINFOHEADER) + len]);
Expand All @@ -134,7 +141,8 @@ HRESULT DumpDX9Surface(IDirect3DSurface9* pSurface, const wchar_t* filename)
bih->biSizeImage = DIBSIZE(*bih);

D3DLOCKED_RECT r;
if (FAILED(hr = pTarget->LockRect(&r, nullptr, D3DLOCK_READONLY))) {
hr = pTarget->LockRect(&r, nullptr, D3DLOCK_READONLY);
if (FAILED(hr)) {
return hr;
}

Expand Down
6 changes: 4 additions & 2 deletions Source/DX9VideoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ HRESULT CDX9VideoProcessor::InitInternal(bool* pChangeDevice/* = nullptr*/)
*/

if (bTryToReset) {
bTryToReset = SUCCEEDED(hr = m_pD3DDevEx->ResetEx(&m_d3dpp, &m_DisplayMode));
hr = m_pD3DDevEx->ResetEx(&m_d3dpp, &m_DisplayMode);
bTryToReset = SUCCEEDED(hr);
DLog(L" => ResetEx(fullscreen) : {}", HR2Str(hr));
}

Expand Down Expand Up @@ -482,7 +483,8 @@ HRESULT CDX9VideoProcessor::InitInternal(bool* pChangeDevice/* = nullptr*/)
}

if (bTryToReset) {
bTryToReset = SUCCEEDED(hr = m_pD3DDevEx->ResetEx(&m_d3dpp, nullptr));
hr = m_pD3DDevEx->ResetEx(&m_d3dpp, nullptr);
bTryToReset = SUCCEEDED(hr);
DLog(L" => ResetEx() : {}", HR2Str(hr));
}

Expand Down

0 comments on commit 0ba241f

Please sign in to comment.