#[repr(C)]pub struct Tile {
pub packed_winding_line_idx: u32,
pub x: u16,
pub y: u16,
}Expand description
A tile represents an aligned area on the pixmap, used to subdivide the viewport into sub-areas (currently 4x4) and analyze line intersections inside each such area.
Keep in mind that it is possible to have multiple tiles with the same index, namely if we have multiple lines crossing the same 4x4 area!
§Note
This struct is #[repr(C)], but the byte order of its fields is dependent on the endianness of
the compilation target.
Fields§
§packed_winding_line_idx: u32The index of the line this tile belongs to into the line buffer, intersection data, and winding data packed together.
The layout is:
- Bits 0-4 (5 bits): Intersection and Winding Mask (
W | R | L | B | T).- Bit 0 (mask
0b00001): Intersects top edge (T) - Bit 1 (mask
0b00010): Intersects bottom edge (B) - Bit 2 (mask
0b00100): Intersects left edge (L) - Bit 3 (mask
0b01000): Intersects right edge (R) - Bit 4 (mask
0b10000): Winding (W) - 1 if crosses top edge.
- Bit 0 (mask
- Bits 5-31 (27 bits): The line index (
line_idx).
Sorting Note: The line_idx occupies the higher bits to ensure that when sorting
tiles with the same (x, y) coordinates, they are sorted by their line index first,
and then by their intersection mask.
x: u16The index of the tile in the x direction.
y: u16The index of the tile in the y direction.
Implementations§
Source§impl Tile
impl Tile
Sourcepub const SENTINEL: Self
pub const SENTINEL: Self
A special tile used to signal the end of a tile stream during rendering.
Sourcepub fn new_clamped(
x: u16,
y: u16,
line_idx: u32,
intersection_mask: u32,
) -> Self
pub fn new_clamped( x: u16, y: u16, line_idx: u32, intersection_mask: u32, ) -> Self
Create a new tile.
x and y will be clamped to the largest possible coordinate if they are too large.
line_idx must be smaller than MAX_LINES_PER_PATH.
Sourcepub const fn new(x: u16, y: u16, line_idx: u32, intersection_mask: u32) -> Self
pub const fn new(x: u16, y: u16, line_idx: u32, intersection_mask: u32) -> Self
The base tile constructor
Unlike Self::new_clamped, this constructor stores x and y exactly as provided.
Callers must ensure these coordinates do not exceed the limits required by downstream
processing (typically u16::MAX / WIDTH and u16::MAX / HEIGHT).
Sourcepub const fn same_loc(&self, other: &Self) -> bool
pub const fn same_loc(&self, other: &Self) -> bool
Check whether two tiles are at the same location.
Sourcepub const fn prev_loc(&self, other: &Self) -> bool
pub const fn prev_loc(&self, other: &Self) -> bool
Check whether self is adjacent to the left of other.
Sourcepub const fn same_row(&self, other: &Self) -> bool
pub const fn same_row(&self, other: &Self) -> bool
Check whether two tiles are on the same row.
Sourcepub const fn line_idx(&self) -> u32
pub const fn line_idx(&self) -> u32
The index of the line this tile belongs to into the line buffer.
Returns the high 27 bits.
Sourcepub const fn winding(&self) -> bool
pub const fn winding(&self) -> bool
Whether the line crosses the top edge of the tile.
Lines making this crossing increment or decrement the coarse tile winding, depending on the line direction.
Checks Bit 4 (Winding).
Sourcepub const fn intersection_mask(&self) -> u32
pub const fn intersection_mask(&self) -> u32
The 5 bits of intersection and winding data.
Sourcepub const fn intersects_top(&self) -> bool
pub const fn intersects_top(&self) -> bool
Whether the line intersects the top edge of the tile.
Sourcepub const fn intersects_bottom(&self) -> bool
pub const fn intersects_bottom(&self) -> bool
Whether the line intersects the bottom edge of the tile.
Sourcepub const fn intersects_left(&self) -> bool
pub const fn intersects_left(&self) -> bool
Whether the line intersects the left edge of the tile.
Sourcepub const fn intersects_right(&self) -> bool
pub const fn intersects_right(&self) -> bool
Whether the line intersects the right edge of the tile.
Sourceconst fn to_bits(self) -> u64
const fn to_bits(self) -> u64
Return the u64 representation of this tile.
This is the u64 interpretation of (y, x, packed_winding_line_idx) where y is the
most-significant part of the number and packed_winding_line_idx the least significant.
Sourcepub const fn is_sentinel(&self) -> bool
pub const fn is_sentinel(&self) -> bool
Whether a tile is a sentinel tile