Allow resolution to be configured on command line. Default to 1280x1024.

This commit is contained in:
Glenn Watson 2014-09-18 08:43:03 +10:00
parent 178843456f
commit c33f18b7df
7 changed files with 31 additions and 9 deletions

View file

@ -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.
//

View file

@ -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,

View file

@ -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();

View file

@ -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.

View file

@ -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.