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

616 Commits

Author SHA1 Message Date
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
narzoul
71e90210ad Introduced a DirectDraw repository for reusable objects 2016-03-31 23:05:54 +02:00
narzoul
0c030f8d57 Eliminated flickering in popup menus
DC redirection for popup menus is suppressed unless requested from WM_PAINT.
2016-03-31 23:05:48 +02:00
narzoul
460433c858 Hooked GdiDrawStream 2016-03-27 12:11:07 +02:00
narzoul
4f4b0cf732 Disabled immersive context menus
Immersive context menus don't display correctly when theming is disabled:
all menu items have empty labels and no icons.
Disabled this menu style through a faked registry value.
2016-03-24 23:12:28 +01:00
narzoul
62334dd32a Handle null pointers when logging strings 2016-03-24 22:57:45 +01:00
narzoul
96ba6c4b5b Handle undocumented menu selection change message
Now the selection is properly cleared also when the mouse leaves the menu window area.
2016-03-21 23:30:53 +01:00
narzoul
68d3c75c95 Extracted function hooking to its own unit 2016-03-21 22:51:56 +01:00
narzoul
1a7319dbee Updated readme
Some minor tweaks and removed development details as I'm too lazy to keep it up to date.
2016-03-21 00:08:13 +01:00
narzoul
7c06d9440b Added WM_PAINT handling for popup menus 2016-03-20 22:58:51 +01:00
narzoul
91a158020a Added WM_PAINT handling for scroll bar controls
Now size box rendering works correctly, so no need for that workaround in
CompatGdiScrollBar.
There seems to be a bug with subclassing scroll bars though, as the cursor
will no longer change to a sizing arrow when it's over a size box control.
At least there is a simple workaround for that via WM_SETCURSOR.
2016-03-20 22:58:11 +01:00
narzoul
6850fc449c Moved WM_ERASEBKGND handling to DefWindowProc
Unfortunately, Edit and ListBox controls don't seem to handle WM_ERASEBKGND
through DefWindowProc, so their window procedures need additional hooking.
2016-03-19 21:41:04 +01:00
narzoul
7ece7eed97 Moved WM_NCPAINT handling to DefWindowProc 2016-03-19 19:25:13 +01:00
narzoul
71586cc994 Hooked PolyPatBlt
Makes the button highlight workaround unnecessary.
2016-03-19 19:09:39 +01:00
narzoul
8c286d21bd Additional debug info for HWND and HDC parameters 2016-03-19 17:13:37 +01:00
narzoul
8e456eafcb Implemented WindowFromDC for compat DCs 2016-03-19 17:13:31 +01:00
narzoul
e8c5cd02d3 Added handling of WM_PRINT and WM_PRINTCLIENT through DefDlgProc/DefWindowProc 2016-03-19 17:13:14 +01:00
narzoul
c93da30330 Added child window invalidation to scroll functions 2016-03-19 13:38:41 +01:00
narzoul
53ae753ae0 Moved unrelated functions from CompatGdiDcFunctions to a new namespace 2016-03-19 13:33:07 +01:00
narzoul
0b5247d93d Moved HOOK_GDI_FUNCTION macro to resuable scope 2016-03-19 13:26:34 +01:00
narzoul
27eec14ee1 Renamed the namespace, functions and macros in CompatGdiDcFunctions 2016-03-19 13:22:30 +01:00
narzoul
ffc74aeb26 Renamed CompatGdiFunctions source files to CompatGdiDcFunctions 2016-03-19 13:15:22 +01:00
narzoul
631c701e57 Implemented copying of GDI DC transformations, mapping mode and layout 2016-03-15 11:03:58 +01:00
narzoul
aed19e5179 Removed dead code
The oject type of DCs created by DirectDraw is OBJ_MEMDC, so getDc would have
already returned nullptr earlier.
2016-03-06 16:47:02 +01:00
narzoul
c0fd60207a Added invalidation of child windows on scroll events
Fixed in issue with adjusting the game speed slider in StarCraft's Battle.net interface.
It was resulting in a WM_HSCROLL message erasing the parent window background without also
redrawing the child windows (labels) on it.
2016-02-28 17:45:45 +01:00
narzoul
fa69ef4a17 Improved debug logging of GDI function calls and window messages 2016-02-28 17:40:50 +01:00
narzoul
2f85be8952 Workaround for corrupted background on toolbar icons 2016-02-27 19:26:50 +01:00
narzoul
1ab496cbf5 Minimize invalidation on window position changes 2016-02-21 12:03:31 +01:00
narzoul
0244c8c022 Added manual rendering of default push button highlight 2016-02-19 23:23:39 +01:00
narzoul
3588072155 Fixed caret position and visibility issues 2016-02-15 22:39:51 +01:00
narzoul
941b55f546 Improved detection of scrolling events 2016-02-15 22:39:44 +01:00
narzoul
4a83a15d78 Invalidate GDI content when palette changes 2016-02-15 22:39:37 +01:00
narzoul
d51cfa1b14 Fixed/refactored manual rendering of the size box 2016-02-15 22:39:30 +01:00
narzoul
66ebcd7696 Added manual rendering of scroll bar arrows 2016-02-15 22:39:22 +01:00
narzoul
ab35223c2f Added manual rendering of title bars 2016-02-15 22:39:15 +01:00
narzoul
93e06700c1 Updated the readme with license info 2016-02-05 00:36:52 +01:00
narzoul
1a1d3c4ac3 Added LICENSE.txt 2016-02-05 00:09:48 +01:00
narzoul
acd61bbed3 Disabled DWM transitions and nonclient area rendering
Disabling DWM nonclient area rendering restores proper hit testing for the
non-themed caption buttons.
Transitions are disabled just in case.
2016-01-23 23:36:01 +01:00
narzoul
e258a17b18 Draw size box for windows with WS_SIZEBOX style 2016-01-23 23:01:01 +01:00
narzoul
7555fb02d2 Fixed scrollbars not updating when scrolling
The nonclient area is now also invalidated when scrolling.
Added similar handling for WM_MOUSEWHEEL messages.
2016-01-23 20:40:01 +01:00
narzoul
3007169592 Added GDI redirection for some additional functions 2016-01-23 17:02:41 +01:00
narzoul
14d28fe7ac Added logging of wide-character string parameters 2016-01-23 17:00:29 +01:00
narzoul
a573c1344c Fixed GDI interworking deadlocks
Because both the DirectDraw and GDI thread locks are held by the thread that
initially calls beginGdiRendering, a deadlock can occur if a complex rendering
operation uses synchronized worker threads for some subtasks and they also need
access to the resources locked by the initial thread.

