pub enum Payload<T: GpuSendable> {
Cpu(T),
Gpu(T::GpuRepr),
}Expand description
Generic payload that can carry either CPU data or a GPU representation.
Variants§
Implementations§
Source§impl<T: GpuSendable> Payload<T>
impl<T: GpuSendable> Payload<T>
Source§impl Payload<DynamicImage>
impl Payload<DynamicImage>
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Return image dimensions without forcing the caller to pattern match.
Sourcepub fn into_gpu(
self,
ctx: &GpuContextHandle,
) -> Result<(GpuImageHandle, u32, u32), GpuError>
pub fn into_gpu( self, ctx: &GpuContextHandle, ) -> Result<(GpuImageHandle, u32, u32), GpuError>
Ensure this payload is resident on GPU; uploads if necessary and returns the handle and dimensions.
Source§impl Payload<DynamicImage>
impl Payload<DynamicImage>
Sourcepub fn to_rgba_bytes(
&self,
ctx: Option<&GpuContextHandle>,
) -> Result<(Vec<u8>, u32, u32), GpuError>
pub fn to_rgba_bytes( &self, ctx: Option<&GpuContextHandle>, ) -> Result<(Vec<u8>, u32, u32), GpuError>
Get RGBA8 bytes + dimensions, downloading from GPU if needed.
Sourcepub fn from_rgba_bytes(
ctx: Option<&GpuContextHandle>,
bytes: Vec<u8>,
w: u32,
h: u32,
) -> Result<Self, GpuError>
pub fn from_rgba_bytes( ctx: Option<&GpuContextHandle>, bytes: Vec<u8>, w: u32, h: u32, ) -> Result<Self, GpuError>
Construct a payload from RGBA8 bytes, uploading if a GPU context is available.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Payload<T>
impl<T> RefUnwindSafe for Payload<T>
impl<T> Send for Payload<T>
impl<T> Sync for Payload<T>
impl<T> Unpin for Payload<T>
impl<T> UnwindSafe for Payload<T>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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