aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/gfx/opts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/gfx/opts.rs')
-rw-r--r--src/components/gfx/opts.rs47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/components/gfx/opts.rs b/src/components/gfx/opts.rs
index ea8eb47bf51..108f6feb651 100644
--- a/src/components/gfx/opts.rs
+++ b/src/components/gfx/opts.rs
@@ -7,39 +7,57 @@
use azure::azure_hl::{BackendType, CairoBackend, CoreGraphicsBackend};
use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBackend};
+use extra::getopts;
-use std::result;
-
+/// Global flags for Servo, currently set on the command line.
#[deriving(Clone)]
pub struct Opts {
+ /// The initial URLs to load.
urls: ~[~str],
+
+ /// The rendering backend to use (`-r`).
render_backend: BackendType,
+
+ /// How many threads to use for CPU rendering (`-t`).
+ ///
+ /// FIXME(pcwalton): This is not currently used. All rendering is sequential.
n_render_threads: uint,
+
+ /// True to use CPU painting, false to use GPU painting via Skia-GL (`-c`). Note that
+ /// compositing is always done on the GPU.
+ cpu_painting: bool,
+
+ /// The maximum size of each tile in pixels (`-s`).
tile_size: uint,
+
+ /// `None` to disable the profiler or `Some` with an interval in seconds to enable it and cause
+ /// it to produce output on that interval (`-p`).
profiler_period: Option<f64>,
+
+ /// True to exit after the page load (`-x`).
exit_after_load: bool,
+
output_file: Option<~str>,
headless: bool,
}
pub fn from_cmdline_args(args: &[~str]) -> Opts {
- use extra::getopts;
-
let args = args.tail();
let opts = ~[
- getopts::optopt("o"), // output file
- getopts::optopt("r"), // rendering backend
- getopts::optopt("s"), // size of tiles
- getopts::optopt("t"), // threads to render with
- getopts::optflagopt("p"), // profiler flag and output interval
- getopts::optflag("x"), // exit after load flag
- getopts::optflag("z"), // headless mode
+ getopts::optflag("c"), // CPU rendering
+ getopts::optopt("o"), // output file
+ getopts::optopt("r"), // rendering backend
+ getopts::optopt("s"), // size of tiles
+ getopts::optopt("t"), // threads to render with
+ getopts::optflagopt("p"), // profiler flag and output interval
+ getopts::optflag("x"), // exit after load flag
+ getopts::optflag("z"), // headless mode
];
let opt_match = match getopts::getopts(args, opts) {
- result::Ok(m) => m,
- result::Err(f) => fail!(f.to_err_msg()),
+ Ok(m) => m,
+ Err(f) => fail!(f.to_err_msg()),
};
let urls = if opt_match.free.is_empty() {
@@ -82,10 +100,13 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
from_str(period).unwrap()
};
+ let cpu_painting = opt_match.opt_present("c");
+
Opts {
urls: urls,
render_backend: render_backend,
n_render_threads: n_render_threads,
+ cpu_painting: cpu_painting,
tile_size: tile_size,
profiler_period: profiler_period,
exit_after_load: opt_match.opt_present("x"),