D3DShot icon indicating copy to clipboard operation
D3DShot copied to clipboard

Feature to wait for any change

Open quartzsaber opened this issue 3 years ago • 0 comments

I needed to detect if a specific region has changed. So I've built a loop waiting for any changes in a specific region, but it used too much CPU. I've found out my program was running very fast, around 180 fps.

If there was a method to wait for any potention change in the region, it would help to reduce CPU usage drastically. I think it's possible to do that cheaply using IDXGIOutputDuplication::GetFrameDirtyRects(). (Or simply waiting for AcquireNextFrame to return would also work, although it would not benefit from specifying a small region.)

API proposal Signature: D3DShot.wait_for_change(self, timeout=None) Returns: True if a potantial change was detected, False if timeout was reached Precondition: A high-speed screen capture was started. (i.e. capture() was called) Description: Blocks until a potential change in the region is detected. Blocks at most timeout seconds. (None means forever.) Note: The system may collapse several dirty rects into one giant rect, so spurious awakenings might happen. It means that if you need to be certain that the region has changed at all, you need to check it yourself.

quartzsaber avatar Jul 24 '21 03:07 quartzsaber