diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-02-19 00:54:06 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-02-19 00:54:06 +0530 |
commit | ab07b06823ea9748a6091aee2281495f86f00bce (patch) | |
tree | 2dd06ac4834d5bc4bcba6e4ada3aab12bb2c12d9 /components/servo | |
parent | fe70efe07f6d72665f10c752884e5705d5bdc600 (diff) | |
parent | c0531c312fdb0783e4d121b4c2d7f15d4f5cdc1f (diff) | |
download | servo-ab07b06823ea9748a6091aee2281495f86f00bce.tar.gz servo-ab07b06823ea9748a6091aee2281495f86f00bce.zip |
Auto merge of #9589 - glennw:webrender, r=pcwalton
Add WebRender integration to Servo.
WebRender is an experimental GPU accelerated rendering backend for Servo.
The WebRender backend can be specified by running Servo with the -w option (otherwise the default rendering backend will be used).
WebRender has many bugs, and missing features - but it is usable to browse most websites - please report any WebRender specific rendering bugs you encounter!
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9589)
<!-- Reviewable:end -->
Diffstat (limited to 'components/servo')
-rw-r--r-- | components/servo/Cargo.lock | 88 | ||||
-rw-r--r-- | components/servo/Cargo.toml | 6 | ||||
-rw-r--r-- | components/servo/lib.rs | 49 |
3 files changed, 128 insertions, 15 deletions
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 39b651e0912..9c4a7af6185 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gfx_tests 0.0.1", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_app 0.0.1", "image 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", @@ -42,6 +42,8 @@ dependencies = [ "util 0.0.1", "util_tests 0.0.1", "webdriver_server 0.0.1", + "webrender 0.1.0 (git+https://github.com/glennw/webrender)", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -152,7 +154,7 @@ dependencies = [ "canvas_traits 0.0.1", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", "layers 0.2.2 (git+https://github.com/servo/rust-layers)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -160,6 +162,7 @@ dependencies = [ "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", "plugins 0.0.1", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -179,6 +182,7 @@ dependencies = [ "serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -200,7 +204,7 @@ name = "cgl" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -273,7 +277,7 @@ dependencies = [ "gaol 0.0.1 (git+https://github.com/servo/gaol)", "gfx 0.0.1", "gfx_traits 0.0.1", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", "layers 0.2.2 (git+https://github.com/servo/rust-layers)", @@ -292,6 +296,8 @@ dependencies = [ "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender 0.1.0 (git+https://github.com/glennw/webrender)", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -680,6 +686,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -728,7 +735,7 @@ dependencies = [ [[package]] name = "gleam" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -748,7 +755,7 @@ dependencies = [ "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "compositing 0.0.1", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "layers 0.2.2 (git+https://github.com/servo/rust-layers)", "msg 0.0.1", "net_traits 0.0.1", @@ -904,7 +911,7 @@ dependencies = [ "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "leaky-cow 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -965,7 +972,7 @@ dependencies = [ "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "glx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1018,6 +1025,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -1034,6 +1042,7 @@ dependencies = [ "serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -1194,6 +1203,7 @@ dependencies = [ "serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", ] [[package]] @@ -1218,6 +1228,7 @@ dependencies = [ "url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", "websocket 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1334,7 +1345,7 @@ dependencies = [ "core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1560,6 +1571,22 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "rustc_version" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scoped_threadpool" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "script" version = "0.0.1" dependencies = [ @@ -1660,6 +1687,11 @@ dependencies = [ ] [[package]] +name = "semver" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "serde" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1766,7 +1798,7 @@ dependencies = [ "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "expat-sys 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gleam 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "glx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "io-surface 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2175,6 +2207,42 @@ dependencies = [ ] [[package]] +name = "webrender" +version = "0.1.0" +source = "git+https://github.com/glennw/webrender#90cd6afdd64cdb48f606dbe0ce5d1ac352329004" +dependencies = [ + "app_units 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-text 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", + "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", + "scoped_threadpool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "webrender_traits 0.1.0 (git+https://github.com/glennw/webrender_traits)", +] + +[[package]] +name = "webrender_traits" +version = "0.1.0" +source = "git+https://github.com/glennw/webrender_traits#8ccc1608590d219d1df54e49f2f1e887995b4d60" +dependencies = [ + "app_units 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gleam 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "ipc-channel 0.2.0 (git+https://github.com/servo/ipc-channel)", + "offscreen_gl_context 0.1.0 (git+https://github.com/ecoal95/rust-offscreen-rendering-context)", + "serde 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_macros 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "websocket" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index c4d2c6d9f36..9bea00cd956 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -52,6 +52,12 @@ name = "reftest" path = "../../tests/reftest.rs" harness = false +[dependencies.webrender_traits] +git = "https://github.com/glennw/webrender_traits" + +[dependencies.webrender] +git = "https://github.com/glennw/webrender" + [features] default = ["glutin_app", "window", "webdriver"] window = ["glutin_app/window"] diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 6544b69e002..67b6875da48 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -48,6 +48,9 @@ mod export { #[cfg(feature = "webdriver")] extern crate webdriver_server; +extern crate webrender; +extern crate webrender_traits; + #[cfg(feature = "webdriver")] fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) { webdriver_server::start_server(port, constellation); @@ -82,6 +85,7 @@ use std::borrow::Borrow; use std::rc::Rc; use std::sync::mpsc::Sender; use util::opts; +use util::resource_files::resources_dir_path; pub use _util as util; pub use export::canvas; @@ -147,6 +151,35 @@ impl Browser { devtools::start_server(port) }); + let (webrender, webrender_api_sender) = if opts::get().use_webrender { + let mut resource_path = resources_dir_path(); + resource_path.push("shaders"); + + // TODO(gw): Duplicates device_pixels_per_screen_px from compositor. Tidy up! + let hidpi_factor = window.as_ref() + .map(|window| window.hidpi_factor().get()) + .unwrap_or(1.0); + let device_pixel_ratio = match opts.device_pixels_per_px { + Some(device_pixels_per_px) => device_pixels_per_px, + None => match opts.output_file { + Some(_) => 1.0, + None => hidpi_factor, + } + }; + + let (webrender, webrender_sender) = + webrender::Renderer::new(webrender::RendererOptions { + device_pixel_ratio: device_pixel_ratio, + resource_path: resource_path, + enable_aa: opts.enable_text_antialiasing, + enable_msaa: opts.use_msaa, + enable_profiler: opts.webrender_stats, + }); + (Some(webrender), Some(webrender_sender)) + } else { + (None, None) + }; + // Create the constellation, which maintains the engine // pipelines, including the script and layout threads, as well // as the navigation context. @@ -155,7 +188,8 @@ impl Browser { time_profiler_chan.clone(), mem_profiler_chan.clone(), devtools_chan, - supports_clipboard); + supports_clipboard, + webrender_api_sender.clone()); if cfg!(feature = "webdriver") { if let Some(port) = opts.webdriver_port { @@ -171,6 +205,8 @@ impl Browser { constellation_chan: constellation_chan, time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, + webrender: webrender, + webrender_api_sender: webrender_api_sender, }); Browser { @@ -200,11 +236,13 @@ fn create_constellation(opts: opts::Opts, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>, - supports_clipboard: bool) -> Sender<ConstellationMsg> { + supports_clipboard: bool, + webrender_api_sender: Option<webrender_traits::RenderApiSender>) -> Sender<ConstellationMsg> { let resource_thread = new_resource_thread(opts.user_agent.clone(), devtools_chan.clone()); - - let image_cache_thread = new_image_cache_thread(resource_thread.clone()); - let font_cache_thread = FontCacheThread::new(resource_thread.clone()); + let image_cache_thread = new_image_cache_thread(resource_thread.clone(), + webrender_api_sender.as_ref().map(|wr| wr.create_api())); + let font_cache_thread = FontCacheThread::new(resource_thread.clone(), + webrender_api_sender.as_ref().map(|wr| wr.create_api())); let storage_thread: StorageThread = StorageThreadFactory::new(); let initial_state = InitialConstellationState { @@ -217,6 +255,7 @@ fn create_constellation(opts: opts::Opts, time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, supports_clipboard: supports_clipboard, + webrender_api_sender: webrender_api_sender, }; let constellation_chan = Constellation::<layout::layout_thread::LayoutThread, |