feat: Implement delta-update feature for efficient screen capture using dirty regions #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the delta-update feature for the Windows Desktop Duplication API screen capture library, enabling efficient capture by only updating dirty (changed) regions instead of copying the entire GPU texture to memory each frame.
Requirements Implemented
Core Changes
GetFrameDirtyRectsto retrieve the list of dirty rectangles (changed screen regions) afterAcquireNextFrameGetFrameMoveRectsto retrieve the list of moved rectangles (scrolled/moved screen regions)CopyResourcecall with targetedCopySubresourceRegioncalls that only copy the dirty and moved rectangular regions from GPU texture to memoryAPI & Compatibility
capture()andcapture_with_pointer_shape()methods continue to work without any breaking changesVecCapturerandSharedMemorybuffer typesGetFrameDirtyRects,GetFrameMoveRects,CopySubresourceRegion)Modified Files
Technical Details
The implementation adds new methods to work alongside the existing capture API:
capture_frame_dirty_rects()- Captures frame with dirty region informationcapture_frame_with_pointer_dirty_rects()- Captures frame with pointer shape and dirty region informationThese methods return both the frame data and a list of dirty/moved rectangles, allowing applications to optimize their processing by only updating the changed regions.
Benefits
Testing
The implementation has been tested to ensure:
This feature is particularly useful for applications that need efficient screen capture, such as remote desktop applications, screen recording tools, and streaming software.