Skip to content

Commit

Permalink
Added const fn 🔥
Browse files Browse the repository at this point in the history
	modified:   src/capture.rs
	modified:   src/frame.rs
  • Loading branch information
NiiightmareXD committed Sep 23, 2023
1 parent 77c3a62 commit 2e7a86e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct WindowsCapture {

impl WindowsCapture {
pub fn new<T: WindowsCaptureHandler + std::marker::Send + 'static>(
_item: GraphicsCaptureItem,
item: GraphicsCaptureItem,
trigger: T,
) -> Result<Self, Box<dyn std::error::Error>> {
// Check Support
Expand All @@ -98,19 +98,19 @@ impl WindowsCapture {
&device,
DirectXPixelFormat::B8G8R8A8UIntNormalized,
2,
_item.Size()?,
item.Size()?,
)?;

// Init
let session = frame_pool.CreateCaptureSession(&_item)?;
let session = frame_pool.CreateCaptureSession(&item)?;
let trigger = Arc::new(Mutex::new(trigger));
let trigger_item = trigger.clone();
let trigger_frame_pool = trigger;
let frame_pool = Arc::new(frame_pool);
let device = SendDirectX::new(device);

// Set CaptureItem Closed Event
_item.Closed(
item.Closed(
&TypedEventHandler::<GraphicsCaptureItem, IInspectable>::new({
move |_, _| {
trigger_item.lock().on_closed();
Expand All @@ -127,7 +127,7 @@ impl WindowsCapture {
&TypedEventHandler::<Direct3D11CaptureFramePool, IInspectable>::new({
let context = unsafe { d3d_device.GetImmediateContext()? };
let frame_pool = frame_pool.clone();
let mut last_size = _item.Size()?;
let mut last_size = item.Size()?;

move |frame, _| {
// Get Frame
Expand Down
4 changes: 2 additions & 2 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Frame<'a> {

impl<'a> Frame<'a> {
/// Craete A New Frame
pub fn new(
pub const fn new(
surface: &'a IDirect3DSurface,
d3d_device: &'a ID3D11Device,
context: &'a ID3D11DeviceContext,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl<'a> Frame<'a> {
}

/// Get The Raw IDirect3DSurface
pub fn get_raw_surface(&self) -> &'a IDirect3DSurface {
pub const fn get_raw_surface(&self) -> &'a IDirect3DSurface {
self.surface
}
}
Expand Down

0 comments on commit 2e7a86e

Please sign in to comment.