Skip to content
Permalink
Browse files

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!
  • Loading branch information
gw3583 committed Feb 18, 2016
1 parent f7f0eea commit c0531c312fdb0783e4d121b4c2d7f15d4f5cdc1f
Showing with 2,871 additions and 890 deletions.
  1. +3 −0 components/canvas/Cargo.toml
  2. +32 −7 components/canvas/canvas_paint_thread.rs
  3. +1 −1 components/canvas/lib.rs
  4. +84 −481 components/canvas/webgl_paint_thread.rs
  5. +3 −0 components/canvas_traits/Cargo.toml
  6. +17 −177 components/canvas_traits/lib.rs
  7. +6 −0 components/compositing/Cargo.toml
  8. +269 −52 components/compositing/compositor.rs
  9. +15 −0 components/compositing/compositor_thread.rs
  10. +14 −3 components/compositing/constellation.rs
  11. +2 −0 components/compositing/lib.rs
  12. +7 −1 components/compositing/pipeline.rs
  13. +3 −0 components/gfx/Cargo.toml
  14. +35 −2 components/gfx/display_list/mod.rs
  15. +2 −0 components/gfx/font.rs
  16. +45 −10 components/gfx/font_cache_thread.rs
  17. +19 −12 components/gfx/font_context.rs
  18. +1 −0 components/gfx/lib.rs
  19. +19 −0 components/gfx/platform/freetype/font_template.rs
  20. +36 −0 components/gfx/platform/macos/font_template.rs
  21. +3 −0 components/gfx/text/text_run.rs
  22. +3 −0 components/layout/Cargo.toml
  23. +80 −46 components/layout/display_list_builder.rs
  24. +7 −2 components/layout/inline.rs
  25. +48 −8 components/layout/layout_thread.rs
  26. +2 −0 components/layout/lib.rs
  27. +481 −0 components/layout/webrender_helpers.rs
  28. +3 −0 components/layout_traits/Cargo.toml
  29. +3 −1 components/layout_traits/lib.rs
  30. +3 −0 components/msg/Cargo.toml
  31. +29 −1 components/msg/constellation_msg.rs
  32. +1 −0 components/msg/lib.rs
  33. +3 −0 components/net/Cargo.toml
  34. +55 −8 components/net/image_cache_thread.rs
  35. +1 −0 components/net/lib.rs
  36. +17 −3 components/net_traits/image/base.rs
  37. +10 −3 components/script/dom/htmlcanvaselement.rs
  38. +2 −0 components/script/dom/webglrenderingcontext.rs
  39. +78 −10 components/servo/Cargo.lock
  40. +6 −0 components/servo/Cargo.toml
  41. +44 −5 components/servo/lib.rs
  42. +28 −0 components/util/opts.rs
  43. +79 −11 ports/cef/Cargo.lock
  44. +66 −34 ports/glutin/window.rs
  45. +78 −10 ports/gonk/Cargo.lock
  46. +193 −0 resources/shaders/blend.fs.glsl
  47. +10 −0 resources/shaders/blend.vs.glsl
  48. +9 −0 resources/shaders/blit.fs.glsl
  49. +12 −0 resources/shaders/blit.vs.glsl
  50. +44 −0 resources/shaders/blur.fs.glsl
  51. +14 −0 resources/shaders/blur.vs.glsl
  52. +41 −0 resources/shaders/border.fs.glsl
  53. +12 −0 resources/shaders/border.vs.glsl
  54. +146 −0 resources/shaders/box_shadow.fs.glsl
  55. +14 −0 resources/shaders/box_shadow.vs.glsl
  56. +8 −0 resources/shaders/clear.fs.glsl
  57. +9 −0 resources/shaders/clear.vs.glsl
  58. +8 −0 resources/shaders/debug_color.fs.glsl
  59. +11 −0 resources/shaders/debug_color.vs.glsl
  60. +13 −0 resources/shaders/debug_font.fs.glsl
  61. +12 −0 resources/shaders/debug_font.vs.glsl
  62. +42 −0 resources/shaders/es2_common.fs.glsl
  63. +70 −0 resources/shaders/es2_common.vs.glsl
  64. +148 −0 resources/shaders/filter.fs.glsl
  65. +12 −0 resources/shaders/filter.vs.glsl
  66. +41 −0 resources/shaders/gl3_common.fs.glsl
  67. +68 −0 resources/shaders/gl3_common.vs.glsl
  68. +8 −0 resources/shaders/mask.fs.glsl
  69. +9 −0 resources/shaders/mask.vs.glsl
  70. +38 −0 resources/shaders/quad.fs.glsl
  71. +112 −0 resources/shaders/quad.vs.glsl
  72. +11 −0 resources/shaders/tile.fs.glsl
  73. +11 −0 resources/shaders/tile.vs.glsl
  74. +1 −1 tests/unit/gfx/font_cache_thread.rs
  75. +1 −1 tests/wpt/harness/wptrunner/browsers/servo.py
