Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Feature to wait for any change #49

Open
quartzsaber opened this issue Jul 24, 2021 · 0 comments
Open

Feature to wait for any change #49

quartzsaber opened this issue Jul 24, 2021 · 0 comments

Comments

@quartzsaber
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant