euv_chart/display/struct.rs
1use super::*;
2
3/// One entry of the display list.
4#[derive(Clone, Data, Debug)]
5pub struct DisplayItem {
6 /// The drawing instruction.
7 pub cmd: DrawCmd,
8 /// The paint-order key.
9 ///
10 /// Items are drawn in ascending `z`; items with the same `z` are drawn
11 /// in the order they were added.
12 #[get(type(copy))]
13 pub z: i32,
14 /// The identity of the element this item belongs to, used to route
15 /// pointer events.
16 #[get(type(copy))]
17 pub element_id: u32,
18 /// The series this item belongs to, if any.
19 #[get(skip)]
20 #[get_mut(pub(crate))]
21 #[set(pub(crate))]
22 pub series_index: Option<usize>,
23 /// The data index this item belongs to, if any.
24 #[get(skip)]
25 #[get_mut(pub(crate))]
26 #[set(pub(crate))]
27 pub data_index: Option<usize>,
28}
29
30/// The ordered list of drawing instructions produced by the chart model.
31///
32/// The list is retained between frames: a chart that does not change does
33/// not rebuild it, and the GPU backends keep their buffers in sync with
34/// it rather than re-uploading every frame. This is the single biggest
35/// reason the chart crate is faster than a JavaScript implementation: an
36/// unchanged chart costs nothing to draw.
37#[derive(Clone, Data, Debug, Default)]
38pub struct DisplayList {
39 /// The items, in paint order.
40 #[get(pub(crate))]
41 #[get_mut(pub(crate))]
42 #[set(pub(crate))]
43 pub(crate) items: Vec<DisplayItem>,
44 /// The bounds of everything in the list.
45 #[get(pub(crate))]
46 #[get_mut(pub(crate))]
47 #[set(pub(crate))]
48 pub(crate) bounds: BBox,
49}