cranpose_render_common/scene_store/
layer_props.rs1#[cfg(feature = "window-damage")]
6use cranpose_core::SceneUpdate;
7use cranpose_ui::{Point, Rect};
8
9use super::translate_run::TranslateRun;
10use crate::graph::{CachePolicy, HitTestNode, IsolationReasons};
11
12#[derive(Clone, Default)]
16pub struct LayerProps {
17 pub layer_bounds: Option<Rect>,
20 pub translated_content_offset: Point,
23 pub hit_test: Option<HitTestNode>,
25 pub isolation: IsolationReasons,
27 pub cache_policy: CachePolicy,
29 #[cfg(feature = "window-damage")]
30 pub(crate) content_run: ContentRun,
31 pub(crate) translate_run: TranslateRun,
33}
34
35impl LayerProps {
36 pub(crate) fn is_default(&self) -> bool {
39 self.layer_bounds.is_none()
40 && self.translated_content_offset == Point::default()
41 && self.hit_test.is_none()
42 && !self.isolation.has_any()
43 && self.cache_policy == CachePolicy::None
44 }
45}
46
47#[cfg(feature = "window-damage")]
50#[derive(Clone, Copy, Debug, Default)]
51pub(crate) struct ContentRun {
52 last: SceneUpdate,
53 run: u32,
54}
55
56#[cfg(feature = "window-damage")]
57impl ContentRun {
58 pub(crate) fn note(&mut self, update: SceneUpdate) {
59 if self.run > 0 && self.last == update {
60 return;
61 }
62 self.run = if self.run > 0 && self.last.next() == update {
63 self.run + 1
64 } else {
65 1
66 };
67 self.last = update;
68 }
69
70 pub(crate) fn churns(self, update: SceneUpdate) -> bool {
71 self.run >= 2 && self.last == update
72 }
73}