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

114 Commits

Author SHA1 Message Date
narzoul
04fc3c808b Added triple buffering in full screen mode
Fixes stuttering in Midtown Madness 2 Trial (and probably other games)
when V-sync is enabled.
2016-05-29 17:31:24 +02:00
narzoul
ee83a95c52 Added DDSCAPS_OFFSCREENPLAIN to surfaces with no type capability
When a surface is created without an explicit capability to specify the type
of surface to create, it only accepts a pixel format that matches the current
display mode. Since the display mode is forced to 32 bit color depth under
DDrawCompat, creating such surfaces could either fail if a different pixel
format is specified (even though it could match the emulated color depth),
or it could be created with the wrong color depth if no pixel format is given.

To prevent these issues, the DDSCAPS_OFFSCREENPLAIN capability is added to all
"untyped" surfaces, which accepts any color depth and already has code in place
to match the emulated display mode's color depth when no pixel format is given.

Fixes #1
2016-05-29 17:31:18 +02:00
narzoul
8694b9a42b Log __COMPAT_LAYER environment variable 2016-05-29 17:31:12 +02:00
narzoul
9f206897ad Disabled the IgnoreAltTab shim 2016-05-29 17:31:06 +02:00
narzoul
abb1b32f2c Restore font smoothing settings 2016-05-29 17:31:00 +02:00
narzoul
f29c371b8b Disabled dynamic thread priority boosts
Fixes performance issues in The Longest Journey.
2016-05-29 17:30:54 +02:00
narzoul
c8ecb227a3 GDI performance enhancements 2016-05-29 17:30:44 +02:00
narzoul
c4ea2541a9 Moved display mode operations to CompatDisplayMode 2016-05-29 17:26:02 +02:00
narzoul
cf08f10162 Improved GetPixel performance via DDLOCK_READONLY
Reduces Diablo II startup time.
2016-05-29 17:02:59 +02:00
narzoul
b78ea774d7 Disabled the VirtualizeDesktopPainting shim 2016-05-29 17:02:53 +02:00
narzoul
f973291f93 Replaced DirectDraw palette and clipper raw pointers with smart pointers 2016-05-29 17:02:47 +02:00
narzoul
e8f4a970e0 Replaced IDirectDraw raw pointers with smart pointers 2016-05-29 17:02:34 +02:00
narzoul
068cdb8028 Replaced IDirectDrawSurface raw pointers with smart pointers 2016-05-29 16:59:35 +02:00
narzoul
70a29c2f12 Fixed unsafe use of released primary surface interface 2016-05-29 16:59:29 +02:00
narzoul
2717b095ec Restore main window, last active popup and GDI on WM_ACTIVATEAPP
Fixes an issue with Fallout's window disappearing from the taskbar every other
time it's minimized.
Also fixes StarCraft's Save Screen Capture dialog being hidden after the main
window is restored.
2016-05-10 00:04:21 +02:00
narzoul
fef2598e5f Do not minimize on deactivation if DDSCL_NOWINDOWCHANGES is set
Fixes alt-tabbing issues in Age of Wonders 2 that was making it difficult
to properly activate the minimized game.
2016-05-08 21:57:51 +02:00
narzoul
639d0ce8fb Disable setting full-screen cooperative level while the app is inactive
Commandos 2 reacts to WM_DISPLAYCHANGE messages by reapplying the full-screen
cooperative level and the display mode. This makes the RestoreDisplayMode call
(which itself generates WM_DISPLAYCHANGE) ineffective.
Additionally, on WM_ACTIVATE it removes the primary surface, which DDrawCompat
was relying on for full-screen detection.

This fix returns DDERR_EXCLUSIVEMODEALREADYSET if the app tries to set
full-screen cooperative level while inactive. The tracking of full-screen
mode is now done via a dummy surface instead of the primary surface.
2016-05-08 21:57:26 +02:00
narzoul
c647f4b2ef Disabled GDI emulation while the app is inactive v0.2.1 2016-05-03 23:02:46 +02:00
narzoul
fe8abe9d5a Avoid side effects when method implementations are delegated to higher versions
Some DirectDraw methods are implemented by delegating to the same method
in a higher interface version. In this case, the hooking logic could be
executed twice, leading to unwanted side effects. This is now avoided.
2016-05-03 23:02:39 +02:00
narzoul
f7f5348a87 Fixed/simplified hooking logic for COM methods 2016-05-03 23:02:33 +02:00
narzoul
e4b67be7ec Fixed misleading error messages 2016-05-03 22:12:46 +02:00
narzoul
5e972cf056 Handle WM_ACTIVATEAPP messages
Aiming to fix Alt-Tabbing issues (such as black screen instead of desktop)
by temporarily setting the cooperative level to windowed mode, restoring
the display mode and minimizing the main window when the app is inactive.
2016-05-03 22:12:25 +02:00
narzoul
f0425495bc Updated disabling of immersive context menus 2016-04-30 23:43:40 +02:00
narzoul
441d7794cd Fixed hangups caused by unreleased back buffer surface 2016-04-30 23:43:20 +02:00
narzoul
495325c984 Moved cached surfaces to DDrawRepository 2016-04-26 23:26:33 +02:00
narzoul
9ddeab4149 Removed hooks on DLL_PROCESS_DETACH
Fixes a crash when opening Blood 2's display settings from the launcher.
2016-04-20 00:07:18 +02:00
narzoul
44cc4c2ad5 Disabled smooth scrolling
Prevents a visual artifact where the area that is supposed to scroll out of view
remains static during the smooth scrolling animation.
2016-04-18 22:32:27 +02:00
narzoul
a8834453e0 Added default paint handlers for ComboListBox controls
Now the background is properly erased and the scroll bar updated when scrolling.
2016-04-18 22:14:53 +02:00
narzoul
90fa9459d2 Reduced flickering when scrolling or erasing background 2016-04-17 22:56:25 +02:00
narzoul
74f306b5b0 Fixed synchronization issue in beginGdiRendering
It's not sufficient to make g_renderingRefCount atomic, because after it is
found to be nonzero in beginGdiRendering, a call to endGdiRendering from
another thread may make it zero before beginGdiRendering has a chance of
entering the critical section. This would mean that the DirectDraw primary
surface is no longer locked, even though beginGdiRendering expects that it is.