To resolve this, the GDI thread lock is no longer held after beginGdiRendering
returns, and the DirectDraw thread lock is only taken during the initial entry.

However, this introduces another problem, because now the final endGdiRendering
might not be called by the same thread that initially called beginGdiRendering.
If this happens, a deadlock will occur because the initial thread is still
holding the DirectDraw thread lock while the other thread is trying to acquire
it to unlock the primary surface.

To resolve this, the initial thread will always be the one to release the lock
on the primary surface, waiting for other threads to finish using GDI DCs if
necessary. This also means that other threads won't be able to create new
cached DCs (as they would need the DD thread lock), so to prevent yet another
deadlock, the initial thread always preallocates a number of DCs in the cache,
and only the initial thread is allowed to extend the cache.
2016-01-19 20:08:13 +01:00
narzoul
acbc183d00 Disabled themes, fixed nonclient area rendering and caret deadlock
Disabled visual styles and added WM_NCPAINT handling (as a simple BitBlt copy
from the original DC) to reduce glitches in rendering of common controls and
windows, such as the GetSaveFileName dialog window in StarCraft.

Fixed a deadlock in the caret emulation code caused by locking the GDI
critical section prior to calling beginGdiRendering, which is locking both the
DirectDraw and GDI critical sections. Another thread that only calls
beginGdiRendering without entering the GDI critical section first could thus
run into a deadlock as both threads were waiting on each other's critical
sections.
Now the global caret data has it its own critical section instead of sharing
the GDI critical section.
2016-01-17 15:31:08 +01:00
narzoul
2a23cf5636 Added files missing from 2 commits earlier
Some new files were accidentally left out of a previous commit:
"Revamping GDI interworking - Part 2" 1999d1c56ef4af2b173764a0dffff0c270357628

The missing files are now added.
v0.2.0b
2016-01-17 14:47:47 +01:00
narzoul
1883d919da Fixed slowdowns caused by palette animation support
The vsynced paletted update is causing performance problems in games that
frequently update the palette outside of a palette animation loop, e.g. StarCraft.

Vsync has been removed from the palette update, and instead a primary surface
synchronization is forced on the main thread, which still seems to preserve
the palette fade-in/fade-out effects in Fallout. Perhaps only the small delay
introduced by the sync was needed? (Seems it would work with Sleep(1) too).
v0.2.0
2016-01-10 21:00:21 +01:00
narzoul
1999d1c56e Revamping GDI interworking - Part 2
Extended GDI redirection to most of the GDI rendering methods.
Readded handling of window messages and extended it to support scrolling.
Readded manual drawing of the caret.
Simplified the DC cache.
2016-01-10 00:23:32 +01:00
narzoul
5a30b072ba Revamping GDI interworking - Part 1
Previous method of GDI interworking does not seem feasible anymore as it is
leaking GDI resources in more complex scenarios (StarCraft). There does not
seem to be a way to prevent all leaks as the ReleaseDC hook does not capture
all released DCs.

New method redirects the individual GDI drawing methods instead by replacing
DCs only temporarily for each operation. Currently only BitBlt is supported
(which seems sufficient for Deadlock 2).

Also, writing to unlocked video surface memory no longer works on Windows 10.
To work around this restriction, the primary surface is temporarily locked
for the duration of each GDI rendering operation.
v0.2.0pre
2016-01-04 23:37:58 +01:00
narzoul
2dc8d4f13b Added a DC cache for GDI interworking
A certain number of DCs are now created upfront and cached to reduce the likelihood
of deadlocks. This avoids having to enter the DD critical section to create new DCs
in most cases.

This change seems to resolve deadlock issues when Alt-Tabbing in Deadlock 2.
v0.1.3
2016-01-02 19:15:53 +01:00