Problem
pixel_search iterates pixel-by-pixel calling GetPixel() — a GDI round-trip per pixel. A full-screen 1920×1080 region = 2M GDI calls taking seconds.
Proposed Solution
Use GetDIBits to capture the entire region into a memory buffer (one GDI call), then scan the buffer in-memory. Trade-off: ~8MB memory for full-screen 32-bit capture, released immediately after search. Speedup: 100-1000× for large regions.
References
- Performance audit item 5
core/src/win32_backend.cpp:439-458
Problem
pixel_searchiterates pixel-by-pixel callingGetPixel()— a GDI round-trip per pixel. A full-screen 1920×1080 region = 2M GDI calls taking seconds.Proposed Solution
Use
GetDIBitsto capture the entire region into a memory buffer (one GDI call), then scan the buffer in-memory. Trade-off: ~8MB memory for full-screen 32-bit capture, released immediately after search. Speedup: 100-1000× for large regions.References
core/src/win32_backend.cpp:439-458