mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Hoist retrieval of layout_threads from opts into Constellation
This commit is contained in:
parent
9c0e7b1cf2
commit
e182d29441
6 changed files with 26 additions and 10 deletions
|
@ -160,6 +160,7 @@ impl Pipeline {
|
||||||
pipeline_port: pipeline_port,
|
pipeline_port: pipeline_port,
|
||||||
layout_to_constellation_chan: state.layout_to_constellation_chan.clone(),
|
layout_to_constellation_chan: state.layout_to_constellation_chan.clone(),
|
||||||
content_process_shutdown_chan: layout_content_process_shutdown_chan.clone(),
|
content_process_shutdown_chan: layout_content_process_shutdown_chan.clone(),
|
||||||
|
layout_threads: opts::get().layout_threads,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)) {
|
if let Err(e) = script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)) {
|
||||||
|
@ -470,7 +471,8 @@ impl UnprivilegedPipelineContent {
|
||||||
self.time_profiler_chan,
|
self.time_profiler_chan,
|
||||||
self.mem_profiler_chan,
|
self.mem_profiler_chan,
|
||||||
self.layout_content_process_shutdown_chan,
|
self.layout_content_process_shutdown_chan,
|
||||||
self.webrender_api_sender);
|
self.webrender_api_sender,
|
||||||
|
opts::get().layout_threads);
|
||||||
|
|
||||||
if wait_for_completion {
|
if wait_for_completion {
|
||||||
let _ = self.script_content_process_shutdown_port.recv();
|
let _ = self.script_content_process_shutdown_port.recv();
|
||||||
|
|
|
@ -232,6 +232,10 @@ pub struct LayoutThread {
|
||||||
/// The timer object to control the timing of the animations. This should
|
/// The timer object to control the timing of the animations. This should
|
||||||
/// only be a test-mode timer during testing for animations.
|
/// only be a test-mode timer during testing for animations.
|
||||||
timer: Timer,
|
timer: Timer,
|
||||||
|
|
||||||
|
// Number of layout threads. This is copied from `util::opts`, but we'd
|
||||||
|
// rather limit the dependency on that module here.
|
||||||
|
layout_threads: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutThreadFactory for LayoutThread {
|
impl LayoutThreadFactory for LayoutThread {
|
||||||
|
@ -251,7 +255,8 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
content_process_shutdown_chan: IpcSender<()>,
|
content_process_shutdown_chan: IpcSender<()>,
|
||||||
webrender_api_sender: Option<webrender_traits::RenderApiSender>) {
|
webrender_api_sender: Option<webrender_traits::RenderApiSender>,
|
||||||
|
layout_threads: usize) {
|
||||||
thread::spawn_named(format!("LayoutThread {:?}", id),
|
thread::spawn_named(format!("LayoutThread {:?}", id),
|
||||||
move || {
|
move || {
|
||||||
thread_state::initialize(thread_state::LAYOUT);
|
thread_state::initialize(thread_state::LAYOUT);
|
||||||
|
@ -270,7 +275,8 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
font_cache_thread,
|
font_cache_thread,
|
||||||
time_profiler_chan,
|
time_profiler_chan,
|
||||||
mem_profiler_chan.clone(),
|
mem_profiler_chan.clone(),
|
||||||
webrender_api_sender);
|
webrender_api_sender,
|
||||||
|
layout_threads);
|
||||||
|
|
||||||
let reporter_name = format!("layout-reporter-{}", id);
|
let reporter_name = format!("layout-reporter-{}", id);
|
||||||
mem_profiler_chan.run_with_memory_reporting(|| {
|
mem_profiler_chan.run_with_memory_reporting(|| {
|
||||||
|
@ -381,14 +387,14 @@ impl LayoutThread {
|
||||||
font_cache_thread: FontCacheThread,
|
font_cache_thread: FontCacheThread,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
webrender_api_sender: Option<webrender_traits::RenderApiSender>)
|
webrender_api_sender: Option<webrender_traits::RenderApiSender>,
|
||||||
|
layout_threads: usize)
|
||||||
-> LayoutThread {
|
-> LayoutThread {
|
||||||
let device = Device::new(
|
let device = Device::new(
|
||||||
MediaType::Screen,
|
MediaType::Screen,
|
||||||
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0));
|
||||||
let parallel_traversal = if opts::get().layout_threads != 1 {
|
let parallel_traversal = if layout_threads != 1 {
|
||||||
Some(WorkQueue::new("LayoutWorker", thread_state::LAYOUT,
|
Some(WorkQueue::new("LayoutWorker", thread_state::LAYOUT, layout_threads))
|
||||||
opts::get().layout_threads))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -479,6 +485,7 @@ impl LayoutThread {
|
||||||
} else {
|
} else {
|
||||||
Timer::new()
|
Timer::new()
|
||||||
},
|
},
|
||||||
|
layout_threads: layout_threads,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +761,8 @@ impl LayoutThread {
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.mem_profiler_chan.clone(),
|
self.mem_profiler_chan.clone(),
|
||||||
info.content_process_shutdown_chan,
|
info.content_process_shutdown_chan,
|
||||||
self.webrender_api.as_ref().map(|wr| wr.clone_sender()));
|
self.webrender_api.as_ref().map(|wr| wr.clone_sender()),
|
||||||
|
info.layout_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is
|
/// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is
|
||||||
|
@ -1158,7 +1166,7 @@ impl LayoutThread {
|
||||||
// TODO(pcwalton): Measure energy usage of text shaping, perhaps?
|
// TODO(pcwalton): Measure energy usage of text shaping, perhaps?
|
||||||
let text_shaping_time =
|
let text_shaping_time =
|
||||||
(font::get_and_reset_text_shaping_performance_counter() as u64) /
|
(font::get_and_reset_text_shaping_performance_counter() as u64) /
|
||||||
(opts::get().layout_threads as u64);
|
(self.layout_threads as u64);
|
||||||
time::send_profile_data(time::ProfilerCategory::LayoutTextShaping,
|
time::send_profile_data(time::ProfilerCategory::LayoutTextShaping,
|
||||||
self.profiler_metadata(),
|
self.profiler_metadata(),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|
|
|
@ -48,5 +48,6 @@ pub trait LayoutThreadFactory {
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
content_process_shutdown_chan: IpcSender<()>,
|
content_process_shutdown_chan: IpcSender<()>,
|
||||||
webrender_api_sender: Option<webrender_traits::RenderApiSender>);
|
webrender_api_sender: Option<webrender_traits::RenderApiSender>,
|
||||||
|
layout_threads: usize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1142,6 +1142,7 @@ impl ScriptThread {
|
||||||
pipeline_port,
|
pipeline_port,
|
||||||
layout_to_constellation_chan,
|
layout_to_constellation_chan,
|
||||||
content_process_shutdown_chan,
|
content_process_shutdown_chan,
|
||||||
|
layout_threads,
|
||||||
} = new_layout_info;
|
} = new_layout_info;
|
||||||
|
|
||||||
let layout_pair = channel();
|
let layout_pair = channel();
|
||||||
|
@ -1158,6 +1159,7 @@ impl ScriptThread {
|
||||||
script_chan: self.control_chan.clone(),
|
script_chan: self.control_chan.clone(),
|
||||||
image_cache_thread: self.image_cache_thread.clone(),
|
image_cache_thread: self.image_cache_thread.clone(),
|
||||||
content_process_shutdown_chan: content_process_shutdown_chan,
|
content_process_shutdown_chan: content_process_shutdown_chan,
|
||||||
|
layout_threads: layout_threads,
|
||||||
};
|
};
|
||||||
|
|
||||||
let context = self.root_browsing_context();
|
let context = self.root_browsing_context();
|
||||||
|
|
|
@ -149,4 +149,5 @@ pub struct NewLayoutThreadInfo {
|
||||||
pub image_cache_thread: ImageCacheThread,
|
pub image_cache_thread: ImageCacheThread,
|
||||||
pub paint_chan: OptionalOpaqueIpcSender,
|
pub paint_chan: OptionalOpaqueIpcSender,
|
||||||
pub content_process_shutdown_chan: IpcSender<()>,
|
pub content_process_shutdown_chan: IpcSender<()>,
|
||||||
|
pub layout_threads: usize,
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,8 @@ pub struct NewLayoutInfo {
|
||||||
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
/// A shutdown channel so that layout can tell the content process to shut down when it's done.
|
/// A shutdown channel so that layout can tell the content process to shut down when it's done.
|
||||||
pub content_process_shutdown_chan: IpcSender<()>,
|
pub content_process_shutdown_chan: IpcSender<()>,
|
||||||
|
/// Number of threads to use for layout.
|
||||||
|
pub layout_threads: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Messages sent from the constellation or layout to the script thread.
|
/// Messages sent from the constellation or layout to the script thread.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue