mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Use opts as a global, to avoid cloning and passing the struct all over the code.
This commit is contained in:
parent
a983debaf1
commit
076495db94
20 changed files with 108 additions and 132 deletions
|
@ -42,7 +42,7 @@ use servo_msg::constellation_msg::{LoadData, PipelineId, ResizedWindowMsg, Windo
|
|||
use servo_msg::constellation_msg;
|
||||
use servo_util::geometry::{PagePx, ScreenPx, ViewportPx};
|
||||
use servo_util::memory::MemoryProfilerChan;
|
||||
use servo_util::opts::Opts;
|
||||
use servo_util::opts;
|
||||
use servo_util::time::{profile, TimeProfilerChan};
|
||||
use servo_util::{memory, time};
|
||||
use std::io::timer::sleep;
|
||||
|
@ -112,9 +112,6 @@ pub struct IOCompositor<Window: WindowMethods> {
|
|||
/// many times for a single page.
|
||||
got_load_complete_message: bool,
|
||||
|
||||
/// The command line option flags.
|
||||
opts: Opts,
|
||||
|
||||
/// The channel on which messages can be sent to the constellation.
|
||||
constellation_chan: ConstellationChan,
|
||||
|
||||
|
@ -137,7 +134,6 @@ enum ShutdownState {
|
|||
|
||||
impl<Window: WindowMethods> IOCompositor<Window> {
|
||||
fn new(window: Rc<Window>,
|
||||
opts: Opts,
|
||||
port: Receiver<Msg>,
|
||||
constellation_chan: ConstellationChan,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
|
@ -150,11 +146,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let window_size = window.framebuffer_size();
|
||||
let hidpi_factor = window.hidpi_factor();
|
||||
|
||||
let show_debug_borders = opts.show_debug_borders;
|
||||
let show_debug_borders = opts::get().show_debug_borders;
|
||||
IOCompositor {
|
||||
window: window,
|
||||
port: port,
|
||||
opts: opts,
|
||||
context: rendergl::RenderContext::new(CompositorTask::create_graphics_context(),
|
||||
show_debug_borders),
|
||||
root_pipeline: None,
|
||||
|
@ -183,13 +178,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
|
||||
pub fn create(window: Rc<Window>,
|
||||
opts: Opts,
|
||||
port: Receiver<Msg>,
|
||||
constellation_chan: ConstellationChan,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
memory_profiler_chan: MemoryProfilerChan) {
|
||||
let mut compositor = IOCompositor::new(window,
|
||||
opts,
|
||||
port,
|
||||
constellation_chan,
|
||||
time_profiler_chan,
|
||||
|
@ -373,7 +366,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
fn has_render_msg_tracking(&self) -> bool {
|
||||
// only track RenderMsg's if the compositor outputs to a file.
|
||||
self.opts.output_file.is_some()
|
||||
opts::get().output_file.is_some()
|
||||
}
|
||||
|
||||
fn has_outstanding_render_msgs(&self) -> bool {
|
||||
|
@ -440,7 +433,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let root_layer = CompositorData::new_layer(frame_tree.pipeline.clone(),
|
||||
layer_properties,
|
||||
WantsScrollEvents,
|
||||
self.opts.tile_size);
|
||||
opts::get().tile_size);
|
||||
|
||||
match frame_rect {
|
||||
Some(ref frame_rect) => {
|
||||
|
@ -500,7 +493,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let first_child = CompositorData::new_layer(root_layer_pipeline.clone(),
|
||||
layer_properties,
|
||||
DoesntWantScrollEvents,
|
||||
self.opts.tile_size);
|
||||
opts::get().tile_size);
|
||||
|
||||
// Add the first child / base layer to the front of the child list, so that
|
||||
// child iframe layers are rendered on top of the base layer. These iframe
|
||||
|
@ -671,7 +664,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
|
||||
FinishedWindowEvent => {
|
||||
let exit = self.opts.exit_after_load;
|
||||
let exit = opts::get().exit_after_load;
|
||||
if exit {
|
||||
debug!("shutting down the constellation for FinishedWindowEvent");
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
|
@ -758,9 +751,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
|
||||
fn device_pixels_per_screen_px(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
||||
match self.opts.device_pixels_per_px {
|
||||
match opts::get().device_pixels_per_px {
|
||||
Some(device_pixels_per_px) => device_pixels_per_px,
|
||||
None => match self.opts.output_file {
|
||||
None => match opts::get().output_file {
|
||||
Some(_) => ScaleFactor(1.0),
|
||||
None => self.hidpi_factor
|
||||
}
|
||||
|
@ -917,7 +910,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
|
||||
fn composite(&mut self) {
|
||||
let output_image = self.opts.output_file.is_some() &&
|
||||
let output_image = opts::get().output_file.is_some() &&
|
||||
self.is_ready_to_render_image_output();
|
||||
|
||||
let mut framebuffer_ids = vec!();
|
||||
|
@ -959,7 +952,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
});
|
||||
|
||||
if output_image {
|
||||
let path = from_str::<Path>(self.opts.output_file.as_ref().unwrap().as_slice()).unwrap();
|
||||
let path = from_str::<Path>(opts::get().output_file.as_ref().unwrap().as_slice()).unwrap();
|
||||
let mut pixels = gl2::read_pixels(0, 0,
|
||||
width as gl2::GLsizei,
|
||||
height as gl2::GLsizei,
|
||||
|
@ -998,7 +991,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
self.window.present();
|
||||
|
||||
let exit = self.opts.exit_after_load;
|
||||
let exit = opts::get().exit_after_load;
|
||||
if exit {
|
||||
debug!("shutting down the constellation for exit_after_load");
|
||||
let ConstellationChan(ref chan) = self.constellation_chan;
|
||||
|
|
|
@ -19,7 +19,6 @@ use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState};
|
|||
use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, ScrollPolicy};
|
||||
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||
use servo_util::memory::MemoryProfilerChan;
|
||||
use servo_util::opts::Opts;
|
||||
use servo_util::time::TimeProfilerChan;
|
||||
use std::comm::{channel, Sender, Receiver};
|
||||
use std::rc::Rc;
|
||||
|
@ -200,7 +199,6 @@ impl CompositorTask {
|
|||
|
||||
pub fn create<Window: WindowMethods>(
|
||||
window: Option<Rc<Window>>,
|
||||
opts: Opts,
|
||||
port: Receiver<Msg>,
|
||||
constellation_chan: ConstellationChan,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
|
@ -209,7 +207,6 @@ impl CompositorTask {
|
|||
match window {
|
||||
Some(window) => {
|
||||
compositor::IOCompositor::create(window,
|
||||
opts,
|
||||
port,
|
||||
constellation_chan.clone(),
|
||||
time_profiler_chan,
|
||||
|
|
|
@ -25,7 +25,7 @@ use gfx::font_cache_task::FontCacheTask;
|
|||
use servo_net::resource_task::ResourceTask;
|
||||
use servo_net::resource_task;
|
||||
use servo_util::geometry::PagePx;
|
||||
use servo_util::opts::Opts;
|
||||
use servo_util::opts;
|
||||
use servo_util::time::TimeProfilerChan;
|
||||
use servo_util::task::spawn_named;
|
||||
use std::cell::RefCell;
|
||||
|
@ -50,7 +50,6 @@ pub struct Constellation<LTF, STF> {
|
|||
pending_sizes: HashMap<(PipelineId, SubpageId), TypedRect<PagePx, f32>>,
|
||||
pub time_profiler_chan: TimeProfilerChan,
|
||||
pub window_size: WindowSizeData,
|
||||
pub opts: Opts,
|
||||
}
|
||||
|
||||
/// Stores the Id of the outermost frame's pipeline, along with a vector of children frames
|
||||
|
@ -241,7 +240,6 @@ impl NavigationContext {
|
|||
|
||||
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||
pub fn start(compositor_chan: CompositorChan,
|
||||
opts: &Opts,
|
||||
resource_task: ResourceTask,
|
||||
image_cache_task: ImageCacheTask,
|
||||
font_cache_task: FontCacheTask,
|
||||
|
@ -250,7 +248,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
-> ConstellationChan {
|
||||
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
||||
let constellation_chan_clone = constellation_chan.clone();
|
||||
let opts_clone = opts.clone();
|
||||
spawn_named("Constellation", proc() {
|
||||
let mut constellation : Constellation<LTF, STF> = Constellation {
|
||||
chan: constellation_chan_clone,
|
||||
|
@ -267,11 +264,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
pending_sizes: HashMap::new(),
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
window_size: WindowSizeData {
|
||||
visible_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
initial_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
visible_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
initial_viewport: opts::get().initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
device_pixel_ratio: ScaleFactor(1.0),
|
||||
},
|
||||
opts: opts_clone,
|
||||
};
|
||||
constellation.run();
|
||||
});
|
||||
|
@ -304,7 +300,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
self.resource_task.clone(),
|
||||
self.time_profiler_chan.clone(),
|
||||
self.window_size,
|
||||
self.opts.clone(),
|
||||
script_pipeline,
|
||||
load_data);
|
||||
pipe.load();
|
||||
|
@ -405,7 +400,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
|
||||
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, subpage_id);
|
||||
|
||||
if self.opts.hard_fail {
|
||||
if opts::get().hard_fail {
|
||||
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
|
||||
// Hard fail exists for test runners so we crash and that's good enough.
|
||||
let mut stderr = io::stderr();
|
||||
|
|
|
@ -15,7 +15,6 @@ use servo_msg::constellation_msg::{LoadData, WindowSizeData};
|
|||
use servo_net::image_cache_task::ImageCacheTask;
|
||||
use gfx::font_cache_task::FontCacheTask;
|
||||
use servo_net::resource_task::ResourceTask;
|
||||
use servo_util::opts::Opts;
|
||||
use servo_util::time::TimeProfilerChan;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -55,7 +54,6 @@ impl Pipeline {
|
|||
resource_task: ResourceTask,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
window_size: WindowSizeData,
|
||||
opts: Opts,
|
||||
script_pipeline: Option<Rc<Pipeline>>,
|
||||
load_data: LoadData)
|
||||
-> Pipeline {
|
||||
|
@ -107,7 +105,6 @@ impl Pipeline {
|
|||
constellation_chan.clone(),
|
||||
font_cache_task.clone(),
|
||||
failure.clone(),
|
||||
opts.clone(),
|
||||
time_profiler_chan.clone(),
|
||||
render_shutdown_chan);
|
||||
|
||||
|
@ -122,7 +119,6 @@ impl Pipeline {
|
|||
resource_task,
|
||||
image_cache_task,
|
||||
font_cache_task,
|
||||
opts.clone(),
|
||||
time_profiler_chan,
|
||||
layout_shutdown_chan);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue