[][src]Struct nannou::wgpu::TextureSnapshot

pub struct TextureSnapshot { /* fields omitted */ }

A snapshot captured by a Capturer.

A snapshot is a thin wrapper around a wgpu::BufferImage that knows that the image format is specifically non-linear sRGBA8.

Methods

impl Snapshot[src]

pub fn read<F>(&self, callback: F) where
    F: 'static + FnOnce(Result<Rgba8AsyncMappedImageBuffer, ()>), 
[src]

Reads the non-linear sRGBA image from mapped memory.

Specifically, this asynchronously maps the buffer of bytes from GPU to host memory and, once mapped, calls the given user callback with the data represented as an Rgba8AsyncMapping.

Note: The given callback will not be called until the memory is mapped and the device is polled. You should not rely on the callback being called immediately.

The given callback will be called on the current thread. If you would like the callback to be processed on a thread pool, see the read_threaded method.

pub fn read_threaded<F>(&self, callback: F) where
    F: 'static + Send + FnOnce(Result<ImageBuffer<Rgba<u8>, Vec<u8>>, ()>), 
[src]

Similar to read, but rather than delivering the mapped memory directly to the callback, this method will first clone the mapped data, send it to another thread and then call the callback from the other thread.

This is useful when the callback performs an operation that could take a long or unknown amount of time (e.g. writing the image to disk).

Note however that if this method is called repeatedly (e.g. every frame) and the given callback takes longer than the interval between calls, then the underlying thread will fall behind and may take a while to complete by the time the application has exited.

Auto Trait Implementations

impl !RefUnwindSafe for Snapshot

impl !Send for Snapshot

impl !Sync for Snapshot

impl Unpin for Snapshot

impl UnwindSafe for Snapshot

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,