diff --git a/DDrawCompat/D3dDdi/KernelModeThunks.cpp b/DDrawCompat/D3dDdi/KernelModeThunks.cpp index fe5bd2c..fec9485 100644 --- a/DDrawCompat/D3dDdi/KernelModeThunks.cpp +++ b/DDrawCompat/D3dDdi/KernelModeThunks.cpp @@ -251,25 +251,7 @@ namespace void waitForVerticalBlank() { - D3DKMT_WAITFORVERTICALBLANKEVENT data = {}; - - { - Compat::ScopedSrwLockShared lock(g_lastOpenAdapterInfoSrwLock); - data.hAdapter = g_lastOpenAdapterInfo.adapter; - data.VidPnSourceId = g_lastOpenAdapterInfo.vidPnSourceId; - } - - if (!data.hAdapter) - { - updateGdiAdapterInfo(); - data.hAdapter = g_gdiAdapterInfo.adapter; - data.VidPnSourceId = g_gdiAdapterInfo.vidPnSourceId; - } - - if (!data.hAdapter || FAILED(D3DKMTWaitForVerticalBlankEvent(&data))) - { - Sleep(16); - } + Sleep(16); } } diff --git a/DDrawCompat/Gdi/User32WndProcs.cpp b/DDrawCompat/Gdi/User32WndProcs.cpp index 236b897..436ccd9 100644 --- a/DDrawCompat/Gdi/User32WndProcs.cpp +++ b/DDrawCompat/Gdi/User32WndProcs.cpp @@ -1,5 +1,8 @@ +#include + #include #include +#include #include #include #include @@ -156,8 +159,20 @@ namespace } break; + case WM_DWMCOMPOSITIONCHANGED: + { + BOOL isEnabled = FALSE; + HRESULT result = DwmIsCompositionEnabled(&isEnabled); + LOG_DEBUG << "DwmIsCompositionEnabled: " << Compat::hex(result) << " " << isEnabled; + break; + } + case WM_ERASEBKGND: { + Gdi::Region updateRegion; + GetUpdateRgn(hwnd, updateRegion, FALSE); + LOG_DEBUG << "updateRegion: " << static_cast(updateRegion); + HBRUSH brush = reinterpret_cast(GetClassLong(hwnd, GCL_HBRBACKGROUND)); if (!brush) { diff --git a/DDrawCompat/Gdi/Window.cpp b/DDrawCompat/Gdi/Window.cpp index bd1c184..f860d41 100644 --- a/DDrawCompat/Gdi/Window.cpp +++ b/DDrawCompat/Gdi/Window.cpp @@ -100,6 +100,9 @@ namespace void updatePosition(Window& window, const RECT& oldWindowRect, const RECT& oldClientRect, const Gdi::Region& oldVisibleRegion, Gdi::Region& invalidatedRegion) { + LOG_FUNC("Window::updatePosition", window.hwnd, oldWindowRect, oldClientRect, + static_cast(oldVisibleRegion), static_cast(invalidatedRegion)); + const bool isClientOriginChanged = window.clientRect.left - window.windowRect.left != oldClientRect.left - oldWindowRect.left || window.clientRect.top - window.windowRect.top != oldClientRect.top - oldWindowRect.top; @@ -155,6 +158,8 @@ namespace GetUpdateRgn(window.hwnd, updateRegion, FALSE); updateRegion.offset(window.clientRect.left, window.clientRect.top); preservedRegion -= updateRegion; + LOG_DEBUG << "updateRegion: " << static_cast(updateRegion); + LOG_DEBUG << "preservedRegion: " << static_cast(preservedRegion); } bool isCopied = false; @@ -170,14 +175,18 @@ namespace if (isCopied) { invalidatedRegion |= preservedRegion; + LOG_DEBUG << "isCopied invalidatedRegion: " << static_cast(invalidatedRegion); } } + LOG_DEBUG << "window.visibleRegion: " << static_cast(window.visibleRegion); + LOG_DEBUG << "old window.invalidatedRegion: " << static_cast(window.invalidatedRegion); window.invalidatedRegion = window.visibleRegion - preservedRegion; if (!window.invalidatedRegion.isEmpty()) { window.invalidatedRegion.offset(-window.clientRect.left, -window.clientRect.top); } + LOG_DEBUG << "new window.invalidatedRegion: " << static_cast(window.invalidatedRegion); } BOOL CALLBACK updateWindow(HWND hwnd, LPARAM lParam) @@ -375,11 +384,18 @@ namespace Gdi } isInvalidated = !it->second.invalidatedRegion.isEmpty(); + LOG_DEBUG << "isInvalidated: " << isInvalidated << " " << static_cast(it->second.invalidatedRegion); + Gdi::Region updateRegion; + GetUpdateRgn(hwnd, updateRegion, FALSE); + LOG_DEBUG << "updateRegion: " << static_cast(updateRegion); + if (isInvalidated) { RedrawWindow(hwnd, nullptr, it->second.invalidatedRegion, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); - it->second.invalidatedRegion = nullptr; + it->second.invalidatedRegion.clear(); + GetUpdateRgn(hwnd, updateRegion, FALSE); + LOG_DEBUG << "updated updateRegion: " << static_cast(updateRegion); } }