@@ -32,15 +32,58 @@ pub trait Capturable {
3232 fn get_raw_handle ( & self ) -> isize ;
3333}
3434
35+ pub struct CaptureBuilder {
36+ capturable : Box < dyn Capturable > ,
37+ is_cursor_capture_enabled : bool ,
38+ is_border_required : bool ,
39+ cpu_access : bool ,
40+ }
41+
42+ impl CaptureBuilder {
43+ pub fn new ( capturable : Box < dyn Capturable > ) -> Self {
44+ Self {
45+ capturable,
46+ is_cursor_capture_enabled : false ,
47+ is_border_required : true ,
48+ cpu_access : true ,
49+ }
50+ }
51+
52+ pub fn set_is_cursor_capture_enabled ( mut self , val : bool ) -> Self {
53+ self . is_cursor_capture_enabled = val;
54+ self
55+ }
56+
57+ pub fn set_is_border_required ( mut self , val : bool ) -> Self {
58+ self . is_border_required = val;
59+ self
60+ }
61+
62+ pub fn set_cpu_access ( mut self , val : bool ) -> Self {
63+ self . cpu_access = val;
64+ self
65+ }
66+
67+ pub fn build ( self ) -> Result < Capture > {
68+ Capture :: new (
69+ self . capturable ,
70+ self . is_cursor_capture_enabled ,
71+ self . is_border_required ,
72+ self . cpu_access ,
73+ )
74+ }
75+ }
76+
77+ /// Represents a Capture session.
3578pub struct Capture {
36- pub d3d : D3D ,
79+ d3d : D3D ,
3780 capturable : Box < dyn Capturable > ,
3881 capture_box : D3D11_BOX ,
3982 capture_done_signal : Receiver < ( ) > ,
4083 frame_pool : Direct3D11CaptureFramePool ,
4184 frame_source : Receiver < Option < Direct3D11CaptureFrame > > ,
4285 session : GraphicsCaptureSession ,
43- pub cpu_access : bool ,
86+ cpu_access : bool ,
4487 staging_texture : Option < ID3D11Texture2D > ,
4588 content_size : SizeInt32 ,
4689 stopped : bool ,
@@ -51,7 +94,7 @@ impl Capture {
5194 /// frame pool / capture session.
5295 ///
5396 /// Note that this will not start capturing yet. Call `start()` to actually start receiving frames.
54- pub fn new (
97+ pub ( crate ) fn new (
5598 capturable : Box < dyn Capturable > ,
5699 is_cursor_capture_enabled : bool ,
57100 is_border_required : bool ,
@@ -119,6 +162,16 @@ impl Capture {
119162 } )
120163 }
121164
165+ /// Get D3D contexts
166+ pub fn d3d ( & mut self ) -> & mut D3D {
167+ & mut self . d3d
168+ }
169+
170+ /// Whether the backing buffer of this instance of `Capture` is CPU-accessible.
171+ pub fn has_cpu_access ( & self ) -> bool {
172+ self . cpu_access
173+ }
174+
122175 /// Get attached capturable.
123176 pub fn capturable ( & self ) -> & dyn Capturable {
124177 self . capturable . as_ref ( )
0 commit comments