#[cfg(feature = "nostd")]
use alloc::string::String;
#[cfg(not(feature = "nostd"))]
use std::string::String;
use ahash::AHashMap;
use fontdb::Database as FontDatabase;
use crate::pipeline::shaping::GlyphRenderer;
mod animation;
mod drawing;
mod position;
mod run;
mod style;
mod text;
mod wrap;
use style::OwnedStyle;
pub struct SoftwarePipeline {
font_database: FontDatabase,
#[allow(dead_code)] glyph_renderer: GlyphRenderer,
collision_resolver: crate::collision::CollisionResolver,
cache: crate::cache::RenderCache,
styles_map: AHashMap<String, OwnedStyle>,
default_style: Option<OwnedStyle>,
play_res_x: f32,
play_res_y: f32,
layout_res_x: Option<f32>,
layout_res_y: Option<f32>,
scaled_border_and_shadow: bool,
dpi_scale: f32,
wrap_style: u8,
}
impl Default for SoftwarePipeline {
fn default() -> Self {
Self::new()
}
}
impl SoftwarePipeline {
pub fn new() -> Self {
let mut font_database = FontDatabase::new();
font_database.load_system_fonts();
Self {
font_database,
glyph_renderer: GlyphRenderer::new(),
collision_resolver: crate::collision::CollisionResolver::new(1920.0, 1080.0),
cache: crate::cache::RenderCache::with_limits(5000, 2000),
styles_map: AHashMap::new(),
default_style: None,
play_res_x: 1920.0, play_res_y: 1080.0, layout_res_x: None,
layout_res_y: None,
scaled_border_and_shadow: true, dpi_scale: 0.9, wrap_style: 0,
}
}
pub fn with_dimensions(width: f32, height: f32) -> Self {
let mut font_database = FontDatabase::new();
font_database.load_system_fonts();
Self {
font_database,
glyph_renderer: GlyphRenderer::new(),
collision_resolver: crate::collision::CollisionResolver::new(width, height),
cache: crate::cache::RenderCache::with_limits(5000, 2000),
styles_map: AHashMap::new(),
default_style: None,
play_res_x: width, play_res_y: height, layout_res_x: None,
layout_res_y: None,
scaled_border_and_shadow: true, dpi_scale: 0.9, wrap_style: 0,
}
}
pub fn set_dpi_scale(&mut self, scale: f32) {
self.dpi_scale = scale;
}
pub fn dpi_scale(&self) -> f32 {
self.dpi_scale
}
}