This patch compatible ONLY for Win32, not for SDL!
Currently, all cursors, all blitters and all GUI sizes are supported, so practically you won't see the difference other than cursor will be more responsive. If there is something going wrong and HW cursor cannot be created - default cursor drawing routine will be used.
Algorithm is following: get current cursor SpriteID, get sprite data, decode it, create two GDI bitmaps ('and' and 'xor' masks) and DCs, write decoded pixel data into bitmaps, create HCURSOR from them and set default window's cursor to created cursor. When hardware cursor is successfully created and shown or when current cursor ID and size is same as at the moment when hw cursor was created, stop execution of cursor drawing routine. All created HCURSOR are cached, so when CursorID changed, if it has just same sprite, use cached HCURSOR instead of recreating same one. When CursorID is same, but cursor itself changed (both it's size or sprite data), destroy previously cached cursor, recreate new one and cache it.
Code: Select all
Version history:
v1.0
- Initial release.
v1.1
Fix for cursor disappearance.
Added check for fully transparent cursor.
Fixed memory leak. Previously cached cursors are now destroyed properly when cache updated.
All cursors are now supported: switch removed and cursors cache size increased.
Minor optimizations, comment lines, so on.
I don't care for good practices of coding/patching, for merging this patch into trunk, for copyrights or their violation (yes, you may copy this piece of faeces and say that you've done this), for thanks, for curses, for your opinion, for anything but bugs, so don't even bother me with this. If you found bug, especially critical one, you're welcome.