From 1ee48b11dfcb35a40c1c9e141b7fb5336615ce7a Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 18 Mar 2018 17:37:50 +0100 Subject: [PATCH] Enable GDI emulation in windowed mode --- DDrawCompat/DDraw/ActivateAppHandler.cpp | 2 -- DDrawCompat/Gdi/DcFunctions.cpp | 12 ---------- DDrawCompat/Gdi/Gdi.cpp | 30 ++---------------------- DDrawCompat/Gdi/Gdi.h | 4 ---- DDrawCompat/Gdi/ScrollFunctions.cpp | 11 ++++----- DDrawCompat/Gdi/WinProc.cpp | 12 +--------- 6 files changed, 7 insertions(+), 64 deletions(-) diff --git a/DDrawCompat/DDraw/ActivateAppHandler.cpp b/DDrawCompat/DDraw/ActivateAppHandler.cpp index b990a49..70e96f8 100644 --- a/DDrawCompat/DDraw/ActivateAppHandler.cpp +++ b/DDrawCompat/DDraw/ActivateAppHandler.cpp @@ -15,13 +15,11 @@ namespace void activateApp() { - Gdi::enableEmulation(); Win32::FontSmoothing::setSystemSettings(g_fontSmoothingSettings); } void deactivateApp() { - Gdi::disableEmulation(); g_fontSmoothingSettings = Win32::FontSmoothing::getSystemSettings(); Win32::FontSmoothing::setSystemSettings(Win32::FontSmoothing::g_origSystemSettings); } diff --git a/DDrawCompat/Gdi/DcFunctions.cpp b/DDrawCompat/Gdi/DcFunctions.cpp index 58ffe50..b777784 100644 --- a/DDrawCompat/Gdi/DcFunctions.cpp +++ b/DDrawCompat/Gdi/DcFunctions.cpp @@ -86,18 +86,6 @@ namespace Result result = Compat::getOrigFuncPtr()(params...); #ifdef _DEBUG - if (!hasDisplayDcArg(params...)) - { - Compat::Log() << "Skipping redirection since there is no display DC argument"; - } - else if (!Gdi::isEmulationEnabled()) - { - Compat::Log() << "Skipping redirection since GDI emulation is disabled"; - } - else - { - Compat::Log() << "Skipping redirection since the primary surface could not be locked"; - } Compat::LogLeave(g_funcNames[origFunc], params...) << result; #endif diff --git a/DDrawCompat/Gdi/Gdi.cpp b/DDrawCompat/Gdi/Gdi.cpp index 2a9cf4a..6248899 100644 --- a/DDrawCompat/Gdi/Gdi.cpp +++ b/DDrawCompat/Gdi/Gdi.cpp @@ -1,5 +1,3 @@ -#include - #include "Common/ScopedCriticalSection.h" #include "DDraw/RealPrimarySurface.h" #include "DDraw/Surfaces/PrimarySurface.h" @@ -14,7 +12,6 @@ namespace { - std::atomic g_disableEmulationCount = 0; DWORD g_gdiThreadId = 0; DWORD g_renderingRefCount = 0; DWORD g_ddLockFlags = 0; @@ -82,11 +79,6 @@ namespace Gdi bool beginGdiRendering(DWORD lockFlags) { - if (!isEmulationEnabled()) - { - return false; - } - Compat::ScopedCriticalSection gdiLock(g_gdiCriticalSection); if (0 == g_renderingRefCount) @@ -150,16 +142,6 @@ namespace Gdi } } - void disableEmulation() - { - ++g_disableEmulationCount; - } - - void enableEmulation() - { - --g_disableEmulationCount; - } - DWORD getGdiThreadId() { return g_gdiThreadId; @@ -208,10 +190,7 @@ namespace Gdi void redraw(HRGN rgn) { - if (isEmulationEnabled()) - { - EnumThreadWindows(GetCurrentThreadId(), &redrawWindowCallback, reinterpret_cast(rgn)); - } + EnumThreadWindows(GetCurrentThreadId(), &redrawWindowCallback, reinterpret_cast(rgn)); } void redrawWindow(HWND hwnd, HRGN rgn) @@ -236,11 +215,6 @@ namespace Gdi OffsetRgn(rgn, origin.x, origin.y); } - bool isEmulationEnabled() - { - return g_disableEmulationCount <= 0 && DDraw::RealPrimarySurface::isFullScreen(); - } - void unhookWndProc(LPCSTR className, WNDPROC oldWndProc) { HWND hwnd = CreateWindow(className, nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, 0); @@ -257,7 +231,7 @@ namespace Gdi void updatePalette(DWORD startingEntry, DWORD count) { - if (isEmulationEnabled() && DDraw::PrimarySurface::s_palette) + if (DDraw::PrimarySurface::s_palette) { Gdi::DcCache::updatePalette(startingEntry, count); } diff --git a/DDrawCompat/Gdi/Gdi.h b/DDrawCompat/Gdi/Gdi.h index d9e3211..bf5ff47 100644 --- a/DDrawCompat/Gdi/Gdi.h +++ b/DDrawCompat/Gdi/Gdi.h @@ -11,14 +11,10 @@ namespace Gdi bool beginGdiRendering(DWORD lockFlags = 0); void endGdiRendering(); - void disableEmulation(); - void enableEmulation(); - DWORD getGdiThreadId(); HRGN getVisibleWindowRgn(HWND hwnd); void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc); void installHooks(); - bool isEmulationEnabled(); bool isTopLevelWindow(HWND hwnd); void redraw(HRGN rgn); void redrawWindow(HWND hwnd, HRGN rgn); diff --git a/DDrawCompat/Gdi/ScrollFunctions.cpp b/DDrawCompat/Gdi/ScrollFunctions.cpp index 1bd735f..0d1f9f7 100644 --- a/DDrawCompat/Gdi/ScrollFunctions.cpp +++ b/DDrawCompat/Gdi/ScrollFunctions.cpp @@ -55,13 +55,10 @@ namespace Gdi void updateScrolledWindow(HWND hwnd) { - if (Gdi::isEmulationEnabled()) - { - DDraw::RealPrimarySurface::disableUpdates(); - RedrawWindow(hwnd, nullptr, nullptr, - RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW); - DDraw::RealPrimarySurface::enableUpdates(); - } + DDraw::RealPrimarySurface::disableUpdates(); + RedrawWindow(hwnd, nullptr, nullptr, + RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW); + DDraw::RealPrimarySurface::enableUpdates(); } } } diff --git a/DDrawCompat/Gdi/WinProc.cpp b/DDrawCompat/Gdi/WinProc.cpp index 0aa0179..25b0f91 100644 --- a/DDrawCompat/Gdi/WinProc.cpp +++ b/DDrawCompat/Gdi/WinProc.cpp @@ -147,11 +147,6 @@ namespace void onActivate(HWND hwnd) { - if (!Gdi::isEmulationEnabled()) - { - return; - } - RECT windowRect = {}; GetWindowRect(hwnd, &windowRect); RECT clientRect = {}; @@ -170,11 +165,6 @@ namespace void onMenuSelect() { - if (!Gdi::isEmulationEnabled()) - { - return; - } - HWND menuWindow = FindWindow(reinterpret_cast(0x8000), nullptr); while (menuWindow) { @@ -207,7 +197,7 @@ namespace notifyFunc(hwnd, prevData.wndRect, data.wndRect); } - if (!prevData.sysClipRgn && !data.sysClipRgn || !Gdi::isEmulationEnabled()) + if (!prevData.sysClipRgn && !data.sysClipRgn) { return; }