feat: bootstrap namespace-driven Tessera renderer

This commit is contained in:
2026-10-04 19:32:04 +08:00
commit 2f4c8f0fe2
14 changed files with 4262 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
use crate::geometry::{Point, Rect};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
pub alpha: u8,
}
impl Color {
pub const fn rgb(red: u8, green: u8, blue: u8) -> Self {
Self {
red,
green,
blue,
alpha: 255,
}
}
pub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self {
Self {
red,
green,
blue,
alpha,
}
}
}
#[derive(Clone, Debug)]
pub enum DrawCommand {
Clear(Color),
FillRoundedRect {
rect: Rect,
radius: f32,
color: Color,
},
StrokeRoundedRect {
rect: Rect,
radius: f32,
width: f32,
color: Color,
},
Text {
origin: Point,
value: String,
scale: u32,
color: Color,
},
}
#[derive(Clone, Debug, Default)]
pub struct DisplayList {
commands: Vec<DrawCommand>,
}
impl DisplayList {
pub fn push(&mut self, command: DrawCommand) {
self.commands.push(command);
}
pub fn commands(&self) -> &[DrawCommand] {
&self.commands
}
pub fn extend(&mut self, other: DisplayList) {
self.commands.extend(other.commands);
}
}