aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2014-09-18 08:43:03 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2014-09-24 06:59:05 +1000
commitc33f18b7dfc009127f23968d517c332226d91a76 (patch)
treebcb86950f58d0100777f89898f6d65714517b27f
parent178843456fedc20029c9c6d0c20071fea31c73e1 (diff)
downloadservo-c33f18b7dfc009127f23968d517c332226d91a76.tar.gz
servo-c33f18b7dfc009127f23968d517c332226d91a76.zip
Allow resolution to be configured on command line. Default to 1280x1024.
-rw-r--r--components/compositing/compositor.rs3
-rw-r--r--components/compositing/constellation.rs5
-rw-r--r--components/compositing/platform/common/glfw_windowing.rs7
-rw-r--r--components/compositing/platform/common/glut_windowing.rs5
-rw-r--r--components/compositing/windowing.rs2
-rw-r--r--components/util/opts.rs16
-rw-r--r--ports/cef/core.rs2
7 files changed, 31 insertions, 9 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index cec9c2b7419..7d0acea2dac 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -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.
//
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index b1926fdfdea..4cc8915f456 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -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,
diff --git a/components/compositing/platform/common/glfw_windowing.rs b/components/compositing/platform/common/glfw_windowing.rs
index 5a7215d3017..dfe200bf8d8 100644
--- a/components/compositing/platform/common/glfw_windowing.rs
+++ b/components/compositing/platform/common/glfw_windowing.rs
@@ -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();
diff --git a/components/compositing/platform/common/glut_windowing.rs b/components/compositing/platform/common/glut_windowing.rs
index 8e673376dc5..00d5cc889e8 100644
--- a/components/compositing/platform/common/glut_windowing.rs
+++ b/components/compositing/platform/common/glut_windowing.rs
@@ -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.
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 77b921bacba..6a90167628a 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -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.
diff --git a/components/util/opts.rs b/components/util/opts.rs
index 2145e83af81..a37f453a51f 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -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,
})
}
diff --git a/ports/cef/core.rs b/ports/cef/core.rs
index b6415d27f12..6ce9a1e3e9a 100644
--- a/ports/cef/core.rs
+++ b/ports/cef/core.rs
@@ -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);