compositing/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5#![deny(unsafe_code)]
6
7use std::cell::Cell;
8use std::path::PathBuf;
9use std::rc::Rc;
10
11use base::generic_channel::RoutedReceiver;
12use compositing_traits::rendering_context::RenderingContext;
13use compositing_traits::{CompositorMsg, CompositorProxy};
14use constellation_traits::EmbedderToConstellationMessage;
15use crossbeam_channel::Sender;
16use embedder_traits::{EventLoopWaker, RefreshDriver, ShutdownState};
17use profile_traits::{mem, time};
18#[cfg(feature = "webxr")]
19use webxr::WebXrRegistry;
20
21pub use crate::compositor::{IOCompositor, WebRenderDebugOption};
22
23#[macro_use]
24mod tracing;
25
26mod compositor;
27mod largest_contentful_paint_calculator;
28mod painter;
29mod pinch_zoom;
30mod pipeline_details;
31mod refresh_driver;
32mod render_notifier;
33mod screenshot;
34mod touch;
35mod webview_manager;
36mod webview_renderer;
37
38/// Data used to construct a compositor.
39pub struct InitialCompositorState {
40    /// A channel to the compositor.
41    pub compositor_proxy: CompositorProxy,
42    /// A port on which messages inbound to the compositor can be received.
43    pub receiver: RoutedReceiver<CompositorMsg>,
44    /// A channel to the constellation.
45    pub embedder_to_constellation_sender: Sender<EmbedderToConstellationMessage>,
46    /// A channel to the time profiler thread.
47    pub time_profiler_chan: time::ProfilerChan,
48    /// A channel to the memory profiler thread.
49    pub mem_profiler_chan: mem::ProfilerChan,
50    /// A shared state which tracks whether Servo has started or has finished
51    /// shutting down.
52    pub shutdown_state: Rc<Cell<ShutdownState>>,
53    /// The target [`RenderingContext`] of this renderer.
54    pub rendering_context: Rc<dyn RenderingContext>,
55    /// An [`EventLoopWaker`] used in order to wake up the embedder when it is
56    /// time to paint.
57    pub event_loop_waker: Box<dyn EventLoopWaker>,
58    /// An optional [`RefreshDriver`] provided by the embedder.
59    pub refresh_driver: Option<Rc<dyn RefreshDriver>>,
60    /// A [`PathBuf`] which can be used to override WebRender shaders.
61    pub shaders_path: Option<PathBuf>,
62    /// If WebXR is enabled, a [`WebXrRegistry`] to register WebXR threads.
63    #[cfg(feature = "webxr")]
64    pub webxr_registry: Box<dyn WebXrRegistry>,
65}