Skip to main content

ferroui_base/rendering/composition/drawing/
i_render_data_visitor.rs

1use crate::media::{BoxShadows, IBrush, IPen, RenderOptions, TextOptions};
2use crate::platform::{IGeometryImpl, IGlyphRunImpl};
3use crate::rendering::scene_graph::ICustomDrawOperation;
4use crate::{Matrix, Point, Rect, RoundedRect};
5use std::sync::Arc;
6
7/// Walks the operations of a render data stream. A push returns a scope
8/// value that is handed back to `on_pop` when the matching pop is reached.
9pub trait IRenderDataVisitor {
10    type Scope;
11
12    /// Whether the walk should end early.
13    fn stop_visiting(&self) -> bool;
14
15    fn on_draw_line(&mut self, server_pen: Option<&dyn IPen>, client_pen: Option<&dyn IPen>, p1: Point, p2: Point);
16    fn on_draw_rectangle(
17        &mut self,
18        server_brush: Option<&dyn IBrush>,
19        server_pen: Option<&dyn IPen>,
20        client_pen: Option<&dyn IPen>,
21        rect: RoundedRect,
22        box_shadows: &BoxShadows,
23    );
24    fn on_draw_ellipse(
25        &mut self,
26        server_brush: Option<&dyn IBrush>,
27        server_pen: Option<&dyn IPen>,
28        client_pen: Option<&dyn IPen>,
29        rect: Rect,
30    );
31    fn on_draw_geometry(
32        &mut self,
33        server_brush: Option<&dyn IBrush>,
34        server_pen: Option<&dyn IPen>,
35        client_pen: Option<&dyn IPen>,
36        geometry: Option<&Arc<dyn IGeometryImpl>>,
37    );
38    fn on_draw_glyph_run(&mut self, server_brush: Option<&dyn IBrush>, glyph_run: Option<&std::sync::Arc<dyn IGlyphRunImpl>>);
39    fn on_draw_bitmap(&mut self, bitmap: Option<&std::sync::Arc<crate::platform::SharedBitmapImpl>>, opacity: f64, source_rect: Rect, dest_rect: Rect);
40    fn on_draw_custom(&mut self, operation: Option<&std::sync::Arc<dyn ICustomDrawOperation>>);
41
42    fn on_push_clip(&mut self, clip: RoundedRect) -> Self::Scope;
43    fn on_push_geometry_clip(&mut self, geometry: Option<&Arc<dyn IGeometryImpl>>) -> Self::Scope;
44    fn on_push_opacity(&mut self, opacity: f64) -> Self::Scope;
45    fn on_push_opacity_mask(&mut self, brush: Option<&dyn IBrush>, bounds: Rect) -> Self::Scope;
46    fn on_push_transform(&mut self, matrix: Matrix) -> Self::Scope;
47    fn on_push_render_options(&mut self, options: RenderOptions) -> Self::Scope;
48    fn on_push_text_options(&mut self, options: TextOptions) -> Self::Scope;
49    fn on_push_effect(&mut self, effect: Option<&std::sync::Arc<dyn crate::media::IImmutableEffect>>, bounds: Rect) -> Self::Scope;
50
51    fn on_pop(&mut self, scope: Self::Scope);
52}