pub enum GpuEncodedPaint {
Image(GpuEncodedImage),
LinearGradient(GpuLinearGradient),
RadialGradient(GpuRadialGradient),
SweepGradient(GpuSweepGradient),
BlurredRoundedRect(GpuBlurredRoundedRect),
}Expand description
One encoded paint of any kind.
Records are compared by their bytes (GpuEncodedPaint::as_bytes) rather
than field-wise: the bytes are the contract the shader reads.
Variants§
Image(GpuEncodedImage)
An image.
LinearGradient(GpuLinearGradient)
A linear gradient.
RadialGradient(GpuRadialGradient)
A radial gradient.
SweepGradient(GpuSweepGradient)
A sweep gradient.
BlurredRoundedRect(GpuBlurredRoundedRect)
A blurred rounded rectangle.
Implementations§
Source§impl GpuEncodedPaint
impl GpuEncodedPaint
Sourcepub const fn paint_type(&self) -> PaintType
pub const fn paint_type(&self) -> PaintType
The paint type a strip instance names this record by.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
This paint’s bytes, exactly as they land in the encoded-paint texture.
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
This paint’s size in bytes — always a multiple of the 16-byte texel.
Sourcepub fn serialized_len(paints: &[Self]) -> usize
pub fn serialized_len(paints: &[Self]) -> usize
The total byte length of paints serialized back to back.
Sourcepub fn serialize_to_buffer(
paints: &[Self],
buffer: &mut [u8],
) -> Result<usize, EngineError>
pub fn serialize_to_buffer( paints: &[Self], buffer: &mut [u8], ) -> Result<usize, EngineError>
Serializes paints back to back into the front of buffer, returning
the number of bytes written.
buffer is the full padded upload buffer, so anything past the
returned length keeps whatever it already held — a paint index only
ever addresses a record that was written.
§Errors
Returns EngineError::AtlasError when buffer is shorter than the
serialized paints, rather than writing a partial record.
Sourcepub fn texel_offsets(paints: &[Self]) -> Vec<u32>
pub fn texel_offsets(paints: &[Self]) -> Vec<u32>
The texel each paint in paints starts at, in serialization order —
the index the shader looks a paint up by.