pub struct Wide<const MODE: u8 = MODE_CPU> {
pub width: u16,
pub height: u16,
pub tiles: Vec<WideTile<MODE>>,
layer_stack: Vec<Layer>,
clip_stack: Vec<Clip>,
}
Expand description
A container for wide tiles.
Fields§
§width: u16
The width of the container.
height: u16
The height of the container.
tiles: Vec<WideTile<MODE>>
The wide tiles in the container.
layer_stack: Vec<Layer>
The stack of layers.
clip_stack: Vec<Clip>
The stack of active clip regions.
Implementations§
Source§impl<const MODE: u8> Wide<MODE>
impl<const MODE: u8> Wide<MODE>
Sourcefn new_internal(width: u16, height: u16) -> Self
fn new_internal(width: u16, height: u16) -> Self
Create a new container for wide tiles.
Sourcepub fn has_layers(&self) -> bool
pub fn has_layers(&self) -> bool
Whether there are any existing layers that haven’t been popped yet.
Sourcepub fn width_tiles(&self) -> u16
pub fn width_tiles(&self) -> u16
Return the number of horizontal tiles.
Sourcepub fn height_tiles(&self) -> u16
pub fn height_tiles(&self) -> u16
Return the number of vertical tiles.
Sourcepub fn get(&self, x: u16, y: u16) -> &WideTile<MODE>
pub fn get(&self, x: u16, y: u16) -> &WideTile<MODE>
Get the wide tile at a certain index.
Panics if the index is out-of-range.
Sourcepub fn get_mut(&mut self, x: u16, y: u16) -> &mut WideTile<MODE>
pub fn get_mut(&mut self, x: u16, y: u16) -> &mut WideTile<MODE>
Get mutable access to the wide tile at a certain index.
Panics if the index is out-of-range.
Sourcepub fn generate(
&mut self,
strip_buf: &[Strip],
fill_rule: Fill,
paint: Paint,
thread_idx: u8,
)
pub fn generate( &mut self, strip_buf: &[Strip], fill_rule: Fill, paint: Paint, thread_idx: u8, )
Generate wide tile commands from the strip buffer.
This method processes a buffer of strips that represent a path, applies the fill rule, and generates appropriate drawing commands for each affected wide tile.
§Algorithm overview:
- For each strip in the buffer:
- Calculate its position and width in pixels
- Determine which wide tiles the strip intersects
- Generate alpha fill commands for the intersected wide tiles
- For active fill regions (determined by fill rule):
- Generate solid fill commands for the regions between strips
Sourcepub fn push_layer(
&mut self,
clip_path: Option<(impl Into<Box<[Strip]>>, Fill)>,
blend_mode: BlendMode,
mask: Option<Mask>,
opacity: f32,
thread_idx: u8,
)
pub fn push_layer( &mut self, clip_path: Option<(impl Into<Box<[Strip]>>, Fill)>, blend_mode: BlendMode, mask: Option<Mask>, opacity: f32, thread_idx: u8, )
Push a new layer with the given properties.
Sourcepub fn push_clip(
&mut self,
strips: impl Into<Box<[Strip]>>,
fill_rule: Fill,
thread_idx: u8,
)
pub fn push_clip( &mut self, strips: impl Into<Box<[Strip]>>, fill_rule: Fill, thread_idx: u8, )
Adds a clipping region defined by the provided strips.
This method takes a vector of strips representing a clip path, calculates the intersection with the current clip region, and updates the clip stack.
§Algorithm overview:
- Calculate bounding box of the clip path
- Intersect with current clip bounding box
- For each tile in the intersected bounding box:
- If covered by zero winding:
push_zero_clip
- If fully covered by non-zero winding: do nothing (clip is a no-op)
- If partially covered:
push_clip
- If covered by zero winding:
Sourcefn get_bbox(&self) -> Bbox
fn get_bbox(&self) -> Bbox
Get the bounding box of the current clip region or the entire viewport if no clip regions are active.
Sourcefn pop_clip(&mut self)
fn pop_clip(&mut self)
Removes the most recently added clip region.
This is the inverse operation of push_clip
, carefully undoing all the clipping
operations while also handling any rendering needed for the clip region itself.
§Algorithm overview:
- Retrieve the top clip from the stack
- For each wide tile in the clip’s bounding box:
- If covered by zero winding:
pop_zero_clip
- If fully covered by non-zero winding: do nothing (was no-op)
- If partially covered: render the clip and
pop_clip
- If covered by zero winding:
This operation must be symmetric with push_clip
to maintain a balanced clip stack.