pub struct DxgiDuplicationFrame<'a> { /* private fields */ }展开描述
表示当前帧已预组装好的完整桌面图像,
由内部 GPU 纹理支持。
调用 DxgiDuplicationFrame::buffer 可获得 CPU 可读的 crate::frame::FrameBuffer。
实现§
Source§impl<'a> DxgiDuplicationFrame<'a>
impl<'a> DxgiDuplicationFrame<'a>
Sourcepub const fn format(&self) -> DxgiDuplicationFormat
pub const fn format(&self) -> DxgiDuplicationFormat
获取该帧的像素格式。
Sourcepub const fn device_context(&self) -> &ID3D11DeviceContext
pub const fn device_context(&self) -> &ID3D11DeviceContext
获取用于 GPU 操作的底层 Direct3D 设备上下文。
Sourcepub const fn duplication(&self) -> &IDXGIOutputDuplication
pub const fn duplication(&self) -> &IDXGIOutputDuplication
获取底层的 IDXGIOutputDuplication 接口。
Sourcepub const fn texture(&self) -> &ID3D11Texture2D
pub const fn texture(&self) -> &ID3D11Texture2D
获取底层的 [windows::Win32::Graphics::Direct3D11::ID3D11Texture2D] 接口。
Sourcepub const fn texture_desc(&self) -> &D3D11_TEXTURE2D_DESC
pub const fn texture_desc(&self) -> &D3D11_TEXTURE2D_DESC
获取底层纹理的 [windows::Win32::Graphics::Direct3D11::D3D11_TEXTURE2D_DESC]。
Sourcepub const fn frame_info(&self) -> &DXGI_OUTDUPL_FRAME_INFO
pub const fn frame_info(&self) -> &DXGI_OUTDUPL_FRAME_INFO
获取当前帧的帧信息。
Sourcepub fn buffer<'b>(&'b mut self) -> Result<DxgiDuplicationFrameBuffer<'b>, Error>
pub fn buffer<'b>(&'b mut self) -> Result<DxgiDuplicationFrameBuffer<'b>, Error>
将内部帧映射到 CPU 可访问的内存,并返回
crate::frame::FrameBuffer。
此方法会创建一张 staging 纹理,将内部纹理复制到其中,并映射为 CPU 可读/可写。
返回的缓冲区可能包含行填充(row padding);你可以使用 crate::frame::FrameBuffer::as_nopadding_buffer 获取紧凑(无填充)表示。
Sourcepub fn buffer_crop<'b>(
&'b mut self,
start_x: u32,
start_y: u32,
end_x: u32,
end_y: u32,
) -> Result<DxgiDuplicationFrameBuffer<'b>, Error>
pub fn buffer_crop<'b>( &'b mut self, start_x: u32, start_y: u32, end_x: u32, end_y: u32, ) -> Result<DxgiDuplicationFrameBuffer<'b>, Error>
获取该复制帧的裁剪缓冲区。
Sourcepub fn buffer_with<'s>(
&'s mut self,
staging: &'s mut StagingTexture,
) -> Result<DxgiDuplicationFrameBuffer<'s>, Error>
pub fn buffer_with<'s>( &'s mut self, staging: &'s mut StagingTexture, ) -> Result<DxgiDuplicationFrameBuffer<'s>, Error>
进阶用法:复用你自己的 CPU staging 纹理 (crate::d3d11::StagingTexture)。
这可以避免每帧分配,并允许你自行管理纹理的生命周期。
staging 纹理必须是 D3D11_USAGE_STAGING 的 2D 纹理,具有 CPU 读/写访问权限,
且与该帧的宽度/高度/格式相匹配。
Sourcepub fn buffer_crop_with<'s>(
&'s mut self,
staging: &'s mut StagingTexture,
start_x: u32,
start_y: u32,
end_x: u32,
end_y: u32,
) -> Result<DxgiDuplicationFrameBuffer<'s>, Error>
pub fn buffer_crop_with<'s>( &'s mut self, staging: &'s mut StagingTexture, start_x: u32, start_y: u32, end_x: u32, end_y: u32, ) -> Result<DxgiDuplicationFrameBuffer<'s>, Error>
进阶用法:使用预分配的 staging 纹理进行裁剪。
所提供的 staging 纹理必须是 D3D11_USAGE_STAGING 的 2D 纹理,具有 CPU 读/写访问权限,
格式与该复制帧相同,且大小足以容纳裁剪区域。
Sourcepub fn save_as_image<T: AsRef<Path>>(
&mut self,
path: T,
format: ImageFormat,
) -> Result<(), Error>
pub fn save_as_image<T: AsRef<Path>>( &mut self, path: T, format: ImageFormat, ) -> Result<(), Error>
将帧缓冲区保存为指定路径的图像。
自动 Trait 实现§
impl<'a> Freeze for DxgiDuplicationFrame<'a>
impl<'a> RefUnwindSafe for DxgiDuplicationFrame<'a>
impl<'a> Send for DxgiDuplicationFrame<'a>
impl<'a> Sync for DxgiDuplicationFrame<'a>
impl<'a> Unpin for DxgiDuplicationFrame<'a>
impl<'a> UnsafeUnpin for DxgiDuplicationFrame<'a>
impl<'a> UnwindSafe for DxgiDuplicationFrame<'a>
通用实现§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
into_left 为 true,则将 self 转换为 Left 变体
(属于 Either<Self, Self>)。
否则将 self 转换为 Right 变体
(属于 Either<Self, Self>)。阅读更多Source§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
into_left(&self) 返回 true,则将 self 转换为 Left 变体
(属于 Either<Self, Self>)。
否则将 self 转换为 Right 变体
(属于 Either<Self, Self>)。阅读更多