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

source

pub fn new_composition_recorder() -> Self

Create a new AsyncScreenshotGrabber for the composition recorder.

source

pub fn deinit(self, device: &mut Device)

Deinitialize the allocated textures and PBOs.

source

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.

source

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.

source

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.

source

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§

source§

impl Default for AsyncScreenshotGrabber

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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

Converts 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 more
source§

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

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.