use crate::layout::*;
use dioxus_native_core::NodeId;
use freya_dom::prelude::FreyaDOM;
use freya_engine::prelude::*;
use torin::prelude::Area;
pub fn process_render<RenderOptions>(
viewports: &Viewports,
fdom: &FreyaDOM,
font_collection: &mut FontCollection,
layers: &Layers,
render_options: &mut RenderOptions,
render_fn: impl Fn(&FreyaDOM, &NodeId, &Area, &mut FontCollection, &Viewports, &mut RenderOptions),
) {
for (_, layer) in layers.layers() {
'elements: for node_id in layer {
let node_viewports = viewports.get(node_id);
let layout = fdom.layout();
let areas = layout.get(*node_id);
if let Some(areas) = areas {
if let Some((_, node_viewports)) = node_viewports {
for viewport_id in node_viewports {
let viewport = viewports.get(viewport_id).unwrap().0;
if let Some(viewport) = viewport {
if !viewport.intersects(&areas.area) {
continue 'elements;
}
}
}
}
render_fn(
fdom,
node_id,
&areas.visible_area(),
font_collection,
viewports,
render_options,
)
}
}
}
}