pub struct LayoutEngine;Implementations§
Source§impl LayoutEngine
impl LayoutEngine
Sourcepub fn layout(root: &mut LayoutNode, width: f32, height: f32)
pub fn layout(root: &mut LayoutNode, width: f32, height: f32)
Main layout entry point. Initiates layout computation from the root node with specified viewport dimensions.
§TODO
- Implement CSS-correct flex-basis precedence.
- flex-basis should override width/height on the main axis, but the current algorithm does not guarantee this.
Examples found in repository?
examples/layout_flex_chain_bench.rs (line 85)
77fn main() {
78 println!("flex-chain layout benchmark");
79 println!("----------------------------");
80
81 let mut root = make_tree();
82
83 let t1 = {
84 let start = Instant::now();
85 LayoutEngine::layout(&mut root, 800.0, 600.0);
86 start.elapsed()
87 };
88
89 println!("1st layout: {:?}", t1);
90
91 let t2 = {
92 let start = Instant::now();
93 LayoutEngine::layout(&mut root, 800.0, 600.0);
94 start.elapsed()
95 };
96
97 println!("2nd layout: {:?}", t2);
98}More examples
examples/layout_bench.rs (line 89)
73fn main() {
74 const TOTAL_NODES: usize = 7_000;
75 const DEPTH: usize = 16;
76
77 println!("layout performance benchmark");
78 println!("TOTAL_NODES = {}", TOTAL_NODES);
79 println!("DEPTH = {}", DEPTH);
80 println!("-------------------------");
81
82 let mut remaining = TOTAL_NODES - 1;
83 let mut root = make_tree(0, DEPTH, &mut remaining);
84
85 println!("remaining nodes unused = {}", remaining);
86
87 let t1 = {
88 let start = Instant::now();
89 LayoutEngine::layout(&mut root, 800.0, 600.0);
90 start.elapsed()
91 };
92
93 println!("1st layout: {:?}", t1);
94
95 let t2 = {
96 let start = Instant::now();
97 LayoutEngine::layout(&mut root, 800.0, 600.0);
98 start.elapsed()
99 };
100
101 println!("2nd layout: {:?}", t2);
102}Auto Trait Implementations§
impl Freeze for LayoutEngine
impl RefUnwindSafe for LayoutEngine
impl Send for LayoutEngine
impl Sync for LayoutEngine
impl Unpin for LayoutEngine
impl UnwindSafe for LayoutEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more