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!
This commit is contained in:
Glenn Watson 2016-02-18 07:57:31 +10:00
parent f7f0eea470
commit c0531c312f
75 changed files with 2869 additions and 888 deletions

View file

@ -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)",
@ -1559,6 +1570,22 @@ name = "rustc-serialize"
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"
@ -1659,6 +1686,11 @@ dependencies = [
"string_cache 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "0.6.6"
@ -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)",
@ -2174,6 +2206,42 @@ dependencies = [
"webdriver 0.4.0 (git+https://github.com/jgraham/webdriver-rust.git)",
]
[[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"

View file

@ -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"]

View file

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