@@ -33,6 +33,9 @@ git = "https://github.com/ecoal95/rust-offscreen-rendering-context"
[dependencies.ipc-channel]
git = "https://github.com/servo/ipc-channel"

[dependencies.webrender_traits]
git = "https://github.com/glennw/webrender_traits"

[dependencies]
log = "0.3"
num = "0.1.24"
@@ -24,6 +24,7 @@ use std::sync::mpsc::{Sender, channel};
use util::opts;
use util::thread::spawn_named;
use util::vec::byte_swap;
use webrender_traits;

impl<'a> CanvasPaintThread<'a> {
/// It reads image data from the canvas
@@ -63,6 +64,8 @@ pub struct CanvasPaintThread<'a> {
path_builder: PathBuilder,
state: CanvasPaintState<'a>,
saved_states: Vec<CanvasPaintState<'a>>,
webrender_api: Option<webrender_traits::RenderApi>,
webrender_image_key: Option<webrender_traits::ImageKey>,
}

#[derive(Clone)]
@@ -102,27 +105,34 @@ impl<'a> CanvasPaintState<'a> {
}

impl<'a> CanvasPaintThread<'a> {
fn new(size: Size2D<i32>) -> CanvasPaintThread<'a> {
fn new(size: Size2D<i32>,
webrender_api_sender: Option<webrender_traits::RenderApiSender>) -> CanvasPaintThread<'a> {
let draw_target = CanvasPaintThread::create(size);
let path_builder = draw_target.create_path_builder();
let webrender_api = webrender_api_sender.map(|wr| wr.create_api());
let webrender_image_key = webrender_api.as_ref().map(|wr| wr.alloc_image());
CanvasPaintThread {
drawtarget: draw_target,
path_builder: path_builder,
state: CanvasPaintState::new(),
saved_states: Vec::new(),
webrender_api: webrender_api,
webrender_image_key: webrender_image_key,
}
}

/// Creates a new `CanvasPaintThread` and returns the out-of-process sender and the in-process
/// sender for it.
pub fn start(size: Size2D<i32>) -> (IpcSender<CanvasMsg>, Sender<CanvasMsg>) {
pub fn start(size: Size2D<i32>,
webrender_api_sender: Option<webrender_traits::RenderApiSender>)
-> (IpcSender<CanvasMsg>, Sender<CanvasMsg>) {
// TODO(pcwalton): Ask the pipeline to create this for us instead of spawning it directly.
// This will be needed for multiprocess Servo.
let (out_of_process_chan, out_of_process_port) = ipc::channel::<CanvasMsg>().unwrap();
let (in_process_chan, in_process_port) = channel();
ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone());
spawn_named("CanvasThread".to_owned(), move || {
let mut painter = CanvasPaintThread::new(size);
let mut painter = CanvasPaintThread::new(size, webrender_api_sender);
loop {
let msg = in_process_port.recv();
match msg.unwrap() {
@@ -190,8 +200,8 @@ impl<'a> CanvasPaintThread<'a> {
},
CanvasMsg::FromLayout(message) => {
match message {
FromLayoutMsg::SendPixelContents(chan) => {
painter.send_pixel_contents(chan)
FromLayoutMsg::SendData(chan) => {
painter.send_data(chan)
}
}
}
@@ -519,9 +529,24 @@ impl<'a> CanvasPaintThread<'a> {
self.drawtarget = CanvasPaintThread::create(size);
}

fn send_pixel_contents(&mut self, chan: IpcSender<IpcSharedMemory>) {
fn send_data(&mut self, chan: IpcSender<CanvasData>) {
self.drawtarget.snapshot().get_data_surface().with_data(|element| {
chan.send(IpcSharedMemory::from_bytes(element)).unwrap();
if let Some(ref webrender_api) = self.webrender_api {
let size = self.drawtarget.get_size();
let mut bytes = Vec::new();
bytes.extend_from_slice(element);
webrender_api.update_image(self.webrender_image_key.unwrap(),
size.width as u32,
size.height as u32,
webrender_traits::ImageFormat::RGBA8,
bytes);
}

let pixel_data = CanvasPixelData {
image_data: IpcSharedMemory::from_bytes(element),
image_key: self.webrender_image_key,
};
chan.send(CanvasData::Pixels(pixel_data)).unwrap();
})
}

@@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![feature(nonzero)]
#![feature(plugin)]
#![plugin(plugins)]

@@ -19,6 +18,7 @@ extern crate log;
extern crate num;
extern crate offscreen_gl_context;
extern crate util;
extern crate webrender_traits;

pub mod canvas_paint_thread;
mod premultiplytable;

0 comments on commit c0531c3

Please sign in to comment.
You can’t perform that action at this time.