jellyflow_runtime/io/tuning/
runtime.rs1use serde::{Deserialize, Serialize};
2
3use super::{NodeGraphPaintCachePruneTuning, NodeGraphSpatialIndexTuning};
4
5#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
10pub struct NodeGraphRuntimeTuning {
11 #[serde(default = "default_spatial_index_tuning")]
13 pub spatial_index: NodeGraphSpatialIndexTuning,
14 #[serde(default = "default_only_render_visible_elements")]
16 pub only_render_visible_elements: bool,
17 #[serde(default = "default_paint_cache_prune_tuning")]
19 pub paint_cache_prune: NodeGraphPaintCachePruneTuning,
20}
21
22impl NodeGraphRuntimeTuning {
23 pub fn is_default(this: &Self) -> bool {
24 this == &Self::default()
25 }
26
27 pub fn with_spatial_index_enabled(mut self, enabled: bool) -> Self {
28 self.spatial_index.enabled = enabled;
29 self
30 }
31
32 pub fn with_only_render_visible_elements(mut self, enabled: bool) -> Self {
33 self.only_render_visible_elements = enabled;
34 self
35 }
36}
37
38impl Default for NodeGraphRuntimeTuning {
39 fn default() -> Self {
40 Self {
41 spatial_index: default_spatial_index_tuning(),
42 only_render_visible_elements: default_only_render_visible_elements(),
43 paint_cache_prune: default_paint_cache_prune_tuning(),
44 }
45 }
46}
47
48fn default_spatial_index_tuning() -> NodeGraphSpatialIndexTuning {
49 NodeGraphSpatialIndexTuning::default()
50}
51
52fn default_paint_cache_prune_tuning() -> NodeGraphPaintCachePruneTuning {
53 NodeGraphPaintCachePruneTuning::default()
54}
55
56pub(crate) fn default_only_render_visible_elements() -> bool {
57 true
58}