#[repr(C)]pub struct QuadVertex {
pub position: [f32; 2],
pub tex_coord: [f32; 2],
pub color: [f32; 4],
pub flags: u32,
pub _pad: u32,
}Expand description
Vertex for the textured quad pipeline (glyphs, images).
Fields§
§position: [f32; 2]§tex_coord: [f32; 2]§color: [f32; 4]§flags: u32Per-vertex bitfield. Bit 0 (QUAD_FLAG_COLOR_GLYPH) selects the
color emoji path in the fragment shader.
_pad: u32Padding so the struct stride stays a multiple of 8 bytes, matching wgpu’s vertex buffer layout expectations.
Implementations§
Source§impl QuadVertex
impl QuadVertex
Sourcepub fn from_glyph_quad_transformed(
quad: &GlyphQuad,
scale_factor: f32,
atlas_width: u32,
atlas_height: u32,
transform: &Transform2D,
) -> [QuadVertex; 4]
pub fn from_glyph_quad_transformed( quad: &GlyphQuad, scale_factor: f32, atlas_width: u32, atlas_height: u32, transform: &Transform2D, ) -> [QuadVertex; 4]
Convert a glyph quad to 4 vertices (two triangles via index buffer),
applying scale_factor (logical → physical pixels) and the current
affine transform (linear part unitless, translation already in
physical pixels). Atlas coordinates are in texels and normalized to
0..1 using the atlas dimensions. Returned positions are in physical
pixels — the caller converts to NDC; it must NOT transform again.
Pixel-snap invariant. The glyph atlas is sampled with bilinear
filtering so the residual GPU scaling between raster-scale buckets
(≤ ~12%, see quantize_raster_scale) stays smooth. Bilinear is only
loss-free when each texel maps exactly onto one framebuffer pixel,
and glyph origins are inherently fractional: shaping pen advances,
widget offsets, and scroll positions are all fractional floats. An
unsnapped origin makes the 2×2 kernel mix neighboring texels at
every edge (uniform blur) and bleed the glyph’s last row into the
transparent atlas gutter (visibly cropping the bottom of letters
like “c”/“e”). So whenever the transformed quad maps 1:1 onto its
atlas bitmap — axis-aligned transform and transformed size equal to
the bitmap size within GLYPH_SNAP_SIZE_EPS — the origin is
rounded to the integer pixel grid and the opposite corner pinned at
exactly origin + bitmap size, making linear sampling an identity.
This covers identity, fractional DPI, pure translations, and
exact-bucket zoom (e.g. a 1.25× transform over a 1.25-bucket
raster). Rotated or residually scaled quads (mid-bucket zoom) skip
the snap and ride bilinear filtering as intended.
Trait Implementations§
Source§impl Clone for QuadVertex
impl Clone for QuadVertex
Source§fn clone(&self) -> QuadVertex
fn clone(&self) -> QuadVertex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for QuadVertex
Source§impl Debug for QuadVertex
impl Debug for QuadVertex
impl Pod for QuadVertex
Auto Trait Implementations§
impl Freeze for QuadVertex
impl RefUnwindSafe for QuadVertex
impl Send for QuadVertex
impl Sync for QuadVertex
impl Unpin for QuadVertex
impl UnsafeUnpin for QuadVertex
impl UnwindSafe for QuadVertex
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.