To prevent potential issues, the g_renderingRefCount check is now also
guarded by the critical section.
2016-04-17 21:13:16 +02:00
narzoul
cc5a4c7cef Readded palette animation support 2016-04-17 19:04:15 +02:00
narzoul
d4042f7e95 Support PC_RESERVED palette entry flag for GDI rendering 2016-04-17 19:04:04 +02:00
narzoul
111719eaf7 Removed unnecessary GDI redraws when GDI emulation is disabled 2016-04-17 19:02:54 +02:00
narzoul
e774564467 Improved scheduling of real primary surface updates 2016-04-17 19:01:25 +02:00
narzoul
2937bde6a4 Introduced a common RAII class for critical sections 2016-04-17 19:01:03 +02:00
narzoul
0a05ef1174 Call WindowFromDC through IAT
GetWindowDC(GetDC(NULL)) may return a special window with a class name of
"CompatWindowDesktopReplacement". Presumably the shim engine installs an
IAT hook for GetWindowDC that replaces this window handle with the normal
desktop window handle.

CALL_ORIG_FUNC(WindowFromDC) returns with an unpatched pointer, therefore
it doesn't perform the above replacement. This results in using the
replacement window's clipping region (whole screen) instead of the desktop
window's clipping region (empty), and things become visible that shouldn't
be, e.g. some character symbols at the top left corner of the screen when
launchning Diablo II.

As a workaround, WindowFromDC is used without CALL_ORIG_FUNC.
2016-04-10 20:37:00 +02:00
narzoul
ac9dbc72de Update only the dirty rectangle on the real primary surface 2016-04-10 17:37:01 +02:00
narzoul
1a3cb2be4d Added invalidation of non-client area on WM_ACTIVATE 2016-04-06 22:35:54 +02:00
narzoul
f12b95ec9f Removed unnecessary GDI redraws 2016-04-06 21:18:26 +02:00
narzoul
bb83780f0a Fixed title bar style issues and text positioning 2016-04-04 22:59:38 +02:00
narzoul
2d30ff6f94 Fixed GDI clipping issues 2016-04-03 20:36:21 +02:00
narzoul
c78c7c927f Aligned usage of flip between compat and real primary surface chains
Using flip for direct front buffer updates can cause performance problems
if the driver forces vertical sync and overrides the DDFLIP_NOVSYNC flag.

On the other hand, DDFLIP_NOVSYNC flip requests on the compat primary
surface should be handled via real flip to allow vertical sync override.
2016-04-03 20:35:59 +02:00
narzoul
be67dff295 Avoid unnecessary palette updates 2016-04-03 13:06:04 +02:00
narzoul
9aa22534ab Fixed crash due to setting clipper on uninitialized palette converter 2016-04-03 11:15:21 +02:00
narzoul
607eb5e25b Simplified caret handling and fixed positioning issues 2016-04-02 23:24:25 +02:00
narzoul
fd1063defe Default paint handlers for Edit and ListBox controls
Missing WM_NCPAINT handler for ListBox was causing the non-client area
to display incorrectly. Now the same handler is used as for DefWindowProc.
2016-04-02 01:00:00 +02:00
narzoul
3827007c0c Avoid forced invalidation of the scroll bar child control when scrolling
This was causing the scroll bar arrows to lose their pressed appearance.
2016-03-31 23:06:18 +02:00
narzoul
d0fbd5cfd0 Fixed another GDI deadlock
Scenario:
Thread #1 enters the DirectDraw critical section
Thread #2 enters the GDI critical section
Thread #2 starts waiting on the DirectDraw critical section
Thread #1 starts waiting on the GDI critical section

Solution:
If the primary surface has not been locked yet, enter the DirectDraw critical
section before entering the GDI critical section.
2016-03-31 23:06:12 +02:00
narzoul
6f643ecf7e Fixed popup menu palette issues 2016-03-31 23:06:06 +02:00
narzoul
ac305fbbba DIB based palette converter 2016-03-31 23:06:00 +02:00