feather_ui/render/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2025 Fundament Research Institute <https://fundament.institute>
3
4use crate::render::compositor::CompositorView;
5use crate::{PxRect, graphics};
6use std::any::Any;
7use std::rc::Rc;
8
9pub mod atlas;
10pub mod compositor;
11pub mod domain;
12pub mod image;
13pub mod line;
14pub mod shape;
15pub mod text;
16pub mod textbox;
17
18pub trait Renderable {
19    fn render(
20        &self,
21        area: PxRect,
22        driver: &crate::graphics::Driver,
23        compositor: &mut CompositorView<'_>,
24    ) -> Result<(), crate::Error>;
25}
26
27pub trait Pipeline: Any + std::fmt::Debug + Send + Sync {
28    #[allow(unused_variables)]
29    fn prepare(
30        &mut self,
31        driver: &graphics::Driver,
32        encoder: &mut wgpu::CommandEncoder,
33        config: &wgpu::SurfaceConfiguration,
34    ) {
35    }
36    fn draw(&mut self, driver: &graphics::Driver, pass: &mut wgpu::RenderPass<'_>, layer: u8);
37    #[allow(unused_variables)]
38    fn destroy(&mut self, driver: &graphics::Driver) {}
39}
40
41pub struct Chain<const N: usize>(pub [Rc<dyn Renderable>; N]);
42
43impl<const N: usize> Renderable for Chain<N> {
44    fn render(
45        &self,
46        area: PxRect,
47        driver: &crate::graphics::Driver,
48        compositor: &mut CompositorView<'_>,
49    ) -> Result<(), crate::Error> {
50        for x in &self.0 {
51            x.render(area, driver, compositor)?;
52        }
53        Ok(())
54    }
55}