From b65f98f0e3659ca47a7f7b13ac1cc3c0a3dd264e Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 27 Aug 2016 20:35:10 +0200 Subject: [PATCH] Moved GDI parts to Gdi namespace and subdirectory --- DDrawCompat/CompatActivateAppHandler.cpp | 8 +- DDrawCompat/CompatDirectDrawSurface.cpp | 4 +- DDrawCompat/CompatGdiCaret.h | 7 - DDrawCompat/CompatGdiDc.h | 12 -- DDrawCompat/CompatGdiDcCache.h | 27 --- DDrawCompat/CompatGdiDcFunctions.h | 6 - DDrawCompat/CompatGdiPaintHandlers.h | 7 - DDrawCompat/CompatGdiScrollFunctions.h | 7 - DDrawCompat/CompatGdiWinProc.h | 7 - DDrawCompat/DDrawCompat.vcxproj | 44 ++--- DDrawCompat/DDrawCompat.vcxproj.filters | 126 ++++++------ DDrawCompat/DllMain.cpp | 6 +- .../{CompatGdiCaret.cpp => Gdi/Caret.cpp} | 55 +++--- DDrawCompat/Gdi/Caret.h | 10 + DDrawCompat/{CompatGdiDc.cpp => Gdi/Dc.cpp} | 127 +++++++------ DDrawCompat/Gdi/Dc.h | 15 ++ .../{CompatGdiDcCache.cpp => Gdi/DcCache.cpp} | 161 ++++++++-------- DDrawCompat/Gdi/DcCache.h | 30 +++ .../DcFunctions.cpp} | 179 +++++++++--------- DDrawCompat/Gdi/DcFunctions.h | 9 + DDrawCompat/{CompatGdi.cpp => Gdi/Gdi.cpp} | 44 ++--- DDrawCompat/{CompatGdi.h => Gdi/Gdi.h} | 2 +- .../PaintHandlers.cpp} | 101 +++++----- DDrawCompat/Gdi/PaintHandlers.h | 10 + .../ScrollBar.cpp} | 6 +- .../{CompatGdiScrollBar.h => Gdi/ScrollBar.h} | 2 +- .../ScrollFunctions.cpp} | 37 ++-- DDrawCompat/Gdi/ScrollFunctions.h | 14 ++ .../TitleBar.cpp} | 6 +- .../{CompatGdiTitleBar.h => Gdi/TitleBar.h} | 2 +- .../{CompatGdiWinProc.cpp => Gdi/WinProc.cpp} | 65 ++++--- DDrawCompat/Gdi/WinProc.h | 10 + DDrawCompat/RealPrimarySurface.cpp | 4 +- 33 files changed, 601 insertions(+), 549 deletions(-) delete mode 100644 DDrawCompat/CompatGdiCaret.h delete mode 100644 DDrawCompat/CompatGdiDc.h delete mode 100644 DDrawCompat/CompatGdiDcCache.h delete mode 100644 DDrawCompat/CompatGdiDcFunctions.h delete mode 100644 DDrawCompat/CompatGdiPaintHandlers.h delete mode 100644 DDrawCompat/CompatGdiScrollFunctions.h delete mode 100644 DDrawCompat/CompatGdiWinProc.h rename DDrawCompat/{CompatGdiCaret.cpp => Gdi/Caret.cpp} (69%) create mode 100644 DDrawCompat/Gdi/Caret.h rename DDrawCompat/{CompatGdiDc.cpp => Gdi/Dc.cpp} (69%) create mode 100644 DDrawCompat/Gdi/Dc.h rename DDrawCompat/{CompatGdiDcCache.cpp => Gdi/DcCache.cpp} (57%) create mode 100644 DDrawCompat/Gdi/DcCache.h rename DDrawCompat/{CompatGdiDcFunctions.cpp => Gdi/DcFunctions.cpp} (57%) create mode 100644 DDrawCompat/Gdi/DcFunctions.h rename DDrawCompat/{CompatGdi.cpp => Gdi/Gdi.cpp} (84%) rename DDrawCompat/{CompatGdi.h => Gdi/Gdi.h} (96%) rename DDrawCompat/{CompatGdiPaintHandlers.cpp => Gdi/PaintHandlers.cpp} (77%) create mode 100644 DDrawCompat/Gdi/PaintHandlers.h rename DDrawCompat/{CompatGdiScrollBar.cpp => Gdi/ScrollBar.cpp} (98%) rename DDrawCompat/{CompatGdiScrollBar.h => Gdi/ScrollBar.h} (97%) rename DDrawCompat/{CompatGdiScrollFunctions.cpp => Gdi/ScrollFunctions.cpp} (64%) create mode 100644 DDrawCompat/Gdi/ScrollFunctions.h rename DDrawCompat/{CompatGdiTitleBar.cpp => Gdi/TitleBar.cpp} (98%) rename DDrawCompat/{CompatGdiTitleBar.h => Gdi/TitleBar.h} (96%) rename DDrawCompat/{CompatGdiWinProc.cpp => Gdi/WinProc.cpp} (74%) create mode 100644 DDrawCompat/Gdi/WinProc.h diff --git a/DDrawCompat/CompatActivateAppHandler.cpp b/DDrawCompat/CompatActivateAppHandler.cpp index 5665d58..1710e6d 100644 --- a/DDrawCompat/CompatActivateAppHandler.cpp +++ b/DDrawCompat/CompatActivateAppHandler.cpp @@ -3,11 +3,11 @@ #include "CompatDirectDrawSurface.h" #include "CompatDisplayMode.h" #include "CompatFontSmoothing.h" -#include "CompatGdi.h" #include "CompatPrimarySurface.h" #include "CompatPtr.h" #include "CompatRef.h" #include "DDrawLog.h" +#include "Gdi/Gdi.h" extern HWND g_mainWindow; @@ -42,7 +42,7 @@ namespace if (primary && SUCCEEDED(primary->Restore(primary))) { CompatDirectDrawSurface::fixSurfacePtrs(*primary); - CompatGdi::invalidate(nullptr); + Gdi::invalidate(nullptr); } CompatFontSmoothing::setSystemSettings(g_fontSmoothingSettings); @@ -90,7 +90,7 @@ namespace if (!isActivated) { - CompatGdi::disableEmulation(); + Gdi::disableEmulation(); } if (g_fullScreenDirectDraw) @@ -108,7 +108,7 @@ namespace if (isActivated) { - CompatGdi::enableEmulation(); + Gdi::enableEmulation(); } Compat::LogLeave("handleActivateApp", isActivated); diff --git a/DDrawCompat/CompatDirectDrawSurface.cpp b/DDrawCompat/CompatDirectDrawSurface.cpp index 262de61..65a748b 100644 --- a/DDrawCompat/CompatDirectDrawSurface.cpp +++ b/DDrawCompat/CompatDirectDrawSurface.cpp @@ -4,11 +4,11 @@ #include "CompatDirectDrawPalette.h" #include "CompatDirectDrawSurface.h" #include "CompatDisplayMode.h" -#include "CompatGdi.h" #include "CompatPrimarySurface.h" #include "CompatPtr.h" #include "DDrawProcs.h" #include "DDrawRepository.h" +#include "Gdi/Gdi.h" #include "IReleaseNotifier.h" #include "RealPrimarySurface.h" @@ -465,7 +465,7 @@ HRESULT STDMETHODCALLTYPE CompatDirectDrawSurface::Restore(TSurface* T result = RealPrimarySurface::restore(); if (wasLost) { - CompatGdi::invalidate(nullptr); + Gdi::invalidate(nullptr); } } } diff --git a/DDrawCompat/CompatGdiCaret.h b/DDrawCompat/CompatGdiCaret.h deleted file mode 100644 index d8de8ec..0000000 --- a/DDrawCompat/CompatGdiCaret.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace CompatGdiCaret -{ - void installHooks(); - void uninstallHooks(); -} diff --git a/DDrawCompat/CompatGdiDc.h b/DDrawCompat/CompatGdiDc.h deleted file mode 100644 index d94c428..0000000 --- a/DDrawCompat/CompatGdiDc.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN - -#include - -namespace CompatGdiDc -{ - HDC getDc(HDC origDc, bool isMenuPaintDc = false); - HDC getOrigDc(HDC dc); - void releaseDc(HDC origDc); -} diff --git a/DDrawCompat/CompatGdiDcCache.h b/DDrawCompat/CompatGdiDcCache.h deleted file mode 100644 index 3069f4c..0000000 --- a/DDrawCompat/CompatGdiDcCache.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#define CINTERFACE -#define WIN32_LEAN_AND_MEAN - -#include -#include - -#include "CompatWeakPtr.h" - -namespace CompatGdiDcCache -{ - struct CachedDc - { - CompatWeakPtr surface; - HDC dc; - DWORD cacheId; - }; - - void clear(); - CachedDc getDc(); - bool init(); - void releaseDc(const CachedDc& cachedDc); - void setDdLockThreadId(DWORD ddLockThreadId); - void setSurfaceMemory(void* surfaceMemory, LONG pitch); - void updatePalette(DWORD startingEntry, DWORD count); -} diff --git a/DDrawCompat/CompatGdiDcFunctions.h b/DDrawCompat/CompatGdiDcFunctions.h deleted file mode 100644 index dc4cb25..0000000 --- a/DDrawCompat/CompatGdiDcFunctions.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace CompatGdiDcFunctions -{ - void installHooks(); -}; diff --git a/DDrawCompat/CompatGdiPaintHandlers.h b/DDrawCompat/CompatGdiPaintHandlers.h deleted file mode 100644 index 45681b4..0000000 --- a/DDrawCompat/CompatGdiPaintHandlers.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace CompatGdiPaintHandlers -{ - void installHooks(); - void uninstallHooks(); -} diff --git a/DDrawCompat/CompatGdiScrollFunctions.h b/DDrawCompat/CompatGdiScrollFunctions.h deleted file mode 100644 index 3aa9260..0000000 --- a/DDrawCompat/CompatGdiScrollFunctions.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace CompatGdiScrollFunctions -{ - void installHooks(); - void updateScrolledWindow(HWND hwnd); -}; diff --git a/DDrawCompat/CompatGdiWinProc.h b/DDrawCompat/CompatGdiWinProc.h deleted file mode 100644 index 0d87e3a..0000000 --- a/DDrawCompat/CompatGdiWinProc.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -namespace CompatGdiWinProc -{ - void installHooks(); - void uninstallHooks(); -} diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 43b78ba..0b24b64 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -70,7 +70,7 @@ ddraw - C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\include;$(IncludePath) + $(ProjectDir);C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\include;$(IncludePath) C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\lib.X86;$(LibraryPath) @@ -78,7 +78,7 @@ ddraw - C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\include;$(IncludePath) + $(ProjectDir);C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\include;$(IncludePath) C:\Program Files %28x86%29\Microsoft Research\Detours Express 3.0\lib.X86;$(LibraryPath) @@ -158,16 +158,6 @@ - - - - - - - - - - @@ -198,6 +188,16 @@ + + + + + + + + + + @@ -218,15 +218,6 @@ - - - - - - - - - @@ -236,10 +227,19 @@ + + + + + + + + + + - diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 019d911..8d68b3f 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -13,6 +13,12 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {ed9adcfd-bf6f-4b69-b425-7a9252072e4d} + + + {a8e1437a-7bec-4492-830a-9a0d844aa06b} + @@ -63,36 +69,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files @@ -183,6 +159,36 @@ Header Files + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + + + Header Files\Gdi + @@ -215,36 +221,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files @@ -299,6 +275,36 @@ Source Files + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + + + Source Files\Gdi + diff --git a/DDrawCompat/DllMain.cpp b/DDrawCompat/DllMain.cpp index 4327783..2efb4a1 100644 --- a/DDrawCompat/DllMain.cpp +++ b/DDrawCompat/DllMain.cpp @@ -7,12 +7,12 @@ #include "CompatDisplayMode.h" #include "CompatFontSmoothing.h" -#include "CompatGdi.h" #include "CompatHooks.h" #include "CompatRegistry.h" #include "D3dDdiHooks.h" #include "DDrawHooks.h" #include "DDrawProcs.h" +#include "Gdi/Gdi.h" #include "Time.h" struct IDirectInput; @@ -32,7 +32,7 @@ namespace Compat::Log() << "Installing DirectDraw hooks"; DDrawHooks::installHooks(); Compat::Log() << "Installing GDI hooks"; - CompatGdi::installHooks(); + Gdi::installHooks(); Compat::Log() << "Installing registry hooks"; CompatRegistry::installHooks(); Compat::Log() << "Finished installing hooks"; @@ -137,7 +137,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lpvReserved*/) Compat::Log() << "Detaching DDrawCompat"; DDrawHooks::uninstallHooks(); D3dDdiHooks::uninstallHooks(); - CompatGdi::uninstallHooks(); + Gdi::uninstallHooks(); Compat::unhookAllFunctions(); FreeLibrary(g_origDInputModule); FreeLibrary(g_origDDrawModule); diff --git a/DDrawCompat/CompatGdiCaret.cpp b/DDrawCompat/Gdi/Caret.cpp similarity index 69% rename from DDrawCompat/CompatGdiCaret.cpp rename to DDrawCompat/Gdi/Caret.cpp index 48b6c8a..6951b79 100644 --- a/DDrawCompat/CompatGdiCaret.cpp +++ b/DDrawCompat/Gdi/Caret.cpp @@ -2,9 +2,9 @@ #include -#include "CompatGdi.h" -#include "CompatGdiCaret.h" -#include "CompatGdiDc.h" +#include "Gdi/Caret.h" +#include "Gdi/Dc.h" +#include "Gdi/Gdi.h" #include "Hook.h" #include "ScopedCriticalSection.h" @@ -63,10 +63,10 @@ namespace if (caret.isVisible) { HDC dc = GetDC(caret.hwnd); - HDC compatDc = CompatGdiDc::getDc(dc); + HDC compatDc = Gdi::Dc::getDc(dc); CALL_ORIG_FUNC(PatBlt)( compatDc, caret.left, caret.top, caret.width, caret.height, PATINVERT); - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); ReleaseDC(caret.hwnd, dc); } } @@ -103,11 +103,11 @@ namespace return; } - if ((g_caret.isVisible || newCaret.isVisible) && CompatGdi::beginGdiRendering()) + if ((g_caret.isVisible || newCaret.isVisible) && Gdi::beginGdiRendering()) { drawCaret(g_caret); drawCaret(newCaret); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); } g_caret = newCaret; @@ -118,29 +118,32 @@ namespace Compat::hookFunction( \ #module, #func, getCompatGdiCaretFuncPtr(&func)); -namespace CompatGdiCaret +namespace Gdi { - void installHooks() + namespace Caret { - InitializeCriticalSection(&g_caretCriticalSection); + void installHooks() + { + InitializeCriticalSection(&g_caretCriticalSection); - HOOK_GDI_CARET_FUNCTION(user32, CreateCaret); - HOOK_GDI_CARET_FUNCTION(user32, DestroyCaret); - HOOK_GDI_CARET_FUNCTION(user32, HideCaret); - HOOK_GDI_CARET_FUNCTION(user32, SetCaretPos); - HOOK_GDI_CARET_FUNCTION(user32, ShowCaret); + HOOK_GDI_CARET_FUNCTION(user32, CreateCaret); + HOOK_GDI_CARET_FUNCTION(user32, DestroyCaret); + HOOK_GDI_CARET_FUNCTION(user32, HideCaret); + HOOK_GDI_CARET_FUNCTION(user32, SetCaretPos); + HOOK_GDI_CARET_FUNCTION(user32, ShowCaret); - const DWORD threadId = GetCurrentThreadId(); - g_compatGdiCaretGeneralEventHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_HIDE, - nullptr, &compatGdiCaretEvent, 0, threadId, WINEVENT_OUTOFCONTEXT); - g_compatGdiCaretLocationChangeEventHook = SetWinEventHook( - EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, nullptr, &compatGdiCaretEvent, - 0, threadId, WINEVENT_OUTOFCONTEXT); - } + const DWORD threadId = GetCurrentThreadId(); + g_compatGdiCaretGeneralEventHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_HIDE, + nullptr, &compatGdiCaretEvent, 0, threadId, WINEVENT_OUTOFCONTEXT); + g_compatGdiCaretLocationChangeEventHook = SetWinEventHook( + EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, nullptr, &compatGdiCaretEvent, + 0, threadId, WINEVENT_OUTOFCONTEXT); + } - void uninstallHooks() - { - UnhookWinEvent(g_compatGdiCaretLocationChangeEventHook); - UnhookWinEvent(g_compatGdiCaretGeneralEventHook); + void uninstallHooks() + { + UnhookWinEvent(g_compatGdiCaretLocationChangeEventHook); + UnhookWinEvent(g_compatGdiCaretGeneralEventHook); + } } } diff --git a/DDrawCompat/Gdi/Caret.h b/DDrawCompat/Gdi/Caret.h new file mode 100644 index 0000000..f6a753e --- /dev/null +++ b/DDrawCompat/Gdi/Caret.h @@ -0,0 +1,10 @@ +#pragma once + +namespace Gdi +{ + namespace Caret + { + void installHooks(); + void uninstallHooks(); + } +} diff --git a/DDrawCompat/CompatGdiDc.cpp b/DDrawCompat/Gdi/Dc.cpp similarity index 69% rename from DDrawCompat/CompatGdiDc.cpp rename to DDrawCompat/Gdi/Dc.cpp index 185502c..7e03027 100644 --- a/DDrawCompat/CompatGdiDc.cpp +++ b/DDrawCompat/Gdi/Dc.cpp @@ -1,16 +1,16 @@ #include #include -#include "CompatGdi.h" -#include "CompatGdiDc.h" -#include "CompatGdiDcCache.h" #include "DDrawLog.h" +#include "Gdi/Dc.h" +#include "Gdi/DcCache.h" +#include "Gdi/Gdi.h" #include "Hook.h" #include "ScopedCriticalSection.h" namespace { - using CompatGdiDcCache::CachedDc; + using Gdi::DcCache::CachedDc; struct CompatDc : CachedDc { @@ -154,75 +154,78 @@ namespace } } -namespace CompatGdiDc +namespace Gdi { - HDC getDc(HDC origDc, bool isMenuPaintDc) + namespace Dc { - if (!origDc || OBJ_DC != GetObjectType(origDc) || DT_RASDISPLAY != GetDeviceCaps(origDc, TECHNOLOGY)) + HDC getDc(HDC origDc, bool isMenuPaintDc) { - return nullptr; + if (!origDc || OBJ_DC != GetObjectType(origDc) || DT_RASDISPLAY != GetDeviceCaps(origDc, TECHNOLOGY)) + { + return nullptr; + } + + Compat::ScopedCriticalSection gdiLock(Gdi::g_gdiCriticalSection); + + auto it = g_origDcToCompatDc.find(origDc); + if (it != g_origDcToCompatDc.end()) + { + ++it->second.refCount; + return it->second.dc; + } + + const HWND hwnd = CALL_ORIG_FUNC(WindowFromDC)(origDc); + const bool isMenuWindow = hwnd && 0x8000 == GetClassLongPtr(hwnd, GCW_ATOM); + if (isMenuWindow && !isMenuPaintDc) + { + return nullptr; + } + + CompatDc compatDc(Gdi::DcCache::getDc()); + if (!compatDc.dc) + { + return nullptr; + } + + POINT origin = {}; + GetDCOrgEx(origDc, &origin); + + compatDc.savedState = SaveDC(compatDc.dc); + copyDcAttributes(compatDc, origDc, origin); + setClippingRegion(compatDc.dc, origDc, hwnd, isMenuWindow, origin); + + compatDc.refCount = 1; + compatDc.origDc = origDc; + g_origDcToCompatDc.insert(CompatDcMap::value_type(origDc, compatDc)); + + return compatDc.dc; } - Compat::ScopedCriticalSection gdiLock(CompatGdi::g_gdiCriticalSection); - - auto it = g_origDcToCompatDc.find(origDc); - if (it != g_origDcToCompatDc.end()) + HDC getOrigDc(HDC dc) { - ++it->second.refCount; - return it->second.dc; + const auto it = std::find_if(g_origDcToCompatDc.begin(), g_origDcToCompatDc.end(), + [dc](const CompatDcMap::value_type& compatDc) { return compatDc.second.dc == dc; }); + return it != g_origDcToCompatDc.end() ? it->first : dc; } - const HWND hwnd = CALL_ORIG_FUNC(WindowFromDC)(origDc); - const bool isMenuWindow = hwnd && 0x8000 == GetClassLongPtr(hwnd, GCW_ATOM); - if (isMenuWindow && !isMenuPaintDc) + void releaseDc(HDC origDc) { - return nullptr; - } + Compat::ScopedCriticalSection gdiLock(Gdi::g_gdiCriticalSection); - CompatDc compatDc(CompatGdiDcCache::getDc()); - if (!compatDc.dc) - { - return nullptr; - } + auto it = g_origDcToCompatDc.find(origDc); + if (it == g_origDcToCompatDc.end()) + { + return; + } - POINT origin = {}; - GetDCOrgEx(origDc, &origin); - - compatDc.savedState = SaveDC(compatDc.dc); - copyDcAttributes(compatDc, origDc, origin); - setClippingRegion(compatDc.dc, origDc, hwnd, isMenuWindow, origin); - - compatDc.refCount = 1; - compatDc.origDc = origDc; - g_origDcToCompatDc.insert(CompatDcMap::value_type(origDc, compatDc)); - - return compatDc.dc; - } - - HDC getOrigDc(HDC dc) - { - const auto it = std::find_if(g_origDcToCompatDc.begin(), g_origDcToCompatDc.end(), - [dc](const CompatDcMap::value_type& compatDc) { return compatDc.second.dc == dc; }); - return it != g_origDcToCompatDc.end() ? it->first : dc; - } - - void releaseDc(HDC origDc) - { - Compat::ScopedCriticalSection gdiLock(CompatGdi::g_gdiCriticalSection); - - auto it = g_origDcToCompatDc.find(origDc); - if (it == g_origDcToCompatDc.end()) - { - return; - } - - CompatDc& compatDc = it->second; - --compatDc.refCount; - if (0 == compatDc.refCount) - { - RestoreDC(compatDc.dc, compatDc.savedState); - CompatGdiDcCache::releaseDc(compatDc); - g_origDcToCompatDc.erase(origDc); + CompatDc& compatDc = it->second; + --compatDc.refCount; + if (0 == compatDc.refCount) + { + RestoreDC(compatDc.dc, compatDc.savedState); + Gdi::DcCache::releaseDc(compatDc); + g_origDcToCompatDc.erase(origDc); + } } } } diff --git a/DDrawCompat/Gdi/Dc.h b/DDrawCompat/Gdi/Dc.h new file mode 100644 index 0000000..2cc4ad7 --- /dev/null +++ b/DDrawCompat/Gdi/Dc.h @@ -0,0 +1,15 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN + +#include + +namespace Gdi +{ + namespace Dc + { + HDC getDc(HDC origDc, bool isMenuPaintDc = false); + HDC getOrigDc(HDC dc); + void releaseDc(HDC origDc); + } +} diff --git a/DDrawCompat/CompatGdiDcCache.cpp b/DDrawCompat/Gdi/DcCache.cpp similarity index 57% rename from DDrawCompat/CompatGdiDcCache.cpp rename to DDrawCompat/Gdi/DcCache.cpp index 066b415..3e7f411 100644 --- a/DDrawCompat/CompatGdiDcCache.cpp +++ b/DDrawCompat/Gdi/DcCache.cpp @@ -1,17 +1,17 @@ #include #include -#include "CompatGdiDcCache.h" #include "CompatPrimarySurface.h" #include "CompatPtr.h" #include "Config.h" #include "DDrawLog.h" #include "DDrawProcs.h" #include "DDrawRepository.h" +#include "Gdi/DcCache.h" namespace { - using CompatGdiDcCache::CachedDc; + using Gdi::DcCache::CachedDc; std::vector g_cache; DWORD g_cacheSize = 0; @@ -117,108 +117,111 @@ namespace } } -namespace CompatGdiDcCache +namespace Gdi { - void clear() + namespace DcCache { - for (auto& cachedDc : g_cache) + void clear() { - releaseCachedDc(cachedDc); + for (auto& cachedDc : g_cache) + { + releaseCachedDc(cachedDc); + } + g_cache.clear(); + g_cacheSize = 0; + ++g_cacheId; } - g_cache.clear(); - g_cacheSize = 0; - ++g_cacheId; - } - CachedDc getDc() - { - CachedDc cachedDc = {}; - if (!g_surfaceMemory) + CachedDc getDc() { + CachedDc cachedDc = {}; + if (!g_surfaceMemory) + { + return cachedDc; + } + + if (g_cache.empty()) + { + extendCache(); + } + + if (!g_cache.empty()) + { + cachedDc = g_cache.back(); + g_cache.pop_back(); + + const DWORD usedCacheSize = g_cacheSize - g_cache.size(); + if (usedCacheSize > g_maxUsedCacheSize) + { + g_maxUsedCacheSize = usedCacheSize; + Compat::Log() << "GDI used DC cache size: " << g_maxUsedCacheSize; + } + } + return cachedDc; } - if (g_cache.empty()) + bool init() { - extendCache(); + auto dd(DDrawRepository::getDirectDraw()); + dd->CreatePalette(dd, + DDPCAPS_8BIT | DDPCAPS_ALLOW256, g_paletteEntries, &g_palette.getRef(), nullptr); + return nullptr != g_palette; } - if (!g_cache.empty()) + void releaseDc(const CachedDc& cachedDc) { - cachedDc = g_cache.back(); - g_cache.pop_back(); - - const DWORD usedCacheSize = g_cacheSize - g_cache.size(); - if (usedCacheSize > g_maxUsedCacheSize) + if (cachedDc.cacheId == g_cacheId) { - g_maxUsedCacheSize = usedCacheSize; - Compat::Log() << "GDI used DC cache size: " << g_maxUsedCacheSize; + g_cache.push_back(cachedDc); + } + else + { + releaseCachedDc(cachedDc); } } - return cachedDc; - } - - bool init() - { - auto dd(DDrawRepository::getDirectDraw()); - dd->CreatePalette(dd, - DDPCAPS_8BIT | DDPCAPS_ALLOW256, g_paletteEntries, &g_palette.getRef(), nullptr); - return nullptr != g_palette; - } - - void releaseDc(const CachedDc& cachedDc) - { - if (cachedDc.cacheId == g_cacheId) + void setDdLockThreadId(DWORD ddLockThreadId) { - g_cache.push_back(cachedDc); - } - else - { - releaseCachedDc(cachedDc); - } - } - - void setDdLockThreadId(DWORD ddLockThreadId) - { - g_ddLockThreadId = ddLockThreadId; - } - - void setSurfaceMemory(void* surfaceMemory, LONG pitch) - { - if (g_surfaceMemory == surfaceMemory && g_pitch == pitch) - { - return; + g_ddLockThreadId = ddLockThreadId; } - g_surfaceMemory = surfaceMemory; - g_pitch = pitch; - clear(); - } - - void updatePalette(DWORD startingEntry, DWORD count) - { - PALETTEENTRY entries[256] = {}; - std::memcpy(&entries[startingEntry], - &CompatPrimarySurface::g_paletteEntries[startingEntry], - count * sizeof(PALETTEENTRY)); - - for (DWORD i = startingEntry; i < startingEntry + count; ++i) + void setSurfaceMemory(void* surfaceMemory, LONG pitch) { - if (entries[i].peFlags & PC_RESERVED) + if (g_surfaceMemory == surfaceMemory && g_pitch == pitch) { - entries[i] = CompatPrimarySurface::g_paletteEntries[0]; - entries[i].peFlags = CompatPrimarySurface::g_paletteEntries[i].peFlags; + return; } - } - if (0 != std::memcmp(&g_paletteEntries[startingEntry], &entries[startingEntry], - count * sizeof(PALETTEENTRY))) - { - std::memcpy(&g_paletteEntries[startingEntry], &entries[startingEntry], - count * sizeof(PALETTEENTRY)); - g_palette->SetEntries(g_palette, 0, startingEntry, count, g_paletteEntries); + g_surfaceMemory = surfaceMemory; + g_pitch = pitch; clear(); } + + void updatePalette(DWORD startingEntry, DWORD count) + { + PALETTEENTRY entries[256] = {}; + std::memcpy(&entries[startingEntry], + &CompatPrimarySurface::g_paletteEntries[startingEntry], + count * sizeof(PALETTEENTRY)); + + for (DWORD i = startingEntry; i < startingEntry + count; ++i) + { + if (entries[i].peFlags & PC_RESERVED) + { + entries[i] = CompatPrimarySurface::g_paletteEntries[0]; + entries[i].peFlags = CompatPrimarySurface::g_paletteEntries[i].peFlags; + } + } + + if (0 != std::memcmp(&g_paletteEntries[startingEntry], &entries[startingEntry], + count * sizeof(PALETTEENTRY))) + { + std::memcpy(&g_paletteEntries[startingEntry], &entries[startingEntry], + count * sizeof(PALETTEENTRY)); + g_palette->SetEntries(g_palette, 0, startingEntry, count, g_paletteEntries); + clear(); + } + } } } diff --git a/DDrawCompat/Gdi/DcCache.h b/DDrawCompat/Gdi/DcCache.h new file mode 100644 index 0000000..ec00f36 --- /dev/null +++ b/DDrawCompat/Gdi/DcCache.h @@ -0,0 +1,30 @@ +#pragma once + +#define CINTERFACE +#define WIN32_LEAN_AND_MEAN + +#include +#include + +#include "CompatWeakPtr.h" + +namespace Gdi +{ + namespace DcCache + { + struct CachedDc + { + CompatWeakPtr surface; + HDC dc; + DWORD cacheId; + }; + + void clear(); + CachedDc getDc(); + bool init(); + void releaseDc(const CachedDc& cachedDc); + void setDdLockThreadId(DWORD ddLockThreadId); + void setSurfaceMemory(void* surfaceMemory, LONG pitch); + void updatePalette(DWORD startingEntry, DWORD count); + } +} diff --git a/DDrawCompat/CompatGdiDcFunctions.cpp b/DDrawCompat/Gdi/DcFunctions.cpp similarity index 57% rename from DDrawCompat/CompatGdiDcFunctions.cpp rename to DDrawCompat/Gdi/DcFunctions.cpp index 77c0ca8..3e50a41 100644 --- a/DDrawCompat/CompatGdiDcFunctions.cpp +++ b/DDrawCompat/Gdi/DcFunctions.cpp @@ -1,10 +1,10 @@ #include #include "CompatDisplayMode.h" -#include "CompatGdi.h" -#include "CompatGdiDc.h" -#include "CompatGdiDcFunctions.h" #include "DDrawLog.h" +#include "Gdi/Dc.h" +#include "Gdi/DcFunctions.h" +#include "Gdi/Gdi.h" #include "Hook.h" namespace @@ -45,7 +45,7 @@ namespace HDC replaceDc(HDC dc) { - HDC compatDc = CompatGdiDc::getDc(dc); + HDC compatDc = Gdi::Dc::getDc(dc); return compatDc ? compatDc : dc; } @@ -54,7 +54,7 @@ namespace void releaseDc(HDC dc) { - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); } template @@ -72,7 +72,7 @@ namespace #endif if (!hasDisplayDcArg(params...) || - !CompatGdi::beginGdiRendering(getDdLockFlags(params...))) + !Gdi::beginGdiRendering(getDdLockFlags(params...))) { Result result = Compat::getOrigFuncPtr()(params...); @@ -81,7 +81,7 @@ namespace { Compat::Log() << "Skipping redirection since there is no display DC argument"; } - else if (!CompatGdi::isEmulationEnabled()) + else if (!Gdi::isEmulationEnabled()) { Compat::Log() << "Skipping redirection since GDI emulation is disabled"; } @@ -97,7 +97,7 @@ namespace Result result = Compat::getOrigFuncPtr()(replaceDc(params)...); releaseDc(params...); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); #ifdef _DEBUG Compat::LogLeave(g_funcNames[origFunc], params...) << result; @@ -205,7 +205,7 @@ namespace HWND WINAPI windowFromDc(HDC dc) { - return CALL_ORIG_FUNC(WindowFromDC)(CompatGdiDc::getOrigDc(dc)); + return CALL_ORIG_FUNC(WindowFromDC)(Gdi::Dc::getOrigDc(dc)); } } @@ -216,96 +216,99 @@ namespace HOOK_GDI_DC_FUNCTION(module, func##A); \ HOOK_GDI_DC_FUNCTION(module, func##W) -namespace CompatGdiDcFunctions +namespace Gdi { - void installHooks() + namespace DcFunctions { - // Bitmap functions - HOOK_GDI_DC_FUNCTION(msimg32, AlphaBlend); - HOOK_GDI_DC_FUNCTION(gdi32, BitBlt); - HOOK_FUNCTION(gdi32, CreateCompatibleBitmap, CompatDisplayMode::createCompatibleBitmap); - HOOK_FUNCTION(gdi32, CreateDIBitmap, CompatDisplayMode::createDIBitmap); - HOOK_FUNCTION(gdi32, CreateDiscardableBitmap, CompatDisplayMode::createDiscardableBitmap); - HOOK_GDI_DC_FUNCTION(gdi32, ExtFloodFill); - HOOK_GDI_DC_FUNCTION(gdi32, GdiAlphaBlend); - HOOK_GDI_DC_FUNCTION(gdi32, GdiGradientFill); - HOOK_GDI_DC_FUNCTION(gdi32, GdiTransparentBlt); - HOOK_GDI_DC_FUNCTION(gdi32, GetDIBits); - HOOK_GDI_DC_FUNCTION(gdi32, GetPixel); - HOOK_GDI_DC_FUNCTION(msimg32, GradientFill); - HOOK_GDI_DC_FUNCTION(gdi32, MaskBlt); - HOOK_GDI_DC_FUNCTION(gdi32, PlgBlt); - HOOK_GDI_DC_FUNCTION(gdi32, SetDIBits); - HOOK_GDI_DC_FUNCTION(gdi32, SetDIBitsToDevice); - HOOK_GDI_DC_FUNCTION(gdi32, SetPixel); - HOOK_GDI_DC_FUNCTION(gdi32, SetPixelV); - HOOK_GDI_DC_FUNCTION(gdi32, StretchBlt); - HOOK_GDI_DC_FUNCTION(gdi32, StretchDIBits); - HOOK_GDI_DC_FUNCTION(msimg32, TransparentBlt); + void installHooks() + { + // Bitmap functions + HOOK_GDI_DC_FUNCTION(msimg32, AlphaBlend); + HOOK_GDI_DC_FUNCTION(gdi32, BitBlt); + HOOK_FUNCTION(gdi32, CreateCompatibleBitmap, CompatDisplayMode::createCompatibleBitmap); + HOOK_FUNCTION(gdi32, CreateDIBitmap, CompatDisplayMode::createDIBitmap); + HOOK_FUNCTION(gdi32, CreateDiscardableBitmap, CompatDisplayMode::createDiscardableBitmap); + HOOK_GDI_DC_FUNCTION(gdi32, ExtFloodFill); + HOOK_GDI_DC_FUNCTION(gdi32, GdiAlphaBlend); + HOOK_GDI_DC_FUNCTION(gdi32, GdiGradientFill); + HOOK_GDI_DC_FUNCTION(gdi32, GdiTransparentBlt); + HOOK_GDI_DC_FUNCTION(gdi32, GetDIBits); + HOOK_GDI_DC_FUNCTION(gdi32, GetPixel); + HOOK_GDI_DC_FUNCTION(msimg32, GradientFill); + HOOK_GDI_DC_FUNCTION(gdi32, MaskBlt); + HOOK_GDI_DC_FUNCTION(gdi32, PlgBlt); + HOOK_GDI_DC_FUNCTION(gdi32, SetDIBits); + HOOK_GDI_DC_FUNCTION(gdi32, SetDIBitsToDevice); + HOOK_GDI_DC_FUNCTION(gdi32, SetPixel); + HOOK_GDI_DC_FUNCTION(gdi32, SetPixelV); + HOOK_GDI_DC_FUNCTION(gdi32, StretchBlt); + HOOK_GDI_DC_FUNCTION(gdi32, StretchDIBits); + HOOK_GDI_DC_FUNCTION(msimg32, TransparentBlt); - // Brush functions - HOOK_GDI_DC_FUNCTION(gdi32, PatBlt); + // Brush functions + HOOK_GDI_DC_FUNCTION(gdi32, PatBlt); - // Device context functions - HOOK_GDI_DC_FUNCTION(gdi32, DrawEscape); - HOOK_FUNCTION(user32, WindowFromDC, windowFromDc); + // Device context functions + HOOK_GDI_DC_FUNCTION(gdi32, DrawEscape); + HOOK_FUNCTION(user32, WindowFromDC, windowFromDc); - // Filled shape functions - HOOK_GDI_DC_FUNCTION(gdi32, Chord); - HOOK_GDI_DC_FUNCTION(gdi32, Ellipse); - HOOK_GDI_DC_FUNCTION(user32, FillRect); - HOOK_GDI_DC_FUNCTION(user32, FrameRect); - HOOK_GDI_DC_FUNCTION(user32, InvertRect); - HOOK_GDI_DC_FUNCTION(gdi32, Pie); - HOOK_GDI_DC_FUNCTION(gdi32, Polygon); - HOOK_GDI_DC_FUNCTION(gdi32, PolyPolygon); - HOOK_GDI_DC_FUNCTION(gdi32, Rectangle); - HOOK_GDI_DC_FUNCTION(gdi32, RoundRect); + // Filled shape functions + HOOK_GDI_DC_FUNCTION(gdi32, Chord); + HOOK_GDI_DC_FUNCTION(gdi32, Ellipse); + HOOK_GDI_DC_FUNCTION(user32, FillRect); + HOOK_GDI_DC_FUNCTION(user32, FrameRect); + HOOK_GDI_DC_FUNCTION(user32, InvertRect); + HOOK_GDI_DC_FUNCTION(gdi32, Pie); + HOOK_GDI_DC_FUNCTION(gdi32, Polygon); + HOOK_GDI_DC_FUNCTION(gdi32, PolyPolygon); + HOOK_GDI_DC_FUNCTION(gdi32, Rectangle); + HOOK_GDI_DC_FUNCTION(gdi32, RoundRect); - // Font and text functions - HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawText); - HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawTextEx); - HOOK_GDI_TEXT_DC_FUNCTION(gdi32, ExtTextOut); - HOOK_GDI_TEXT_DC_FUNCTION(gdi32, PolyTextOut); - HOOK_GDI_TEXT_DC_FUNCTION(user32, TabbedTextOut); - HOOK_GDI_TEXT_DC_FUNCTION(gdi32, TextOut); + // Font and text functions + HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawText); + HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawTextEx); + HOOK_GDI_TEXT_DC_FUNCTION(gdi32, ExtTextOut); + HOOK_GDI_TEXT_DC_FUNCTION(gdi32, PolyTextOut); + HOOK_GDI_TEXT_DC_FUNCTION(user32, TabbedTextOut); + HOOK_GDI_TEXT_DC_FUNCTION(gdi32, TextOut); - // Icon functions - HOOK_GDI_DC_FUNCTION(user32, DrawIcon); - HOOK_GDI_DC_FUNCTION(user32, DrawIconEx); + // Icon functions + HOOK_GDI_DC_FUNCTION(user32, DrawIcon); + HOOK_GDI_DC_FUNCTION(user32, DrawIconEx); - // Line and curve functions - HOOK_GDI_DC_FUNCTION(gdi32, AngleArc); - HOOK_GDI_DC_FUNCTION(gdi32, Arc); - HOOK_GDI_DC_FUNCTION(gdi32, ArcTo); - HOOK_GDI_DC_FUNCTION(gdi32, LineTo); - HOOK_GDI_DC_FUNCTION(gdi32, PolyBezier); - HOOK_GDI_DC_FUNCTION(gdi32, PolyBezierTo); - HOOK_GDI_DC_FUNCTION(gdi32, PolyDraw); - HOOK_GDI_DC_FUNCTION(gdi32, Polyline); - HOOK_GDI_DC_FUNCTION(gdi32, PolylineTo); - HOOK_GDI_DC_FUNCTION(gdi32, PolyPolyline); + // Line and curve functions + HOOK_GDI_DC_FUNCTION(gdi32, AngleArc); + HOOK_GDI_DC_FUNCTION(gdi32, Arc); + HOOK_GDI_DC_FUNCTION(gdi32, ArcTo); + HOOK_GDI_DC_FUNCTION(gdi32, LineTo); + HOOK_GDI_DC_FUNCTION(gdi32, PolyBezier); + HOOK_GDI_DC_FUNCTION(gdi32, PolyBezierTo); + HOOK_GDI_DC_FUNCTION(gdi32, PolyDraw); + HOOK_GDI_DC_FUNCTION(gdi32, Polyline); + HOOK_GDI_DC_FUNCTION(gdi32, PolylineTo); + HOOK_GDI_DC_FUNCTION(gdi32, PolyPolyline); - // Painting and drawing functions - HOOK_GDI_DC_FUNCTION(user32, DrawCaption); - HOOK_GDI_DC_FUNCTION(user32, DrawEdge); - HOOK_GDI_DC_FUNCTION(user32, DrawFocusRect); - HOOK_GDI_DC_FUNCTION(user32, DrawFrameControl); - HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawState); - HOOK_GDI_TEXT_DC_FUNCTION(user32, GrayString); - HOOK_GDI_DC_FUNCTION(user32, PaintDesktop); + // Painting and drawing functions + HOOK_GDI_DC_FUNCTION(user32, DrawCaption); + HOOK_GDI_DC_FUNCTION(user32, DrawEdge); + HOOK_GDI_DC_FUNCTION(user32, DrawFocusRect); + HOOK_GDI_DC_FUNCTION(user32, DrawFrameControl); + HOOK_GDI_TEXT_DC_FUNCTION(user32, DrawState); + HOOK_GDI_TEXT_DC_FUNCTION(user32, GrayString); + HOOK_GDI_DC_FUNCTION(user32, PaintDesktop); - // Region functions - HOOK_GDI_DC_FUNCTION(gdi32, FillRgn); - HOOK_GDI_DC_FUNCTION(gdi32, FrameRgn); - HOOK_GDI_DC_FUNCTION(gdi32, InvertRgn); - HOOK_GDI_DC_FUNCTION(gdi32, PaintRgn); + // Region functions + HOOK_GDI_DC_FUNCTION(gdi32, FillRgn); + HOOK_GDI_DC_FUNCTION(gdi32, FrameRgn); + HOOK_GDI_DC_FUNCTION(gdi32, InvertRgn); + HOOK_GDI_DC_FUNCTION(gdi32, PaintRgn); - // Scroll bar functions - HOOK_GDI_DC_FUNCTION(user32, ScrollDC); + // Scroll bar functions + HOOK_GDI_DC_FUNCTION(user32, ScrollDC); - // Undocumented functions - HOOK_GDI_DC_FUNCTION(gdi32, GdiDrawStream); - HOOK_GDI_DC_FUNCTION(gdi32, PolyPatBlt); + // Undocumented functions + HOOK_GDI_DC_FUNCTION(gdi32, GdiDrawStream); + HOOK_GDI_DC_FUNCTION(gdi32, PolyPatBlt); + } } } diff --git a/DDrawCompat/Gdi/DcFunctions.h b/DDrawCompat/Gdi/DcFunctions.h new file mode 100644 index 0000000..3ae80af --- /dev/null +++ b/DDrawCompat/Gdi/DcFunctions.h @@ -0,0 +1,9 @@ +#pragma once + +namespace Gdi +{ + namespace DcFunctions + { + void installHooks(); + } +} diff --git a/DDrawCompat/CompatGdi.cpp b/DDrawCompat/Gdi/Gdi.cpp similarity index 84% rename from DDrawCompat/CompatGdi.cpp rename to DDrawCompat/Gdi/Gdi.cpp index 27d5318..bc3b93e 100644 --- a/DDrawCompat/CompatGdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -1,15 +1,15 @@ #include -#include "CompatGdi.h" -#include "CompatGdiCaret.h" -#include "CompatGdiDcCache.h" -#include "CompatGdiDcFunctions.h" -#include "CompatGdiPaintHandlers.h" -#include "CompatGdiScrollFunctions.h" -#include "CompatGdiWinProc.h" #include "CompatPaletteConverter.h" #include "CompatPrimarySurface.h" #include "DDrawProcs.h" +#include "Gdi/Caret.h" +#include "Gdi/DcCache.h" +#include "Gdi/DcFunctions.h" +#include "Gdi/Gdi.h" +#include "Gdi/PaintHandlers.h" +#include "Gdi/ScrollFunctions.h" +#include "Gdi/WinProc.h" #include "RealPrimarySurface.h" #include "ScopedCriticalSection.h" @@ -67,12 +67,12 @@ namespace g_ddLockFlags = lockFlags; if (0 != lockFlags) { - EnterCriticalSection(&CompatGdi::g_gdiCriticalSection); + EnterCriticalSection(&Gdi::g_gdiCriticalSection); } g_ddLockThreadId = GetCurrentThreadId(); - CompatGdiDcCache::setDdLockThreadId(g_ddLockThreadId); - CompatGdiDcCache::setSurfaceMemory(desc.lpSurface, desc.lPitch); + Gdi::DcCache::setDdLockThreadId(g_ddLockThreadId); + Gdi::DcCache::setSurfaceMemory(desc.lpSurface, desc.lPitch); return true; } @@ -89,7 +89,7 @@ namespace if (0 != g_ddLockFlags) { - LeaveCriticalSection(&CompatGdi::g_gdiCriticalSection); + LeaveCriticalSection(&Gdi::g_gdiCriticalSection); } g_ddLockFlags = 0; @@ -97,7 +97,7 @@ namespace } } -namespace CompatGdi +namespace Gdi { CRITICAL_SECTION g_gdiCriticalSection; @@ -192,7 +192,7 @@ namespace CompatGdi void installHooks() { InitializeCriticalSection(&g_gdiCriticalSection); - if (CompatGdiDcCache::init()) + if (Gdi::DcCache::init()) { g_ddUnlockBeginEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); g_ddUnlockEndEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -202,11 +202,11 @@ namespace CompatGdi return; } - CompatGdiDcFunctions::installHooks(); - CompatGdiPaintHandlers::installHooks(); - CompatGdiScrollFunctions::installHooks(); - CompatGdiWinProc::installHooks(); - CompatGdiCaret::installHooks(); + Gdi::DcFunctions::installHooks(); + Gdi::PaintHandlers::installHooks(); + Gdi::ScrollFunctions::installHooks(); + Gdi::WinProc::installHooks(); + Gdi::Caret::installHooks(); } } @@ -232,16 +232,16 @@ namespace CompatGdi void uninstallHooks() { - CompatGdiCaret::uninstallHooks(); - CompatGdiWinProc::uninstallHooks(); - CompatGdiPaintHandlers::uninstallHooks(); + Gdi::Caret::uninstallHooks(); + Gdi::WinProc::uninstallHooks(); + Gdi::PaintHandlers::uninstallHooks(); } void updatePalette(DWORD startingEntry, DWORD count) { if (isEmulationEnabled() && CompatPrimarySurface::g_palette) { - CompatGdiDcCache::updatePalette(startingEntry, count); + Gdi::DcCache::updatePalette(startingEntry, count); } } } diff --git a/DDrawCompat/CompatGdi.h b/DDrawCompat/Gdi/Gdi.h similarity index 96% rename from DDrawCompat/CompatGdi.h rename to DDrawCompat/Gdi/Gdi.h index a2668e7..e3b8276 100644 --- a/DDrawCompat/CompatGdi.h +++ b/DDrawCompat/Gdi/Gdi.h @@ -4,7 +4,7 @@ #include -namespace CompatGdi +namespace Gdi { bool beginGdiRendering(DWORD lockFlags = 0); void endGdiRendering(); diff --git a/DDrawCompat/CompatGdiPaintHandlers.cpp b/DDrawCompat/Gdi/PaintHandlers.cpp similarity index 77% rename from DDrawCompat/CompatGdiPaintHandlers.cpp rename to DDrawCompat/Gdi/PaintHandlers.cpp index c18ec2d..b0ff9c6 100644 --- a/DDrawCompat/CompatGdiPaintHandlers.cpp +++ b/DDrawCompat/Gdi/PaintHandlers.cpp @@ -1,12 +1,12 @@ -#include "CompatGdi.h" -#include "CompatGdiDc.h" -#include "CompatGdiPaintHandlers.h" -#include "CompatGdiScrollBar.h" -#include "CompatGdiScrollFunctions.h" -#include "CompatGdiTitleBar.h" #include "CompatPrimarySurface.h" #include "CompatRegistry.h" #include "DDrawLog.h" +#include "Gdi/Dc.h" +#include "Gdi/Gdi.h" +#include "Gdi/PaintHandlers.h" +#include "Gdi/ScrollBar.h" +#include "Gdi/ScrollFunctions.h" +#include "Gdi/TitleBar.h" #include "Hook.h" #include "RealPrimarySurface.h" @@ -117,7 +117,7 @@ namespace LRESULT result = defPaintProc(hwnd, msg, wParam, lParam, g_origEditWndProc, "editWndProc"); if (0 == result && (WM_HSCROLL == msg || WM_VSCROLL == msg)) { - CompatGdiScrollFunctions::updateScrolledWindow(hwnd); + Gdi::ScrollFunctions::updateScrolledWindow(hwnd); } return result; } @@ -157,17 +157,17 @@ namespace LRESULT onEraseBackground(HWND hwnd, HDC dc, WNDPROC origWndProc) { - if (!hwnd || !CompatGdi::beginGdiRendering()) + if (!hwnd || !Gdi::beginGdiRendering()) { return origWndProc(hwnd, WM_ERASEBKGND, reinterpret_cast(dc), 0); } LRESULT result = 0; - HDC compatDc = CompatGdiDc::getDc(dc); + HDC compatDc = Gdi::Dc::getDc(dc); if (compatDc) { result = origWndProc(hwnd, WM_ERASEBKGND, reinterpret_cast(compatDc), 0); - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); if (result) { RealPrimarySurface::disableUpdates(); @@ -178,7 +178,7 @@ namespace result = origWndProc(hwnd, WM_ERASEBKGND, reinterpret_cast(dc), 0); } - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); if (result && compatDc) { @@ -191,20 +191,20 @@ namespace LRESULT onMenuPaint(HWND hwnd, WNDPROC origWndProc) { - if (!hwnd || !CompatGdi::beginGdiRendering()) + if (!hwnd || !Gdi::beginGdiRendering()) { return origWndProc(hwnd, WM_PAINT, 0, 0); } HDC dc = GetWindowDC(hwnd); const bool isMenuPaintDc = true; - HDC compatDc = CompatGdiDc::getDc(dc, isMenuPaintDc); + HDC compatDc = Gdi::Dc::getDc(dc, isMenuPaintDc); if (compatDc) { origWndProc(hwnd, WM_PRINT, reinterpret_cast(compatDc), PRF_NONCLIENT | PRF_ERASEBKGND | PRF_CLIENT); ValidateRect(hwnd, nullptr); - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); } else { @@ -212,55 +212,55 @@ namespace } ReleaseDC(hwnd, dc); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); return 0; } LRESULT onNcPaint(HWND hwnd, WPARAM wParam, WNDPROC origWndProc) { - if (!hwnd || !CompatGdi::beginGdiRendering()) + if (!hwnd || !Gdi::beginGdiRendering()) { return origWndProc(hwnd, WM_NCPAINT, wParam, 0); } HDC windowDc = GetWindowDC(hwnd); - HDC compatDc = CompatGdiDc::getDc(windowDc); + HDC compatDc = Gdi::Dc::getDc(windowDc); if (compatDc) { - CompatGdi::TitleBar titleBar(hwnd, compatDc); + Gdi::TitleBar titleBar(hwnd, compatDc); titleBar.drawAll(); titleBar.excludeFromClipRegion(); - CompatGdi::ScrollBar scrollBar(hwnd, compatDc); + Gdi::ScrollBar scrollBar(hwnd, compatDc); scrollBar.drawAll(); scrollBar.excludeFromClipRegion(); SendMessage(hwnd, WM_PRINT, reinterpret_cast(compatDc), PRF_NONCLIENT); - CompatGdiDc::releaseDc(windowDc); + Gdi::Dc::releaseDc(windowDc); } ReleaseDC(hwnd, windowDc); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); return 0; } LRESULT onPaint(HWND hwnd, WNDPROC origWndProc) { - if (!hwnd || !CompatGdi::beginGdiRendering()) + if (!hwnd || !Gdi::beginGdiRendering()) { return origWndProc(hwnd, WM_PAINT, 0, 0); } PAINTSTRUCT paint = {}; HDC dc = BeginPaint(hwnd, &paint); - HDC compatDc = CompatGdiDc::getDc(dc); + HDC compatDc = Gdi::Dc::getDc(dc); if (compatDc) { origWndProc(hwnd, WM_PRINTCLIENT, reinterpret_cast(compatDc), PRF_CLIENT); - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); } else { @@ -269,30 +269,30 @@ namespace EndPaint(hwnd, &paint); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); return 0; } LRESULT onPrint(HWND hwnd, UINT msg, HDC dc, LONG flags, WNDPROC origWndProc) { - if (!CompatGdi::beginGdiRendering()) + if (!Gdi::beginGdiRendering()) { return origWndProc(hwnd, msg, reinterpret_cast(dc), flags); } LRESULT result = 0; - HDC compatDc = CompatGdiDc::getDc(dc); + HDC compatDc = Gdi::Dc::getDc(dc); if (compatDc) { result = origWndProc(hwnd, msg, reinterpret_cast(compatDc), flags); - CompatGdiDc::releaseDc(dc); + Gdi::Dc::releaseDc(dc); } else { result = origWndProc(hwnd, msg, reinterpret_cast(dc), flags); } - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); return result; } @@ -325,30 +325,33 @@ namespace } } -namespace CompatGdiPaintHandlers +namespace Gdi { - void installHooks() + namespace PaintHandlers { - disableImmersiveContextMenus(); + void installHooks() + { + disableImmersiveContextMenus(); - CompatGdi::hookWndProc("ComboLBox", g_origComboListBoxWndProc, &comboListBoxWndProc); - CompatGdi::hookWndProc("Edit", g_origEditWndProc, &editWndProc); - CompatGdi::hookWndProc("ListBox", g_origListBoxWndProc, &listBoxWndProc); - CompatGdi::hookWndProc("#32768", g_origMenuWndProc, &menuWndProc); - CompatGdi::hookWndProc("ScrollBar", g_origScrollBarWndProc, &scrollBarWndProc); + Gdi::hookWndProc("ComboLBox", g_origComboListBoxWndProc, &comboListBoxWndProc); + Gdi::hookWndProc("Edit", g_origEditWndProc, &editWndProc); + Gdi::hookWndProc("ListBox", g_origListBoxWndProc, &listBoxWndProc); + Gdi::hookWndProc("#32768", g_origMenuWndProc, &menuWndProc); + Gdi::hookWndProc("ScrollBar", g_origScrollBarWndProc, &scrollBarWndProc); - HOOK_FUNCTION(user32, DefWindowProcA, defWindowProcA); - HOOK_FUNCTION(user32, DefWindowProcW, defWindowProcW); - HOOK_FUNCTION(user32, DefDlgProcA, defDlgProcA); - HOOK_FUNCTION(user32, DefDlgProcW, defDlgProcW); - } + HOOK_FUNCTION(user32, DefWindowProcA, defWindowProcA); + HOOK_FUNCTION(user32, DefWindowProcW, defWindowProcW); + HOOK_FUNCTION(user32, DefDlgProcA, defDlgProcA); + HOOK_FUNCTION(user32, DefDlgProcW, defDlgProcW); + } - void uninstallHooks() - { - CompatGdi::unhookWndProc("ComboLBox", g_origComboListBoxWndProc); - CompatGdi::unhookWndProc("Edit", g_origEditWndProc); - CompatGdi::unhookWndProc("ListBox", g_origListBoxWndProc); - CompatGdi::unhookWndProc("#32768", g_origMenuWndProc); - CompatGdi::unhookWndProc("ScrollBar", g_origScrollBarWndProc); + void uninstallHooks() + { + Gdi::unhookWndProc("ComboLBox", g_origComboListBoxWndProc); + Gdi::unhookWndProc("Edit", g_origEditWndProc); + Gdi::unhookWndProc("ListBox", g_origListBoxWndProc); + Gdi::unhookWndProc("#32768", g_origMenuWndProc); + Gdi::unhookWndProc("ScrollBar", g_origScrollBarWndProc); + } } } diff --git a/DDrawCompat/Gdi/PaintHandlers.h b/DDrawCompat/Gdi/PaintHandlers.h new file mode 100644 index 0000000..1f84798 --- /dev/null +++ b/DDrawCompat/Gdi/PaintHandlers.h @@ -0,0 +1,10 @@ +#pragma once + +namespace Gdi +{ + namespace PaintHandlers + { + void installHooks(); + void uninstallHooks(); + } +} diff --git a/DDrawCompat/CompatGdiScrollBar.cpp b/DDrawCompat/Gdi/ScrollBar.cpp similarity index 98% rename from DDrawCompat/CompatGdiScrollBar.cpp rename to DDrawCompat/Gdi/ScrollBar.cpp index a7cc5af..4cecc5a 100644 --- a/DDrawCompat/CompatGdiScrollBar.cpp +++ b/DDrawCompat/Gdi/ScrollBar.cpp @@ -1,5 +1,5 @@ -#include "CompatGdi.h" -#include "CompatGdiScrollBar.h" +#include "Gdi/Gdi.h" +#include "Gdi/ScrollBar.h" #include "Hook.h" namespace @@ -15,7 +15,7 @@ namespace }; } -namespace CompatGdi +namespace Gdi { ScrollBar::ScrollBar(HWND hwnd, HDC compatDc) : m_hwnd(hwnd), m_compatDc(compatDc), m_windowRect(), diff --git a/DDrawCompat/CompatGdiScrollBar.h b/DDrawCompat/Gdi/ScrollBar.h similarity index 97% rename from DDrawCompat/CompatGdiScrollBar.h rename to DDrawCompat/Gdi/ScrollBar.h index 8b89dd7..1838cc6 100644 --- a/DDrawCompat/CompatGdiScrollBar.h +++ b/DDrawCompat/Gdi/ScrollBar.h @@ -4,7 +4,7 @@ #include -namespace CompatGdi +namespace Gdi { class ScrollBar { diff --git a/DDrawCompat/CompatGdiScrollFunctions.cpp b/DDrawCompat/Gdi/ScrollFunctions.cpp similarity index 64% rename from DDrawCompat/CompatGdiScrollFunctions.cpp rename to DDrawCompat/Gdi/ScrollFunctions.cpp index 1e202d2..32dc50c 100644 --- a/DDrawCompat/CompatGdiScrollFunctions.cpp +++ b/DDrawCompat/Gdi/ScrollFunctions.cpp @@ -1,6 +1,6 @@ -#include "CompatGdi.h" -#include "CompatGdiScrollFunctions.h" #include "DDrawLog.h" +#include "Gdi/Gdi.h" +#include "Gdi/ScrollFunctions.h" #include "Hook.h" #include "RealPrimarySurface.h" @@ -13,7 +13,7 @@ namespace BOOL result = CALL_ORIG_FUNC(ScrollWindow)(hWnd, XAmount, YAmount, lpRect, lpClipRect); if (result) { - CompatGdiScrollFunctions::updateScrolledWindow(hWnd); + Gdi::ScrollFunctions::updateScrolledWindow(hWnd); } Compat::LogLeave("scrollWindow", hWnd, XAmount, YAmount, lpRect, lpClipRect) << result; return result; @@ -34,7 +34,7 @@ namespace hWnd, dx, dy, prcScroll, prcClip, hrgnUpdate, prcUpdate, flags); if (ERROR != result) { - CompatGdiScrollFunctions::updateScrolledWindow(hWnd); + Gdi::ScrollFunctions::updateScrolledWindow(hWnd); } Compat::LogLeave("scrollWindowEx", @@ -43,22 +43,25 @@ namespace } } -namespace CompatGdiScrollFunctions +namespace Gdi { - void installHooks() + namespace ScrollFunctions { - HOOK_FUNCTION(user32, ScrollWindow, scrollWindow); - HOOK_FUNCTION(user32, ScrollWindowEx, scrollWindowEx); - } - - void updateScrolledWindow(HWND hwnd) - { - if (CompatGdi::isEmulationEnabled()) + void installHooks() { - RealPrimarySurface::disableUpdates(); - RedrawWindow(hwnd, nullptr, nullptr, - RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW); - RealPrimarySurface::enableUpdates(); + HOOK_FUNCTION(user32, ScrollWindow, scrollWindow); + HOOK_FUNCTION(user32, ScrollWindowEx, scrollWindowEx); + } + + void updateScrolledWindow(HWND hwnd) + { + if (Gdi::isEmulationEnabled()) + { + RealPrimarySurface::disableUpdates(); + RedrawWindow(hwnd, nullptr, nullptr, + RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW); + RealPrimarySurface::enableUpdates(); + } } } } diff --git a/DDrawCompat/Gdi/ScrollFunctions.h b/DDrawCompat/Gdi/ScrollFunctions.h new file mode 100644 index 0000000..b1cbbd9 --- /dev/null +++ b/DDrawCompat/Gdi/ScrollFunctions.h @@ -0,0 +1,14 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN + +#include + +namespace Gdi +{ + namespace ScrollFunctions + { + void installHooks(); + void updateScrolledWindow(HWND hwnd); + } +} diff --git a/DDrawCompat/CompatGdiTitleBar.cpp b/DDrawCompat/Gdi/TitleBar.cpp similarity index 98% rename from DDrawCompat/CompatGdiTitleBar.cpp rename to DDrawCompat/Gdi/TitleBar.cpp index df25873..38b5196 100644 --- a/DDrawCompat/CompatGdiTitleBar.cpp +++ b/DDrawCompat/Gdi/TitleBar.cpp @@ -1,6 +1,6 @@ -#include "CompatGdi.h" -#include "CompatGdiTitleBar.h" #include "CompatPrimarySurface.h" +#include "Gdi/Gdi.h" +#include "Gdi/TitleBar.h" #include "Hook.h" namespace @@ -15,7 +15,7 @@ namespace }; } -namespace CompatGdi +namespace Gdi { TitleBar::TitleBar(HWND hwnd, HDC compatDc) : m_hwnd(hwnd), m_compatDc(compatDc), m_buttonWidth(0), m_buttonHeight(0), m_tbi(), diff --git a/DDrawCompat/CompatGdiTitleBar.h b/DDrawCompat/Gdi/TitleBar.h similarity index 96% rename from DDrawCompat/CompatGdiTitleBar.h rename to DDrawCompat/Gdi/TitleBar.h index 74e3c3b..aaa7a9d 100644 --- a/DDrawCompat/CompatGdiTitleBar.h +++ b/DDrawCompat/Gdi/TitleBar.h @@ -6,7 +6,7 @@ #include -namespace CompatGdi +namespace Gdi { class TitleBar { diff --git a/DDrawCompat/CompatGdiWinProc.cpp b/DDrawCompat/Gdi/WinProc.cpp similarity index 74% rename from DDrawCompat/CompatGdiWinProc.cpp rename to DDrawCompat/Gdi/WinProc.cpp index 288c2e1..5775d23 100644 --- a/DDrawCompat/CompatGdiWinProc.cpp +++ b/DDrawCompat/Gdi/WinProc.cpp @@ -5,13 +5,13 @@ #include #include -#include "CompatGdi.h" -#include "CompatGdiDc.h" -#include "CompatGdiScrollBar.h" -#include "CompatGdiScrollFunctions.h" -#include "CompatGdiTitleBar.h" -#include "CompatGdiWinProc.h" #include "DDrawLog.h" +#include "Gdi/Dc.h" +#include "Gdi/Gdi.h" +#include "Gdi/ScrollBar.h" +#include "Gdi/ScrollFunctions.h" +#include "Gdi/TitleBar.h" +#include "Gdi/WinProc.h" #include "ScopedCriticalSection.h" namespace @@ -40,7 +40,7 @@ namespace } else if (WM_DESTROY == ret->message) { - Compat::ScopedCriticalSection lock(CompatGdi::g_gdiCriticalSection); + Compat::ScopedCriticalSection lock(Gdi::g_gdiCriticalSection); g_prevWindowRect.erase(ret->hwnd); } else if (WM_WINDOWPOSCHANGED == ret->message) @@ -56,7 +56,7 @@ namespace auto notifCode = HIWORD(ret->wParam); if (ret->lParam && (EN_HSCROLL == notifCode || EN_VSCROLL == notifCode)) { - CompatGdiScrollFunctions::updateScrolledWindow(reinterpret_cast(ret->lParam)); + Gdi::ScrollFunctions::updateScrolledWindow(reinterpret_cast(ret->lParam)); } } else if (WM_MENUSELECT == ret->message) @@ -92,38 +92,38 @@ namespace { if (OBJID_TITLEBAR == idObject || OBJID_HSCROLL == idObject || OBJID_VSCROLL == idObject) { - if (!hwnd || !CompatGdi::beginGdiRendering()) + if (!hwnd || !Gdi::beginGdiRendering()) { return; } HDC windowDc = GetWindowDC(hwnd); - HDC compatDc = CompatGdiDc::getDc(windowDc); + HDC compatDc = Gdi::Dc::getDc(windowDc); if (compatDc) { if (OBJID_TITLEBAR == idObject) { - CompatGdi::TitleBar(hwnd, compatDc).drawButtons(); + Gdi::TitleBar(hwnd, compatDc).drawButtons(); } else if (OBJID_HSCROLL == idObject) { - CompatGdi::ScrollBar(hwnd, compatDc).drawHorizArrows(); + Gdi::ScrollBar(hwnd, compatDc).drawHorizArrows(); } else if (OBJID_VSCROLL == idObject) { - CompatGdi::ScrollBar(hwnd, compatDc).drawVertArrows(); + Gdi::ScrollBar(hwnd, compatDc).drawVertArrows(); } - CompatGdiDc::releaseDc(windowDc); + Gdi::Dc::releaseDc(windowDc); } ReleaseDC(hwnd, windowDc); - CompatGdi::endGdiRendering(); + Gdi::endGdiRendering(); } } void onActivate(HWND hwnd) { - if (!CompatGdi::isEmulationEnabled()) + if (!Gdi::isEmulationEnabled()) { return; } @@ -146,7 +146,7 @@ namespace void onMenuSelect() { - if (!CompatGdi::isEmulationEnabled()) + if (!Gdi::isEmulationEnabled()) { return; } @@ -161,17 +161,17 @@ namespace void onWindowPosChanged(HWND hwnd) { - Compat::ScopedCriticalSection lock(CompatGdi::g_gdiCriticalSection); + Compat::ScopedCriticalSection lock(Gdi::g_gdiCriticalSection); const auto it = g_prevWindowRect.find(hwnd); if (it != g_prevWindowRect.end()) { - CompatGdi::invalidate(&it->second); + Gdi::invalidate(&it->second); } if (IsWindowVisible(hwnd)) { - if (CompatGdi::isEmulationEnabled()) + if (Gdi::isEmulationEnabled()) { GetWindowRect(hwnd, it != g_prevWindowRect.end() ? &it->second : &g_prevWindowRect[hwnd]); RedrawWindow(hwnd, nullptr, nullptr, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); @@ -193,19 +193,22 @@ namespace } } -namespace CompatGdiWinProc +namespace Gdi { - void installHooks() + namespace WinProc { - const DWORD threadId = GetCurrentThreadId(); - g_callWndRetProcHook = SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId); - g_objectStateChangeEventHook = SetWinEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE, - nullptr, &objectStateChangeEvent, 0, threadId, WINEVENT_OUTOFCONTEXT); - } + void installHooks() + { + const DWORD threadId = GetCurrentThreadId(); + g_callWndRetProcHook = SetWindowsHookEx(WH_CALLWNDPROCRET, callWndRetProc, nullptr, threadId); + g_objectStateChangeEventHook = SetWinEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE, + nullptr, &objectStateChangeEvent, 0, threadId, WINEVENT_OUTOFCONTEXT); + } - void uninstallHooks() - { - UnhookWinEvent(g_objectStateChangeEventHook); - UnhookWindowsHookEx(g_callWndRetProcHook); + void uninstallHooks() + { + UnhookWinEvent(g_objectStateChangeEventHook); + UnhookWindowsHookEx(g_callWndRetProcHook); + } } } diff --git a/DDrawCompat/Gdi/WinProc.h b/DDrawCompat/Gdi/WinProc.h new file mode 100644 index 0000000..fd9b582 --- /dev/null +++ b/DDrawCompat/Gdi/WinProc.h @@ -0,0 +1,10 @@ +#pragma once + +namespace Gdi +{ + namespace WinProc + { + void installHooks(); + void uninstallHooks(); + } +} diff --git a/DDrawCompat/RealPrimarySurface.cpp b/DDrawCompat/RealPrimarySurface.cpp index 1318541..6770d52 100644 --- a/DDrawCompat/RealPrimarySurface.cpp +++ b/DDrawCompat/RealPrimarySurface.cpp @@ -1,7 +1,6 @@ #include #include "CompatDirectDrawSurface.h" -#include "CompatGdi.h" #include "CompatPaletteConverter.h" #include "CompatPrimarySurface.h" #include "CompatPtr.h" @@ -9,6 +8,7 @@ #include "DDrawScopedThreadLock.h" #include "DDrawProcs.h" #include "DDrawTypes.h" +#include "Gdi/Gdi.h" #include "Hook.h" #include "IReleaseNotifier.h" #include "RealPrimarySurface.h" @@ -375,7 +375,7 @@ void RealPrimarySurface::update() void RealPrimarySurface::updatePalette(DWORD startingEntry, DWORD count) { CompatPaletteConverter::updatePalette(startingEntry, count); - CompatGdi::updatePalette(startingEntry, count); + Gdi::updatePalette(startingEntry, count); if (CompatPrimarySurface::g_palette) { invalidate(nullptr);