Skip to main content

QuadVertex

Struct QuadVertex 

Source
#[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: u32

Per-vertex bitfield. Bit 0 (QUAD_FLAG_COLOR_GLYPH) selects the color emoji path in the fragment shader.

§_pad: u32

Padding so the struct stride stays a multiple of 8 bytes, matching wgpu’s vertex buffer layout expectations.

Implementations§

Source§

impl QuadVertex

Source

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

Source§

fn clone(&self) -> QuadVertex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for QuadVertex

Source§

impl Debug for QuadVertex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Pod for QuadVertex

Source§

impl Zeroable for QuadVertex

Source§

fn zeroed() -> Self

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> AnyBitPattern for T
where T: Pod,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> NoUninit for T
where T: Pod,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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>,

Source§

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,