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 screenshot;
28mod touch;
29mod webview_manager;
30mod webview_renderer;
31
32/// Data used to construct a compositor.
33pub struct InitialCompositorState {
34    /// A channel to the compositor.
35    pub sender: CompositorProxy,
36    /// A port on which messages inbound to the compositor can be received.
37    pub receiver: RoutedReceiver<CompositorMsg>,
38    /// A channel to the constellation.
39    pub constellation_chan: Sender<EmbedderToConstellationMessage>,
40    /// A channel to the time profiler thread.
41    pub time_profiler_chan: time::ProfilerChan,
42    /// A channel to the memory profiler thread.
43    pub mem_profiler_chan: mem::ProfilerChan,
44    /// A shared state which tracks whether Servo has started or has finished
45    /// shutting down.
46    pub shutdown_state: Rc<Cell<ShutdownState>>,
47    /// Instance of webrender API
48    pub webrender: webrender::Renderer,
49    pub webrender_document: DocumentId,
50    pub webrender_api: RenderApi,
51    pub rendering_context: Rc<dyn RenderingContext>,
52    pub webrender_gl: Rc<dyn gleam::gl::Gl>,
53    #[cfg(feature = "webxr")]
54    pub webxr_main_thread: webxr::MainThreadRegistry,
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}