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:
parent
c384167244
commit
1ee48b11df
@ -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);
|
||||
}
|
||||
|
@ -86,18 +86,6 @@ namespace
|
||||
Result result = Compat::getOrigFuncPtr<OrigFuncPtr, origFunc>()(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
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include <atomic>
|
||||
|
||||
#include "Common/ScopedCriticalSection.h"
|
||||
#include "DDraw/RealPrimarySurface.h"
|
||||
#include "DDraw/Surfaces/PrimarySurface.h"
|
||||
@ -14,7 +12,6 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
std::atomic<int> 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<LPARAM>(rgn));
|
||||
}
|
||||
EnumThreadWindows(GetCurrentThreadId(), &redrawWindowCallback, reinterpret_cast<LPARAM>(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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<LPCSTR>(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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user