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

Enable GDI emulation in windowed mode

This commit is contained in:
narzoul 2018-03-18 17:37:50 +01:00
parent c384167244
commit 1ee48b11df
6 changed files with 7 additions and 64 deletions

View File

@ -15,13 +15,11 @@ namespace
void activateApp() void activateApp()
{ {
Gdi::enableEmulation();
Win32::FontSmoothing::setSystemSettings(g_fontSmoothingSettings); Win32::FontSmoothing::setSystemSettings(g_fontSmoothingSettings);
} }
void deactivateApp() void deactivateApp()
{ {
Gdi::disableEmulation();
g_fontSmoothingSettings = Win32::FontSmoothing::getSystemSettings(); g_fontSmoothingSettings = Win32::FontSmoothing::getSystemSettings();
Win32::FontSmoothing::setSystemSettings(Win32::FontSmoothing::g_origSystemSettings); Win32::FontSmoothing::setSystemSettings(Win32::FontSmoothing::g_origSystemSettings);
} }

View File

@ -86,18 +86,6 @@ namespace
Result result = Compat::getOrigFuncPtr<OrigFuncPtr, origFunc>()(params...); Result result = Compat::getOrigFuncPtr<OrigFuncPtr, origFunc>()(params...);
#ifdef _DEBUG #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; Compat::LogLeave(g_funcNames[origFunc], params...) << result;
#endif #endif

View File

@ -1,5 +1,3 @@
#include <atomic>
#include "Common/ScopedCriticalSection.h" #include "Common/ScopedCriticalSection.h"
#include "DDraw/RealPrimarySurface.h" #include "DDraw/RealPrimarySurface.h"
#include "DDraw/Surfaces/PrimarySurface.h" #include "DDraw/Surfaces/PrimarySurface.h"
@ -14,7 +12,6 @@
namespace namespace
{ {
std::atomic<int> g_disableEmulationCount = 0;
DWORD g_gdiThreadId = 0; DWORD g_gdiThreadId = 0;
DWORD g_renderingRefCount = 0; DWORD g_renderingRefCount = 0;
DWORD g_ddLockFlags = 0; DWORD g_ddLockFlags = 0;
@ -82,11 +79,6 @@ namespace Gdi
bool beginGdiRendering(DWORD lockFlags) bool beginGdiRendering(DWORD lockFlags)
{ {
if (!isEmulationEnabled())
{
return false;
}
Compat::ScopedCriticalSection gdiLock(g_gdiCriticalSection); Compat::ScopedCriticalSection gdiLock(g_gdiCriticalSection);
if (0 == g_renderingRefCount) if (0 == g_renderingRefCount)
@ -150,16 +142,6 @@ namespace Gdi
} }
} }
void disableEmulation()
{
++g_disableEmulationCount;
}
void enableEmulation()
{
--g_disableEmulationCount;
}
DWORD getGdiThreadId() DWORD getGdiThreadId()
{ {
return g_gdiThreadId; return g_gdiThreadId;
@ -208,10 +190,7 @@ namespace Gdi
void redraw(HRGN rgn) void redraw(HRGN rgn)
{ {
if (isEmulationEnabled()) EnumThreadWindows(GetCurrentThreadId(), &redrawWindowCallback, reinterpret_cast<LPARAM>(rgn));
{
EnumThreadWindows(GetCurrentThreadId(), &redrawWindowCallback, reinterpret_cast<LPARAM>(rgn));
}
} }
void redrawWindow(HWND hwnd, HRGN rgn) void redrawWindow(HWND hwnd, HRGN rgn)
@ -236,11 +215,6 @@ namespace Gdi
OffsetRgn(rgn, origin.x, origin.y); OffsetRgn(rgn, origin.x, origin.y);
} }
bool isEmulationEnabled()
{
return g_disableEmulationCount <= 0 && DDraw::RealPrimarySurface::isFullScreen();
}
void unhookWndProc(LPCSTR className, WNDPROC oldWndProc) void unhookWndProc(LPCSTR className, WNDPROC oldWndProc)
{ {
HWND hwnd = CreateWindow(className, nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, 0); 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) void updatePalette(DWORD startingEntry, DWORD count)
{ {
if (isEmulationEnabled() && DDraw::PrimarySurface::s_palette) if (DDraw::PrimarySurface::s_palette)
{ {
Gdi::DcCache::updatePalette(startingEntry, count); Gdi::DcCache::updatePalette(startingEntry, count);
} }

View File

@ -11,14 +11,10 @@ namespace Gdi
bool beginGdiRendering(DWORD lockFlags = 0); bool beginGdiRendering(DWORD lockFlags = 0);
void endGdiRendering(); void endGdiRendering();
void disableEmulation();
void enableEmulation();
DWORD getGdiThreadId(); DWORD getGdiThreadId();
HRGN getVisibleWindowRgn(HWND hwnd); HRGN getVisibleWindowRgn(HWND hwnd);
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc); void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc);
void installHooks(); void installHooks();
bool isEmulationEnabled();
bool isTopLevelWindow(HWND hwnd); bool isTopLevelWindow(HWND hwnd);
void redraw(HRGN rgn); void redraw(HRGN rgn);
void redrawWindow(HWND hwnd, HRGN rgn); void redrawWindow(HWND hwnd, HRGN rgn);

View File

@ -55,13 +55,10 @@ namespace Gdi
void updateScrolledWindow(HWND hwnd) void updateScrolledWindow(HWND hwnd)
{ {
if (Gdi::isEmulationEnabled()) DDraw::RealPrimarySurface::disableUpdates();
{ RedrawWindow(hwnd, nullptr, nullptr,
DDraw::RealPrimarySurface::disableUpdates(); RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW);
RedrawWindow(hwnd, nullptr, nullptr, DDraw::RealPrimarySurface::enableUpdates();
RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW);
DDraw::RealPrimarySurface::enableUpdates();
}
} }
} }
} }

View File

@ -147,11 +147,6 @@ namespace
void onActivate(HWND hwnd) void onActivate(HWND hwnd)
{ {
if (!Gdi::isEmulationEnabled())
{
return;
}
RECT windowRect = {}; RECT windowRect = {};
GetWindowRect(hwnd, &windowRect); GetWindowRect(hwnd, &windowRect);
RECT clientRect = {}; RECT clientRect = {};
@ -170,11 +165,6 @@ namespace
void onMenuSelect() void onMenuSelect()
{ {
if (!Gdi::isEmulationEnabled())
{
return;
}
HWND menuWindow = FindWindow(reinterpret_cast<LPCSTR>(0x8000), nullptr); HWND menuWindow = FindWindow(reinterpret_cast<LPCSTR>(0x8000), nullptr);
while (menuWindow) while (menuWindow)
{ {
@ -207,7 +197,7 @@ namespace
notifyFunc(hwnd, prevData.wndRect, data.wndRect); notifyFunc(hwnd, prevData.wndRect, data.wndRect);
} }
if (!prevData.sysClipRgn && !data.sysClipRgn || !Gdi::isEmulationEnabled()) if (!prevData.sysClipRgn && !data.sysClipRgn)
{ {
return; return;
} }