mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Allow resolution to be configured on command line. Default to 1280x1024.
This commit is contained in:
parent
178843456f
commit
c33f18b7df
7 changed files with 31 additions and 9 deletions
|
@ -142,7 +142,8 @@ impl IOCompositor {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor {
|
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor {
|
||||||
let window: Rc<Window> = WindowMethods::new(app, opts.output_file.is_none());
|
let window: Rc<Window> = WindowMethods::new(app, opts.output_file.is_none(),
|
||||||
|
opts.initial_window_size);
|
||||||
|
|
||||||
// Create an initial layer tree.
|
// Create an initial layer tree.
|
||||||
//
|
//
|
||||||
|
|
|
@ -7,7 +7,6 @@ use devtools_traits::DevtoolsControlChan;
|
||||||
use std::collections::hashmap::{HashMap, HashSet};
|
use std::collections::hashmap::{HashMap, HashSet};
|
||||||
use geom::rect::{Rect, TypedRect};
|
use geom::rect::{Rect, TypedRect};
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
use geom::size::TypedSize2D;
|
|
||||||
use gfx::render_task;
|
use gfx::render_task;
|
||||||
use libc;
|
use libc;
|
||||||
use pipeline::{Pipeline, CompositionPipeline};
|
use pipeline::{Pipeline, CompositionPipeline};
|
||||||
|
@ -268,8 +267,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
pending_sizes: HashMap::new(),
|
pending_sizes: HashMap::new(),
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
window_size: WindowSizeData {
|
window_size: WindowSizeData {
|
||||||
visible_viewport: TypedSize2D(800_f32, 600_f32),
|
visible_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||||
initial_viewport: TypedSize2D(800_f32, 600_f32),
|
initial_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||||
device_pixel_ratio: ScaleFactor(1.0),
|
device_pixel_ratio: ScaleFactor(1.0),
|
||||||
},
|
},
|
||||||
opts: opts_clone,
|
opts: opts_clone,
|
||||||
|
|
|
@ -104,10 +104,13 @@ pub struct Window {
|
||||||
|
|
||||||
impl WindowMethods<Application> for Window {
|
impl WindowMethods<Application> for Window {
|
||||||
/// Creates a new window.
|
/// Creates a new window.
|
||||||
fn new(app: &Application, is_foreground: bool) -> Rc<Window> {
|
fn new(app: &Application, is_foreground: bool, size: TypedSize2D<DevicePixel, uint>) -> Rc<Window> {
|
||||||
// Create the GLFW window.
|
// Create the GLFW window.
|
||||||
|
let window_size = size.to_untyped();
|
||||||
app.glfw.window_hint(glfw::Visible(is_foreground));
|
app.glfw.window_hint(glfw::Visible(is_foreground));
|
||||||
let (glfw_window, events) = app.glfw.create_window(800, 600, "Servo", glfw::Windowed)
|
let (glfw_window, events) = app.glfw.create_window(window_size.width as u32,
|
||||||
|
window_size.height as u32,
|
||||||
|
"Servo", glfw::Windowed)
|
||||||
.expect("Failed to create GLFW window");
|
.expect("Failed to create GLFW window");
|
||||||
glfw_window.make_current();
|
glfw_window.make_current();
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,10 @@ pub struct Window {
|
||||||
|
|
||||||
impl WindowMethods<Application> for Window {
|
impl WindowMethods<Application> for Window {
|
||||||
/// Creates a new window.
|
/// Creates a new window.
|
||||||
fn new(_: &Application, _: bool) -> Rc<Window> {
|
fn new(_: &Application, _: bool, size: TypedSize2D<DevicePixel, uint>) -> Rc<Window> {
|
||||||
// Create the GLUT window.
|
// Create the GLUT window.
|
||||||
glut::init_window_size(800, 600);
|
let window_size = size.to_untyped();
|
||||||
|
glut::init_window_size(window_size.width, window_size.height);
|
||||||
let glut_window = glut::create_window("Servo".to_string());
|
let glut_window = glut::create_window("Servo".to_string());
|
||||||
|
|
||||||
// Create our window object.
|
// Create our window object.
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub trait ApplicationMethods {
|
||||||
|
|
||||||
pub trait WindowMethods<A> {
|
pub trait WindowMethods<A> {
|
||||||
/// Creates a new window.
|
/// Creates a new window.
|
||||||
fn new(app: &A, is_foreground: bool) -> Rc<Self>;
|
fn new(app: &A, is_foreground: bool, size: TypedSize2D<DevicePixel, uint>) -> Rc<Self>;
|
||||||
/// Returns the size of the window in hardware pixels.
|
/// Returns the size of the window in hardware pixels.
|
||||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint>;
|
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint>;
|
||||||
/// Returns the size of the window in density-independent "px" units.
|
/// Returns the size of the window in density-independent "px" units.
|
||||||
|
|
|
@ -10,6 +10,7 @@ use geometry::ScreenPx;
|
||||||
use azure::azure_hl::{BackendType, CairoBackend, CoreGraphicsBackend};
|
use azure::azure_hl::{BackendType, CairoBackend, CoreGraphicsBackend};
|
||||||
use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
|
use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
use geom::size::TypedSize2D;
|
||||||
use layers::geometry::DevicePixel;
|
use layers::geometry::DevicePixel;
|
||||||
use getopts;
|
use getopts;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
@ -86,6 +87,9 @@ pub struct Opts {
|
||||||
|
|
||||||
/// True if we should start a server to listen to remote Firefox devtools connections.
|
/// True if we should start a server to listen to remote Firefox devtools connections.
|
||||||
pub devtools_server: bool,
|
pub devtools_server: bool,
|
||||||
|
|
||||||
|
/// The initial requested size of the window.
|
||||||
|
pub initial_window_size: TypedSize2D<DevicePixel, uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
|
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
|
||||||
|
@ -121,6 +125,7 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
getopts::optflag("", "disable-text-aa", "Disable antialiasing for text rendering."),
|
getopts::optflag("", "disable-text-aa", "Disable antialiasing for text rendering."),
|
||||||
getopts::optflag("", "trace-layout", "Write layout trace to external file for debugging."),
|
getopts::optflag("", "trace-layout", "Write layout trace to external file for debugging."),
|
||||||
getopts::optflag("", "devtools", "Start remote devtools server"),
|
getopts::optflag("", "devtools", "Start remote devtools server"),
|
||||||
|
getopts::optopt("", "resolution", "Set window resolution.", "1280x1024"),
|
||||||
getopts::optflag("h", "help", "Print this message")
|
getopts::optflag("h", "help", "Print this message")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -202,6 +207,16 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
bubble_inline_sizes_separately = true;
|
bubble_inline_sizes_separately = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let initial_window_size = match opt_match.opt_str("resolution") {
|
||||||
|
Some(res_string) => {
|
||||||
|
let res: Vec<uint> = res_string.as_slice().split('x').map(|r| from_str(r).unwrap()).collect();
|
||||||
|
TypedSize2D(res[0], res[1])
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
TypedSize2D(1280, 1024)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Some(Opts {
|
Some(Opts {
|
||||||
urls: urls,
|
urls: urls,
|
||||||
render_backend: render_backend,
|
render_backend: render_backend,
|
||||||
|
@ -222,6 +237,7 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
enable_text_antialiasing: !opt_match.opt_present("disable-text-aa"),
|
enable_text_antialiasing: !opt_match.opt_present("disable-text-aa"),
|
||||||
trace_layout: trace_layout,
|
trace_layout: trace_layout,
|
||||||
devtools_server: opt_match.opt_present("devtools"),
|
devtools_server: opt_match.opt_present("devtools"),
|
||||||
|
initial_window_size: initial_window_size,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use azure;
|
use azure;
|
||||||
use command_line::command_line_init;
|
use command_line::command_line_init;
|
||||||
use eutil::fptr_is_null;
|
use eutil::fptr_is_null;
|
||||||
|
use geom::size::TypedSize2D;
|
||||||
use libc::{c_int, c_void};
|
use libc::{c_int, c_void};
|
||||||
use native;
|
use native;
|
||||||
use servo;
|
use servo;
|
||||||
|
@ -68,6 +69,7 @@ pub extern "C" fn cef_run_message_loop() {
|
||||||
enable_text_antialiasing: true,
|
enable_text_antialiasing: true,
|
||||||
trace_layout: false,
|
trace_layout: false,
|
||||||
devtools_server: false,
|
devtools_server: false,
|
||||||
|
initial_window_size: TypedSize2D(1280, 1024),
|
||||||
};
|
};
|
||||||
native::start(0, 0 as *const *const u8, proc() {
|
native::start(0, 0 as *const *const u8, proc() {
|
||||||
servo::run(opts);
|
servo::run(opts);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue