跳到主要内容

DxgiDuplicationApi

搜索

结构体 DxgiDuplicationApi 

Source
pub struct DxgiDuplicationApi { /* private fields */ }
展开描述

一个最小化、易用的 DXGI 桌面复制 API 包装器,用于捕获显示器画面。

该包装器力求贴近原生 API,同时提供简洁的 Rust 接口。 它与 crate::monitor::Monitor 集成以选择目标输出。

实现§

Source§

impl DxgiDuplicationApi

Source

pub fn new(monitor: Monitor) -> Result<Self, Error>

为指定的显示器构造一个新的复制会话。

内部使用本 crate 的 d3d11 模块创建 Direct3D 11 设备和即时上下文。

Source

pub fn new_options( monitor: Monitor, supported_formats: &[DxgiDuplicationFormat], ) -> Result<Self, Error>

为指定的显示器构造一个新的复制会话,使用自定义的 DXGI 支持格式列表。

该方法允许直接接收正在运行的全屏应用程序所使用的原始后缓冲格式。

会额外插入 Bgra8,因为它被广泛支持,可作为可靠的回退选项。

Source

pub fn recreate(self) -> Result<Self, Error>

重新创建复制接口,主要在 DxgiDuplicationApi::acquire_next_frame 返回 Error::AccessLost 错误之后调用。

Source

pub fn recreate_options( self, supported_formats: &[DxgiDuplicationFormat], ) -> Result<Self, Error>

使用自定义的 DXGI 支持格式列表重新创建复制接口,主要在 DxgiDuplicationApi::acquire_next_frame 返回 Error::AccessLost 错误之后调用。

Source

pub const fn device(&self) -> &ID3D11Device

获取与该对象关联的底层 [windows::Win32::Graphics::Direct3D11::ID3D11Device]。

Source

pub const fn device_context(&self) -> &ID3D11DeviceContext

获取用于 GPU 操作的底层 [windows::Win32::Graphics::Direct3D11::ID3D11DeviceContext]。

Source

pub const fn duplication(&self) -> &IDXGIOutputDuplication

获取底层的 [windows::Win32::Graphics::Dxgi::IDXGIOutputDuplication] 接口。

Source

pub const fn duplication_desc(&self) -> &DXGI_OUTDUPL_DESC

获取该复制的 [windows::Win32::Graphics::Dxgi::DXGI_OUTDUPL_DESC]。

Source

pub const fn dxgi_device(&self) -> &IDXGIDevice4

获取底层的 [windows::Win32::Graphics::Dxgi::IDXGIDevice4] 接口。

Source

pub const fn output(&self) -> &IDXGIOutput6

获取底层的 [windows::Win32::Graphics::Dxgi::IDXGIOutput6] 接口。

Source

pub const fn width(&self) -> u32

获取该复制的宽度。

Source

pub const fn height(&self) -> u32

获取该复制的高度。

Source

pub const fn format(&self) -> DxgiDuplicationFormat

获取该复制的像素格式。

Source

pub const fn refresh_rate(&self) -> (u32, u32)

以(分子, 分母)的形式获取该复制的刷新率。

Source

pub fn acquire_next_frame( &mut self, timeout_ms: u32, ) -> Result<DxgiDuplicationFrame<'_>, Error>

获取下一帧并更新内部纹理。

此调用最多阻塞 timeout_ms 毫秒。若在超时前没有新帧到达,则返回 Error::Timeout。 若复制访问权限丢失,则返回 Error::AccessLost,此时应重新创建一次复制。

Error::AccessLost 的主要原因包括:

  • 该输出的显示模式发生改变(例如分辨率或颜色格式变化)。
  • 用户切换到了不同的桌面(例如通过 Ctrl+Alt+Del 或快速用户切换)。
  • DWM 开/关状态切换,或其他全屏应用

返回的 DxgiDuplicationFrame 允许你通过 DxgiDuplicationFrame::buffer 映射当前完整桌面图像。它包含该帧所报告的脏矩形列表。

§错误

自动 Trait 实现§

通用实现§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

获取 selfTypeId阅读更多
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

从拥有的值不可变地借用。阅读更多
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

从拥有的值可变地借用。阅读更多
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回参数。

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换由 From<T> for U 的实现自行决定。

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

into_lefttrue,则将 self 转换为 Left 变体 (属于 Either<Self, Self>)。 否则将 self 转换为 Right 变体 (属于 Either<Self, Self>)。阅读更多
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

into_left(&self) 返回 true,则将 self 转换为 Left 变体 (属于 Either<Self, Self>)。 否则将 self 转换为 Right 变体 (属于 Either<Self, Self>)。阅读更多
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

指针的对齐方式。
Source§

type Init = T

初始化器的类型。
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

使用给定的初始化器初始化 a。阅读更多
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

解引用给定的指针。阅读更多
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

可变地解引用给定的指针。阅读更多
Source§

unsafe fn drop(ptr: usize)

丢弃给定指针指向的对象。阅读更多
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。