paint/
pipeline_details.rs1use std::collections::VecDeque;
6
7use euclid::Scale;
8use paint_api::display_list::{PaintTimingInfo, ScrollTree};
9use paint_api::{CompositionPipeline, PipelineExitSource};
10use rustc_hash::FxHashMap;
11use servo_base::Epoch;
12use servo_base::id::{ContainerTimingID, LCPCandidateID, PipelineId, ScrollTreeNodeId};
13use style_traits::CSSPixel;
14use webrender_api::units::{DevicePixel, LayoutRect};
15use webrender_api::{Epoch as WebRenderEpoch, PipelineId as WebRenderPipelineId};
16
17use crate::painter::PaintMetricState;
18use crate::web_content_animation::PipelineAnimations;
19
20pub(crate) struct PipelineDetails {
21 pub pipeline: Option<CompositionPipeline>,
23
24 pub parent_pipeline_id: Option<PipelineId>,
26
27 pub children: Vec<PipelineId>,
29
30 pub iframes: FxHashMap<WebRenderPipelineId, (ScrollTreeNodeId, LayoutRect)>,
34
35 pub animations_running: bool,
37
38 pub animation_callbacks_running: bool,
40
41 pub throttled: bool,
43
44 pub scroll_tree: ScrollTree,
47
48 pub first_paint_metric: PaintMetricState,
50
51 pub first_contentful_paint_metric: PaintMetricState,
53
54 pub lcp_candidates: VecDeque<(WebRenderEpoch, (LCPCandidateID, usize), PaintTimingInfo)>,
56
57 pub container_timing_candidates: VecDeque<(WebRenderEpoch, Vec<ContainerTimingID>)>,
59
60 pub viewport_scale: Option<Scale<f32, CSSPixel, DevicePixel>>,
64
65 pub exited: PipelineExitSource,
68
69 pub display_list_epoch: Option<Epoch>,
72
73 pub animations: PipelineAnimations,
79}
80
81impl PipelineDetails {
82 pub(crate) fn animation_callbacks_running(&self) -> bool {
83 self.animation_callbacks_running
84 }
85
86 pub(crate) fn animating(&self) -> bool {
87 !self.throttled && (self.animation_callbacks_running || self.animations_running)
88 }
89}
90
91impl PipelineDetails {
92 pub(crate) fn new() -> PipelineDetails {
93 PipelineDetails {
94 pipeline: None,
95 parent_pipeline_id: None,
96 children: Default::default(),
97 iframes: Default::default(),
98 viewport_scale: None,
99 animations_running: false,
100 animation_callbacks_running: false,
101 throttled: false,
102 scroll_tree: ScrollTree::default(),
103 first_paint_metric: PaintMetricState::Waiting,
104 first_contentful_paint_metric: PaintMetricState::Waiting,
105 lcp_candidates: VecDeque::new(),
106 container_timing_candidates: VecDeque::new(),
107 exited: PipelineExitSource::empty(),
108 display_list_epoch: None,
109 animations: Default::default(),
110 }
111 }
112
113 pub(crate) fn install_new_scroll_tree_and_iframes(
114 &mut self,
115 new_scroll_tree: ScrollTree,
116 iframes: FxHashMap<WebRenderPipelineId, (ScrollTreeNodeId, LayoutRect)>,
117 ) {
118 let old_scroll_offsets = self.scroll_tree.scroll_offsets();
119 self.scroll_tree = new_scroll_tree;
120 self.scroll_tree.set_all_scroll_offsets(&old_scroll_offsets);
121 self.iframes = iframes;
122 }
123}