use crate::blend::BlendMode;
use crate::brush::{Brush, Image, Sampling};
use crate::geometry::Affine;
use crate::mesh::Mesh;
use crate::path::{FillRule, Path};
use crate::pick::PickId;
pub mod recording;
pub trait SceneBuilder {
fn clear(&mut self);
fn fill(
&mut self,
rule: FillRule,
transform: Affine,
brush: &Brush,
brush_transform: Option<Affine>,
path: &Path,
pick_id: PickId,
);
fn stroke(
&mut self,
stroke: &crate::stroke::Stroke,
transform: Affine,
brush: &Brush,
brush_transform: Option<Affine>,
path: &Path,
pick_id: PickId,
);
fn draw_image(
&mut self,
image: &Image,
transform: Affine,
sampling: Sampling,
alpha: f32,
pick_id: PickId,
);
fn draw_glyphs(&mut self, run: &GlyphRun<'_>, pick_id: PickId);
fn draw_mesh(&mut self, mesh: &Mesh, transform: Affine, pick_id: PickId);
fn push_layer(&mut self, blend: BlendMode, alpha: f32, transform: Affine, clip: &Path);
fn pop_layer(&mut self);
}
#[derive(Debug, Clone)]
pub struct Font(peniko::FontData);
impl Font {
pub(crate) fn from_data(data: peniko::FontData) -> Self {
Self(data)
}
#[cfg_attr(not(feature = "vello"), allow(dead_code))]
pub(crate) fn data(&self) -> &peniko::FontData {
&self.0
}
pub fn new(data: peniko::Blob<u8>, index: u32) -> Self {
Self(peniko::FontData::new(data, index))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Glyph {
pub id: u32,
pub x: f32,
pub y: f32,
}
#[derive(Debug, Clone, Copy)]
pub struct GlyphRun<'a> {
pub font: &'a Font,
pub font_size: f32,
pub transform: Affine,
pub glyph_transform: Option<Affine>,
pub brush: &'a Brush,
pub brush_alpha: f32,
pub hint: bool,
pub glyphs: &'a [Glyph],
pub style: Option<&'a crate::stroke::Stroke>,
}