paint/
pipeline_details.rs1use std::collections::VecDeque;
6
7use euclid::Scale;
8use paint_api::display_list::{PaintTimingInfo, ScrollTree};
9use paint_api::{CompositionPipeline, PipelineExitSource};
10use servo_base::Epoch;
11use servo_base::id::{ContainerTimingID, LCPCandidateID, PipelineId};
12use style_traits::CSSPixel;
13use webrender_api::Epoch as WebRenderEpoch;
14use webrender_api::units::DevicePixel;
15
16use crate::painter::PaintMetricState;
17use crate::web_content_animation::PipelineAnimations;
18
19pub(crate) struct PipelineDetails {
20 pub pipeline: Option<CompositionPipeline>,
22
23 pub parent_pipeline_id: Option<PipelineId>,
25
26 pub children: Vec<PipelineId>,
28
29 pub animations_running: bool,
31
32 pub animation_callbacks_running: bool,
34
35 pub throttled: bool,
37
38 pub scroll_tree: ScrollTree,
41
42 pub first_paint_metric: PaintMetricState,
44
45 pub first_contentful_paint_metric: PaintMetricState,
47
48 pub lcp_candidates: VecDeque<(WebRenderEpoch, (LCPCandidateID, usize), PaintTimingInfo)>,
50
51 pub container_timing_candidates: VecDeque<(WebRenderEpoch, Vec<ContainerTimingID>)>,
53
54 pub viewport_scale: Option<Scale<f32, CSSPixel, DevicePixel>>,
58
59 pub exited: PipelineExitSource,
62
63 pub display_list_epoch: Option<Epoch>,
66
67 pub animations: PipelineAnimations,
73}
74
75impl PipelineDetails {
76 pub(crate) fn animation_callbacks_running(&self) -> bool {
77 self.animation_callbacks_running
78 }
79
80 pub(crate) fn animating(&self) -> bool {
81 !self.throttled && (self.animation_callbacks_running || self.animations_running)
82 }
83}
84
85impl PipelineDetails {
86 pub(crate) fn new() -> PipelineDetails {
87 PipelineDetails {
88 pipeline: None,
89 parent_pipeline_id: None,
90 children: Default::default(),
91 viewport_scale: None,
92 animations_running: false,
93 animation_callbacks_running: false,
94 throttled: false,
95 scroll_tree: ScrollTree::default(),
96 first_paint_metric: PaintMetricState::Waiting,
97 first_contentful_paint_metric: PaintMetricState::Waiting,
98 lcp_candidates: VecDeque::new(),
99 container_timing_candidates: VecDeque::new(),
100 exited: PipelineExitSource::empty(),
101 display_list_epoch: None,
102 animations: Default::default(),
103 }
104 }
105
106 pub(crate) fn install_new_scroll_tree(&mut self, new_scroll_tree: ScrollTree) {
107 let old_scroll_offsets = self.scroll_tree.scroll_offsets();
108 self.scroll_tree = new_scroll_tree;
109 self.scroll_tree.set_all_scroll_offsets(&old_scroll_offsets);
110 }
111}