mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Disabled GDI emulation while the app is inactive
This commit is contained in:
parent
fe8abe9d5a
commit
c647f4b2ef
@ -1,6 +1,7 @@
|
|||||||
#include "CompatActivateAppHandler.h"
|
#include "CompatActivateAppHandler.h"
|
||||||
#include "CompatDirectDraw.h"
|
#include "CompatDirectDraw.h"
|
||||||
#include "CompatDirectDrawSurface.h"
|
#include "CompatDirectDrawSurface.h"
|
||||||
|
#include "CompatGdi.h"
|
||||||
#include "CompatPrimarySurface.h"
|
#include "CompatPrimarySurface.h"
|
||||||
#include "DDrawLog.h"
|
#include "DDrawLog.h"
|
||||||
#include "RealPrimarySurface.h"
|
#include "RealPrimarySurface.h"
|
||||||
@ -54,9 +55,11 @@ namespace
|
|||||||
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
|
CompatDirectDraw<IDirectDraw7>::s_origVtable.SetDisplayMode(
|
||||||
dd, dm.width, dm.height, 32, dm.refreshRate, 0);
|
dd, dm.width, dm.height, 32, dm.refreshRate, 0);
|
||||||
}
|
}
|
||||||
|
CompatGdi::enableEmulation();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CompatGdi::disableEmulation();
|
||||||
if (CompatPrimarySurface::isDisplayModeChanged)
|
if (CompatPrimarySurface::isDisplayModeChanged)
|
||||||
{
|
{
|
||||||
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(dd);
|
CompatDirectDraw<IDirectDraw7>::s_origVtable.RestoreDisplayMode(dd);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include "CompatDirectDrawPalette.h"
|
#include "CompatDirectDrawPalette.h"
|
||||||
#include "CompatDirectDrawSurface.h"
|
#include "CompatDirectDrawSurface.h"
|
||||||
#include "CompatGdi.h"
|
#include "CompatGdi.h"
|
||||||
@ -15,6 +17,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
std::atomic<int> g_disableEmulationCount = 0;
|
||||||
DWORD g_renderingRefCount = 0;
|
DWORD g_renderingRefCount = 0;
|
||||||
DWORD g_ddLockThreadRenderingRefCount = 0;
|
DWORD g_ddLockThreadRenderingRefCount = 0;
|
||||||
DWORD g_ddLockThreadId = 0;
|
DWORD g_ddLockThreadId = 0;
|
||||||
@ -154,6 +157,16 @@ namespace CompatGdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void disableEmulation()
|
||||||
|
{
|
||||||
|
++g_disableEmulationCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void enableEmulation()
|
||||||
|
{
|
||||||
|
--g_disableEmulationCount;
|
||||||
|
}
|
||||||
|
|
||||||
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc)
|
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -193,7 +206,7 @@ namespace CompatGdi
|
|||||||
|
|
||||||
bool isEmulationEnabled()
|
bool isEmulationEnabled()
|
||||||
{
|
{
|
||||||
return RealPrimarySurface::isFullScreen();
|
return g_disableEmulationCount <= 0 && RealPrimarySurface::isFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unhookWndProc(LPCSTR className, WNDPROC oldWndProc)
|
void unhookWndProc(LPCSTR className, WNDPROC oldWndProc)
|
||||||
|
@ -9,6 +9,9 @@ namespace CompatGdi
|
|||||||
bool beginGdiRendering();
|
bool beginGdiRendering();
|
||||||
void endGdiRendering();
|
void endGdiRendering();
|
||||||
|
|
||||||
|
void disableEmulation();
|
||||||
|
void enableEmulation();
|
||||||
|
|
||||||
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc);
|
void hookWndProc(LPCSTR className, WNDPROC &oldWndProc, WNDPROC newWndProc);
|
||||||
void installHooks();
|
void installHooks();
|
||||||
void invalidate(const RECT* rect);
|
void invalidate(const RECT* rect);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user