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

Feature to wait for any change #49

@quartzsaber

Description

@quartzsaber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions