1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed blitting with a window clipper when the window region is empty

Fixes invisible menu buttons after alt-tabbing in Red Alert 2 (issue #262).
This commit is contained in:
narzoul 2024-03-23 17:49:08 +01:00
parent bc88dd2e92
commit f36a255ac9
2 changed files with 12 additions and 10 deletions

View File

@ -53,11 +53,16 @@ namespace
} }
DWORD rgnSize = GetRegionData(rgn, 0, nullptr); DWORD rgnSize = GetRegionData(rgn, 0, nullptr);
std::vector<unsigned char> rgnData(rgnSize); std::vector<unsigned char> rgnDataBuf(std::max<DWORD>(rgnSize, sizeof(RGNDATA)));
GetRegionData(rgn, rgnSize, reinterpret_cast<RGNDATA*>(rgnData.data())); RGNDATA* rgnData = reinterpret_cast<RGNDATA*>(rgnDataBuf.data());
GetRegionData(rgn, rgnSize, rgnData);
if (0 == rgnData->rdh.nCount)
{
rgnData->rdh.nCount = 1;
}
clipper->SetHWnd(&clipper, 0, nullptr); clipper->SetHWnd(&clipper, 0, nullptr);
clipper->SetClipList(&clipper, rgnData.empty() ? nullptr : reinterpret_cast<RGNDATA*>(rgnData.data()), 0); clipper->SetClipList(&clipper, rgnData, 0);
} }
HRESULT STDMETHODCALLTYPE GetHWnd(IDirectDrawClipper* This, HWND* lphWnd) HRESULT STDMETHODCALLTYPE GetHWnd(IDirectDrawClipper* This, HWND* lphWnd)
@ -199,13 +204,9 @@ namespace DDraw
void update() void update()
{ {
if (g_isInvalidated) for (auto& clipperData : g_clipperData)
{ {
g_isInvalidated = false; updateWindowClipList(*clipperData.first, clipperData.second);
for (auto& clipperData : g_clipperData)
{
updateWindowClipList(*clipperData.first, clipperData.second);
}
} }
} }

View File

@ -372,7 +372,8 @@ namespace
int WINAPI getRandomRgn(HDC hdc, HRGN hrgn, INT i) int WINAPI getRandomRgn(HDC hdc, HRGN hrgn, INT i)
{ {
return Gdi::Window::getRandomRgn(hdc, hrgn, i); LOG_FUNC("GetRandomRgn", hdc, hrgn, i);
return LOG_RESULT(Gdi::Window::getRandomRgn(hdc, hrgn, i));
} }
LONG getWindowLong(HWND hWnd, int nIndex, LONG getWindowLong(HWND hWnd, int nIndex,