ass_renderer/pipeline/build/
mod.rs1#[cfg(feature = "nostd")]
4use alloc::string::String;
5#[cfg(not(feature = "nostd"))]
6use std::string::String;
7
8use ahash::AHashMap;
9use fontdb::Database as FontDatabase;
10
11use crate::pipeline::shaping::GlyphRenderer;
12
13mod animation;
14mod drawing;
15mod position;
16mod run;
17mod style;
18mod text;
19mod wrap;
20use style::OwnedStyle;
21
22pub struct SoftwarePipeline {
24 font_database: FontDatabase,
26 #[allow(dead_code)] glyph_renderer: GlyphRenderer,
29 collision_resolver: crate::collision::CollisionResolver,
31 cache: crate::cache::RenderCache,
33 styles_map: AHashMap<String, OwnedStyle>,
35 default_style: Option<OwnedStyle>,
37 play_res_x: f32,
39 play_res_y: f32,
40 layout_res_x: Option<f32>,
42 layout_res_y: Option<f32>,
43 scaled_border_and_shadow: bool,
45 dpi_scale: f32,
49 wrap_style: u8,
52}
53
54impl Default for SoftwarePipeline {
55 fn default() -> Self {
56 Self::new()
57 }
58}
59
60impl SoftwarePipeline {
61 pub fn new() -> Self {
63 let mut font_database = FontDatabase::new();
64 font_database.load_system_fonts();
65
66 Self {
67 font_database,
68 glyph_renderer: GlyphRenderer::new(),
69 collision_resolver: crate::collision::CollisionResolver::new(1920.0, 1080.0),
70 cache: crate::cache::RenderCache::with_limits(5000, 2000),
71 styles_map: AHashMap::new(),
72 default_style: None,
73 play_res_x: 1920.0, play_res_y: 1080.0, layout_res_x: None,
76 layout_res_y: None,
77 scaled_border_and_shadow: true, dpi_scale: 0.9, wrap_style: 0,
80 }
81 }
82
83 pub fn with_dimensions(width: f32, height: f32) -> Self {
85 let mut font_database = FontDatabase::new();
86 font_database.load_system_fonts();
87
88 Self {
89 font_database,
90 glyph_renderer: GlyphRenderer::new(),
91 collision_resolver: crate::collision::CollisionResolver::new(width, height),
92 cache: crate::cache::RenderCache::with_limits(5000, 2000),
93 styles_map: AHashMap::new(),
94 default_style: None,
95 play_res_x: width, play_res_y: height, layout_res_x: None,
98 layout_res_y: None,
99 scaled_border_and_shadow: true, dpi_scale: 0.9, wrap_style: 0,
102 }
103 }
104
105 pub fn set_dpi_scale(&mut self, scale: f32) {
108 self.dpi_scale = scale;
109 }
110
111 pub fn dpi_scale(&self) -> f32 {
113 self.dpi_scale
114 }
115}