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::rc::Rc;
9
10use base::generic_channel::RoutedReceiver;
11use compositing_traits::rendering_context::RenderingContext;
12use compositing_traits::{CompositorMsg, CompositorProxy};
13use constellation_traits::EmbedderToConstellationMessage;
14use crossbeam_channel::Sender;
15use embedder_traits::{EventLoopWaker, ShutdownState};
16use profile_traits::{mem, time};
17use webrender::RenderApi;
18use webrender_api::DocumentId;
19
20pub use crate::compositor::{IOCompositor, WebRenderDebugOption};
21
22#[macro_use]
23mod tracing;
24
25mod compositor;
26mod refresh_driver;
27mod touch;
28mod webview_manager;
29mod webview_renderer;
30
31/// Data used to construct a compositor.
32pub struct InitialCompositorState {
33    /// A channel to the compositor.
34    pub sender: CompositorProxy,
35    /// A port on which messages inbound to the compositor can be received.
36    pub receiver: RoutedReceiver<CompositorMsg>,
37    /// A channel to the constellation.
38    pub constellation_chan: Sender<EmbedderToConstellationMessage>,
39    /// A channel to the time profiler thread.
40    pub time_profiler_chan: time::ProfilerChan,
41    /// A channel to the memory profiler thread.
42    pub mem_profiler_chan: mem::ProfilerChan,
43    /// A shared state which tracks whether Servo has started or has finished
44    /// shutting down.
45    pub shutdown_state: Rc<Cell<ShutdownState>>,
46    /// Instance of webrender API
47    pub webrender: webrender::Renderer,
48    pub webrender_document: DocumentId,
49    pub webrender_api: RenderApi,
50    pub rendering_context: Rc<dyn RenderingContext>,
51    pub webrender_gl: Rc<dyn gleam::gl::Gl>,
52    #[cfg(feature = "webxr")]
53    pub webxr_main_thread: webxr::MainThreadRegistry,
54    /// An [`EventLoopWaker`] used in order to wake up the embedder when it is
55    /// time to paint.
56    pub event_loop_waker: Box<dyn EventLoopWaker>,
57}