mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Introduce InitialCompositorState
This commit is contained in:
parent
3d420abe40
commit
5cf8d597e6
4 changed files with 48 additions and 67 deletions
|
@ -3,7 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
|
use compositor_layer::{CompositorData, CompositorLayer, WantsScrollEventsFlag};
|
||||||
use compositor_task::{CompositorEventListener, CompositorProxy, CompositorReceiver, Msg};
|
use compositor_task::{CompositorEventListener, CompositorProxy};
|
||||||
|
use compositor_task::{CompositorReceiver, InitialCompositorState, Msg};
|
||||||
use constellation::SendableFrameTree;
|
use constellation::SendableFrameTree;
|
||||||
use pipeline::CompositionPipeline;
|
use pipeline::CompositionPipeline;
|
||||||
use scrolling::ScrollingTimerProxy;
|
use scrolling::ScrollingTimerProxy;
|
||||||
|
@ -248,23 +249,19 @@ pub fn reporter_name() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Window: WindowMethods> IOCompositor<Window> {
|
impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
fn new(window: Rc<Window>,
|
fn new(window: Rc<Window>, state: InitialCompositorState)
|
||||||
sender: Box<CompositorProxy + Send>,
|
|
||||||
receiver: Box<CompositorReceiver>,
|
|
||||||
constellation_chan: ConstellationChan,
|
|
||||||
time_profiler_chan: time::ProfilerChan,
|
|
||||||
mem_profiler_chan: mem::ProfilerChan)
|
|
||||||
-> IOCompositor<Window> {
|
-> IOCompositor<Window> {
|
||||||
// Register this thread as a memory reporter, via its own channel.
|
// Register this thread as a memory reporter, via its own channel.
|
||||||
let (reporter_sender, reporter_receiver) = ipc::channel().unwrap();
|
let (reporter_sender, reporter_receiver) = ipc::channel().unwrap();
|
||||||
let compositor_proxy_for_memory_reporter = sender.clone_compositor_proxy();
|
let compositor_proxy_for_memory_reporter = state.sender.clone_compositor_proxy();
|
||||||
ROUTER.add_route(reporter_receiver.to_opaque(), box move |reporter_request| {
|
ROUTER.add_route(reporter_receiver.to_opaque(), box move |reporter_request| {
|
||||||
let reporter_request: ReporterRequest = reporter_request.to().unwrap();
|
let reporter_request: ReporterRequest = reporter_request.to().unwrap();
|
||||||
compositor_proxy_for_memory_reporter.send(Msg::CollectMemoryReports(
|
compositor_proxy_for_memory_reporter.send(Msg::CollectMemoryReports(
|
||||||
reporter_request.reports_channel));
|
reporter_request.reports_channel));
|
||||||
});
|
});
|
||||||
let reporter = Reporter(reporter_sender);
|
let reporter = Reporter(reporter_sender);
|
||||||
mem_profiler_chan.send(mem::ProfilerMsg::RegisterReporter(reporter_name(), reporter));
|
state.mem_profiler_chan.send(
|
||||||
|
mem::ProfilerMsg::RegisterReporter(reporter_name(), reporter));
|
||||||
|
|
||||||
let window_size = window.framebuffer_size();
|
let window_size = window.framebuffer_size();
|
||||||
let hidpi_factor = window.hidpi_factor();
|
let hidpi_factor = window.hidpi_factor();
|
||||||
|
@ -276,7 +273,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
IOCompositor {
|
IOCompositor {
|
||||||
window: window,
|
window: window,
|
||||||
native_display: native_display,
|
native_display: native_display,
|
||||||
port: receiver,
|
port: state.receiver,
|
||||||
context: None,
|
context: None,
|
||||||
root_pipeline: None,
|
root_pipeline: None,
|
||||||
pipeline_details: HashMap::new(),
|
pipeline_details: HashMap::new(),
|
||||||
|
@ -286,8 +283,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}),
|
}),
|
||||||
window_size: window_size,
|
window_size: window_size,
|
||||||
hidpi_factor: hidpi_factor,
|
hidpi_factor: hidpi_factor,
|
||||||
channel_to_self: sender.clone_compositor_proxy(),
|
channel_to_self: state.sender.clone_compositor_proxy(),
|
||||||
scrolling_timer: ScrollingTimerProxy::new(sender),
|
scrolling_timer: ScrollingTimerProxy::new(state.sender),
|
||||||
composition_request: CompositionRequest::NoCompositingNecessary,
|
composition_request: CompositionRequest::NoCompositingNecessary,
|
||||||
pending_scroll_events: Vec::new(),
|
pending_scroll_events: Vec::new(),
|
||||||
composite_target: composite_target,
|
composite_target: composite_target,
|
||||||
|
@ -300,9 +297,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
zoom_time: 0f64,
|
zoom_time: 0f64,
|
||||||
got_load_complete_message: false,
|
got_load_complete_message: false,
|
||||||
frame_tree_id: FrameTreeId(0),
|
frame_tree_id: FrameTreeId(0),
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: state.constellation_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: state.time_profiler_chan,
|
||||||
mem_profiler_chan: mem_profiler_chan,
|
mem_profiler_chan: state.mem_profiler_chan,
|
||||||
fragment_point: None,
|
fragment_point: None,
|
||||||
last_composite_time: 0,
|
last_composite_time: 0,
|
||||||
has_seen_quit_event: false,
|
has_seen_quit_event: false,
|
||||||
|
@ -311,19 +308,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(window: Rc<Window>,
|
pub fn create(window: Rc<Window>, state: InitialCompositorState)
|
||||||
sender: Box<CompositorProxy + Send>,
|
|
||||||
receiver: Box<CompositorReceiver>,
|
|
||||||
constellation_chan: ConstellationChan,
|
|
||||||
time_profiler_chan: time::ProfilerChan,
|
|
||||||
mem_profiler_chan: mem::ProfilerChan)
|
|
||||||
-> IOCompositor<Window> {
|
-> IOCompositor<Window> {
|
||||||
let mut compositor = IOCompositor::new(window,
|
let mut compositor = IOCompositor::new(window, state);
|
||||||
sender,
|
|
||||||
receiver,
|
|
||||||
constellation_chan,
|
|
||||||
time_profiler_chan,
|
|
||||||
mem_profiler_chan);
|
|
||||||
|
|
||||||
// Set the size of the root layer.
|
// Set the size of the root layer.
|
||||||
compositor.update_zoom_transform();
|
compositor.update_zoom_transform();
|
||||||
|
|
|
@ -260,28 +260,16 @@ pub struct CompositorTask;
|
||||||
|
|
||||||
impl CompositorTask {
|
impl CompositorTask {
|
||||||
pub fn create<Window>(window: Option<Rc<Window>>,
|
pub fn create<Window>(window: Option<Rc<Window>>,
|
||||||
sender: Box<CompositorProxy + Send>,
|
state: InitialCompositorState)
|
||||||
receiver: Box<CompositorReceiver>,
|
|
||||||
constellation_chan: ConstellationChan,
|
|
||||||
time_profiler_chan: time::ProfilerChan,
|
|
||||||
mem_profiler_chan: mem::ProfilerChan)
|
|
||||||
-> Box<CompositorEventListener + 'static>
|
-> Box<CompositorEventListener + 'static>
|
||||||
where Window: WindowMethods + 'static {
|
where Window: WindowMethods + 'static {
|
||||||
match window {
|
match window {
|
||||||
Some(window) => {
|
Some(window) => {
|
||||||
box compositor::IOCompositor::create(window,
|
box compositor::IOCompositor::create(window, state)
|
||||||
sender,
|
|
||||||
receiver,
|
|
||||||
constellation_chan,
|
|
||||||
time_profiler_chan,
|
|
||||||
mem_profiler_chan)
|
|
||||||
as Box<CompositorEventListener>
|
as Box<CompositorEventListener>
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
box headless::NullCompositor::create(receiver,
|
box headless::NullCompositor::create(state)
|
||||||
constellation_chan,
|
|
||||||
time_profiler_chan,
|
|
||||||
mem_profiler_chan)
|
|
||||||
as Box<CompositorEventListener>
|
as Box<CompositorEventListener>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,3 +284,17 @@ pub trait CompositorEventListener {
|
||||||
/// Requests that the compositor send the title for the main frame as soon as possible.
|
/// Requests that the compositor send the title for the main frame as soon as possible.
|
||||||
fn title_for_main_frame(&self);
|
fn title_for_main_frame(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Data used to construct a compositor.
|
||||||
|
pub struct InitialCompositorState {
|
||||||
|
/// A channel to the compositor.
|
||||||
|
pub sender: Box<CompositorProxy + Send>,
|
||||||
|
/// A port on which messages inbound to the compositor can be received.
|
||||||
|
pub receiver: Box<CompositorReceiver>,
|
||||||
|
/// A channel to the constellation.
|
||||||
|
pub constellation_chan: ConstellationChan,
|
||||||
|
/// A channel to the time profiler thread.
|
||||||
|
pub time_profiler_chan: time::ProfilerChan,
|
||||||
|
/// A channel to the memory profiler thread.
|
||||||
|
pub mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use compositor_task::{CompositorEventListener, CompositorReceiver, Msg};
|
use compositor_task::{CompositorEventListener, CompositorReceiver};
|
||||||
|
use compositor_task::{InitialCompositorState, Msg};
|
||||||
use windowing::WindowEvent;
|
use windowing::WindowEvent;
|
||||||
|
|
||||||
use euclid::scale_factor::ScaleFactor;
|
use euclid::scale_factor::ScaleFactor;
|
||||||
|
@ -29,28 +30,17 @@ pub struct NullCompositor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NullCompositor {
|
impl NullCompositor {
|
||||||
fn new(port: Box<CompositorReceiver>,
|
fn new(state: InitialCompositorState) -> NullCompositor {
|
||||||
constellation_chan: ConstellationChan,
|
|
||||||
time_profiler_chan: time::ProfilerChan,
|
|
||||||
mem_profiler_chan: mem::ProfilerChan)
|
|
||||||
-> NullCompositor {
|
|
||||||
NullCompositor {
|
NullCompositor {
|
||||||
port: port,
|
port: state.receiver,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: state.constellation_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: state.time_profiler_chan,
|
||||||
mem_profiler_chan: mem_profiler_chan,
|
mem_profiler_chan: state.mem_profiler_chan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(port: Box<CompositorReceiver>,
|
pub fn create(state: InitialCompositorState) -> NullCompositor {
|
||||||
constellation_chan: ConstellationChan,
|
let compositor = NullCompositor::new(state);
|
||||||
time_profiler_chan: time::ProfilerChan,
|
|
||||||
mem_profiler_chan: mem::ProfilerChan)
|
|
||||||
-> NullCompositor {
|
|
||||||
let compositor = NullCompositor::new(port,
|
|
||||||
constellation_chan,
|
|
||||||
time_profiler_chan,
|
|
||||||
mem_profiler_chan);
|
|
||||||
|
|
||||||
// Tell the constellation about the initial fake size.
|
// Tell the constellation about the initial fake size.
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,6 +81,7 @@ pub use export::gleam::gl;
|
||||||
use compositing::CompositorEventListener;
|
use compositing::CompositorEventListener;
|
||||||
use compositing::windowing::WindowEvent;
|
use compositing::windowing::WindowEvent;
|
||||||
|
|
||||||
|
use compositing::compositor_task::InitialCompositorState;
|
||||||
use compositing::windowing::WindowMethods;
|
use compositing::windowing::WindowMethods;
|
||||||
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
||||||
|
|
||||||
|
@ -163,12 +164,13 @@ impl Browser {
|
||||||
|
|
||||||
// The compositor coordinates with the client window to create the final
|
// The compositor coordinates with the client window to create the final
|
||||||
// rendered page and display it somewhere.
|
// rendered page and display it somewhere.
|
||||||
let compositor = CompositorTask::create(window,
|
let compositor = CompositorTask::create(window, InitialCompositorState {
|
||||||
compositor_proxy,
|
sender: compositor_proxy,
|
||||||
compositor_receiver,
|
receiver: compositor_receiver,
|
||||||
constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
mem_profiler_chan);
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
|
});
|
||||||
|
|
||||||
Browser {
|
Browser {
|
||||||
compositor: compositor,
|
compositor: compositor,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue