mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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,
|
||||
time_profiler_chan: TimeProfilerChan,
|
||||
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.
|
||||
//
|
||||
|
|
|
@ -7,7 +7,6 @@ use devtools_traits::DevtoolsControlChan;
|
|||
use std::collections::hashmap::{HashMap, HashSet};
|
||||
use geom::rect::{Rect, TypedRect};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use gfx::render_task;
|
||||
use libc;
|
||||
use pipeline::{Pipeline, CompositionPipeline};
|
||||
|
@ -268,8 +267,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
|||
pending_sizes: HashMap::new(),
|
||||
time_profiler_chan: time_profiler_chan,
|
||||
window_size: WindowSizeData {
|
||||
visible_viewport: TypedSize2D(800_f32, 600_f32),
|
||||
initial_viewport: TypedSize2D(800_f32, 600_f32),
|
||||
visible_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
initial_viewport: opts_clone.initial_window_size.as_f32() * ScaleFactor(1.0),
|
||||
device_pixel_ratio: ScaleFactor(1.0),
|
||||
},
|
||||
opts: opts_clone,
|
||||
|
|
|
@ -104,10 +104,13 @@ pub struct Window {
|
|||
|
||||
impl WindowMethods<Application> for 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.
|
||||
let window_size = size.to_untyped();
|
||||
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");
|
||||
glfw_window.make_current();
|
||||
|
||||
|
|
|
@ -63,9 +63,10 @@ pub struct Window {
|
|||
|
||||
impl WindowMethods<Application> for 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.
|
||||
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());
|
||||
|
||||
// Create our window object.
|
||||
|
|
|
@ -61,7 +61,7 @@ pub trait ApplicationMethods {
|
|||
|
||||
pub trait WindowMethods<A> {
|
||||
/// 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.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint>;
|
||||
/// 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::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use layers::geometry::DevicePixel;
|
||||
use getopts;
|
||||
use std::cmp;
|
||||
|
@ -86,6 +87,9 @@ pub struct Opts {
|
|||
|
||||
/// True if we should start a server to listen to remote Firefox devtools connections.
|
||||
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]) {
|
||||
|
@ -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("", "trace-layout", "Write layout trace to external file for debugging."),
|
||||
getopts::optflag("", "devtools", "Start remote devtools server"),
|
||||
getopts::optopt("", "resolution", "Set window resolution.", "1280x1024"),
|
||||
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;
|
||||
}
|
||||
|
||||
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 {
|
||||
urls: urls,
|
||||
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"),
|
||||
trace_layout: trace_layout,
|
||||
devtools_server: opt_match.opt_present("devtools"),
|
||||
initial_window_size: initial_window_size,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
use azure;
|
||||
use command_line::command_line_init;
|
||||
use eutil::fptr_is_null;
|
||||
use geom::size::TypedSize2D;
|
||||
use libc::{c_int, c_void};
|
||||
use native;
|
||||
use servo;
|
||||
|
@ -68,6 +69,7 @@ pub extern "C" fn cef_run_message_loop() {
|
|||
enable_text_antialiasing: true,
|
||||
trace_layout: false,
|
||||
devtools_server: false,
|
||||
initial_window_size: TypedSize2D(1280, 1024),
|
||||
};
|
||||
native::start(0, 0 as *const *const u8, proc() {
|
||||
servo::run(opts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue