mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Extract device_pixels_per_px from global opts
This is also an embedder specific option, so removing it from the global options makes sense.
This commit is contained in:
parent
74f1e2ec32
commit
0ee300479e
9 changed files with 67 additions and 36 deletions
|
@ -32,10 +32,6 @@ pub struct Opts {
|
|||
/// The maximum size of each tile in pixels (`-s`).
|
||||
pub tile_size: usize,
|
||||
|
||||
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
|
||||
/// platform default setting.
|
||||
pub device_pixels_per_px: Option<f32>,
|
||||
|
||||
/// `None` to disable the time profiler or `Some` to enable it with:
|
||||
///
|
||||
/// - an interval in seconds to cause it to produce output on that interval.
|
||||
|
@ -524,7 +520,6 @@ pub fn default_opts() -> Opts {
|
|||
is_running_problem_test: false,
|
||||
url: None,
|
||||
tile_size: 512,
|
||||
device_pixels_per_px: None,
|
||||
time_profiling: None,
|
||||
time_profiler_trace_path: None,
|
||||
mem_profiler_period: None,
|
||||
|
@ -587,7 +582,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
|
|||
opts.optflag("g", "gpu", "GPU painting");
|
||||
opts.optopt("o", "output", "Output file", "output.png");
|
||||
opts.optopt("s", "size", "Size of tiles", "512");
|
||||
opts.optopt("", "device-pixel-ratio", "Device pixels per px", "");
|
||||
opts.optflagopt(
|
||||
"p",
|
||||
"profile",
|
||||
|
@ -792,15 +786,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
|
|||
None => 512,
|
||||
};
|
||||
|
||||
let device_pixels_per_px = opt_match.opt_str("device-pixel-ratio").map(|dppx_str| {
|
||||
dppx_str.parse().unwrap_or_else(|err| {
|
||||
args_fail(&format!(
|
||||
"Error parsing option: --device-pixel-ratio ({})",
|
||||
err
|
||||
))
|
||||
})
|
||||
});
|
||||
|
||||
// If only the flag is present, default to a 5 second period for both profilers
|
||||
let time_profiling = if opt_match.opt_present("p") {
|
||||
match opt_match.opt_str("p") {
|
||||
|
@ -951,7 +936,6 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
|
|||
is_running_problem_test: is_running_problem_test,
|
||||
url: url_opt,
|
||||
tile_size: tile_size,
|
||||
device_pixels_per_px: device_pixels_per_px,
|
||||
time_profiling: time_profiling,
|
||||
time_profiler_trace_path: opt_match.opt_str("profiler-trace-path"),
|
||||
mem_profiler_period: mem_profiler_period,
|
||||
|
|
|
@ -464,6 +464,10 @@ pub struct Constellation<Message, LTF, STF> {
|
|||
|
||||
/// Mechanism to force the compositor to process events.
|
||||
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
||||
|
||||
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
|
||||
/// platform default setting.
|
||||
device_pixels_per_px: Option<f32>,
|
||||
}
|
||||
|
||||
/// State needed to construct a constellation.
|
||||
|
@ -520,6 +524,10 @@ pub struct InitialConstellationState {
|
|||
|
||||
/// Mechanism to force the compositor to process events.
|
||||
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
||||
|
||||
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
|
||||
/// platform default setting.
|
||||
pub device_pixels_per_px: Option<f32>,
|
||||
}
|
||||
|
||||
/// Data needed for webdriver
|
||||
|
@ -837,6 +845,7 @@ where
|
|||
glplayer_threads: state.glplayer_threads,
|
||||
player_context: state.player_context,
|
||||
event_loop_waker: state.event_loop_waker,
|
||||
device_pixels_per_px,
|
||||
};
|
||||
|
||||
constellation.run();
|
||||
|
@ -1081,6 +1090,7 @@ where
|
|||
webxr_registry: self.webxr_registry.clone(),
|
||||
player_context: self.player_context.clone(),
|
||||
event_loop_waker: self.event_loop_waker.as_ref().map(|w| (*w).clone_box()),
|
||||
device_pixels_per_px: self.device_pixels_per_px,
|
||||
});
|
||||
|
||||
let pipeline = match result {
|
||||
|
|
|
@ -205,6 +205,10 @@ pub struct InitialPipelineState {
|
|||
|
||||
/// Mechanism to force the compositor to process events.
|
||||
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
||||
|
||||
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
|
||||
/// platform default setting.
|
||||
pub device_pixels_per_px: Option<f32>,
|
||||
}
|
||||
|
||||
pub struct NewPipeline {
|
||||
|
@ -312,6 +316,7 @@ impl Pipeline {
|
|||
webvr_chan: state.webvr_chan,
|
||||
webxr_registry: state.webxr_registry,
|
||||
player_context: state.player_context,
|
||||
device_pixels_per_px: state.device_pixels_per_px,
|
||||
};
|
||||
|
||||
// Spawn the child process.
|
||||
|
@ -518,6 +523,7 @@ pub struct UnprivilegedPipelineContent {
|
|||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
webxr_registry: webxr_api::Registry,
|
||||
player_context: WindowGLContext,
|
||||
device_pixels_per_px: Option<f32>,
|
||||
}
|
||||
|
||||
impl UnprivilegedPipelineContent {
|
||||
|
@ -609,7 +615,7 @@ impl UnprivilegedPipelineContent {
|
|||
layout_thread_busy_flag.clone(),
|
||||
self.opts.load_webfonts_synchronously,
|
||||
self.opts.initial_window_size,
|
||||
self.opts.device_pixels_per_px,
|
||||
self.device_pixels_per_px,
|
||||
self.opts.dump_display_list,
|
||||
self.opts.dump_display_list_json,
|
||||
self.opts.dump_style_tree,
|
||||
|
|
|
@ -306,7 +306,11 @@ impl<Window> Servo<Window>
|
|||
where
|
||||
Window: WindowMethods + 'static + ?Sized,
|
||||
{
|
||||
pub fn new(mut embedder: Box<dyn EmbedderMethods>, window: Rc<Window>) -> Servo<Window> {
|
||||
pub fn new(
|
||||
mut embedder: Box<dyn EmbedderMethods>,
|
||||
window: Rc<Window>,
|
||||
device_pixels_per_px: Option<f32>,
|
||||
) -> Servo<Window> {
|
||||
// Global configuration options, parsed from the command line.
|
||||
let opts = opts::get();
|
||||
|
||||
|
@ -551,6 +555,7 @@ where
|
|||
webvr_constellation_sender,
|
||||
glplayer_threads,
|
||||
event_loop_waker,
|
||||
device_pixels_per_px,
|
||||
);
|
||||
|
||||
// Send the constellation's swmanager sender to service worker manager thread
|
||||
|
@ -582,7 +587,7 @@ where
|
|||
opts.is_running_problem_test,
|
||||
opts.exit_after_load,
|
||||
opts.convert_mouse_to_touch,
|
||||
opts.device_pixels_per_px,
|
||||
device_pixels_per_px,
|
||||
);
|
||||
|
||||
Servo {
|
||||
|
@ -870,6 +875,7 @@ fn create_constellation(
|
|||
webvr_constellation_sender: Option<Sender<Sender<ConstellationMsg>>>,
|
||||
glplayer_threads: Option<GLPlayerThreads>,
|
||||
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
||||
device_pixels_per_px: Option<f32>,
|
||||
) -> (Sender<ConstellationMsg>, SWManagerSenders) {
|
||||
// Global configuration options, parsed from the command line.
|
||||
let opts = opts::get();
|
||||
|
@ -912,6 +918,7 @@ fn create_constellation(
|
|||
glplayer_threads,
|
||||
player_context,
|
||||
event_loop_waker,
|
||||
device_pixels_per_px,
|
||||
};
|
||||
let (constellation_chan, from_swmanager_sender) = Constellation::<
|
||||
script_layout_interface::message::Msg,
|
||||
|
@ -920,7 +927,7 @@ fn create_constellation(
|
|||
>::start(
|
||||
initial_state,
|
||||
opts.initial_window_size,
|
||||
opts.device_pixels_per_px,
|
||||
device_pixels_per_px,
|
||||
opts.random_pipeline_closure_probability,
|
||||
opts.random_pipeline_closure_seed,
|
||||
opts.is_running_problem_test,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue