Struct webrender::screen_capture::AsyncScreenshotGrabber
source · pub(crate) struct AsyncScreenshotGrabber {
scaling_textures: Vec<Texture>,
available_pbos: Vec<PBO>,
awaiting_readback: HashMap<AsyncScreenshotHandle, AsyncScreenshot>,
next_pbo_handle: usize,
mode: AsyncScreenshotGrabberMode,
}
Expand description
Renderer infrastructure for capturing screenshots and scaling them asynchronously.
Fields§
§scaling_textures: Vec<Texture>
The textures used to scale screenshots.
available_pbos: Vec<PBO>
PBOs available to be used for screenshot readback.
awaiting_readback: HashMap<AsyncScreenshotHandle, AsyncScreenshot>
PBOs containing screenshots that are awaiting readback.
next_pbo_handle: usize
The handle for the net PBO that will be inserted into in_use_pbos
.
mode: AsyncScreenshotGrabberMode
The mode the grabber operates in.
Implementations§
source§impl AsyncScreenshotGrabber
impl AsyncScreenshotGrabber
sourcepub fn new_composition_recorder() -> Self
pub fn new_composition_recorder() -> Self
Create a new AsyncScreenshotGrabber for the composition recorder.
sourcepub fn get_screenshot(
&mut self,
device: &mut Device,
window_rect: DeviceIntRect,
buffer_size: DeviceIntSize,
image_format: ImageFormat,
) -> (AsyncScreenshotHandle, DeviceIntSize)
pub fn get_screenshot( &mut self, device: &mut Device, window_rect: DeviceIntRect, buffer_size: DeviceIntSize, image_format: ImageFormat, ) -> (AsyncScreenshotHandle, DeviceIntSize)
Take a screenshot and scale it asynchronously.
The returned handle can be used to access the mapped screenshot data via
map_and_recycle_screenshot
.
The returned size is the size of the screenshot.
sourcefn scale_screenshot(
&mut self,
device: &mut Device,
read_target: ReadTarget,
read_target_rect: DeviceIntRect,
buffer_size: DeviceIntSize,
min_texture_size: DeviceIntSize,
dest_size: DeviceIntSize,
image_format: ImageFormat,
level: usize,
)
fn scale_screenshot( &mut self, device: &mut Device, read_target: ReadTarget, read_target_rect: DeviceIntRect, buffer_size: DeviceIntSize, min_texture_size: DeviceIntSize, dest_size: DeviceIntSize, image_format: ImageFormat, level: usize, )
Take the screenshot in the given ReadTarget
and scale it to dest_size
recursively.
Each scaling operation scales only by a factor of two to preserve quality.
Textures are scaled such that scaling_textures[n]
is half the size of
scaling_textures[n+1]
.
After the scaling completes, the final screenshot will be in
scaling_textures[0]
.
The size of scaling_textures[0]
will be increased to min_texture_size
so that an optimally-sized area can be read from it.
sourcepub fn map_and_recycle_screenshot(
&mut self,
device: &mut Device,
handle: AsyncScreenshotHandle,
dst_buffer: &mut [u8],
dst_stride: usize,
) -> bool
pub fn map_and_recycle_screenshot( &mut self, device: &mut Device, handle: AsyncScreenshotHandle, dst_buffer: &mut [u8], dst_stride: usize, ) -> bool
Map the contents of the screenshot given by the handle and copy it into the given buffer.
fn iter_src_buffer_chunked<'a>( &self, gl_type: GlType, src_buffer: &'a [u8], src_stride: usize, ) -> Box<dyn Iterator<Item = &'a [u8]> + 'a>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncScreenshotGrabber
impl !RefUnwindSafe for AsyncScreenshotGrabber
impl Send for AsyncScreenshotGrabber
impl !Sync for AsyncScreenshotGrabber
impl Unpin for AsyncScreenshotGrabber
impl UnwindSafe for AsyncScreenshotGrabber
Blanket Implementations§
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>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more