mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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:
parent
f7f0eea470
commit
c0531c312f
75 changed files with 2869 additions and 888 deletions
|
@ -5,6 +5,7 @@
|
|||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
use piston_image::{self, DynamicImage, GenericImage, ImageFormat};
|
||||
use stb_image::image as stb_image2;
|
||||
use util::opts;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
pub use msg::constellation_msg::{Image, ImageMetadata, PixelFormat};
|
||||
|
@ -15,14 +16,25 @@ pub use msg::constellation_msg::{Image, ImageMetadata, PixelFormat};
|
|||
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
|
||||
fn byte_swap_and_premultiply(data: &mut [u8]) {
|
||||
let length = data.len();
|
||||
|
||||
// No need to pre-multiply alpha when using direct GPU rendering.
|
||||
let premultiply_alpha = !opts::get().use_webrender;
|
||||
|
||||
for i in (0..length).step_by(4) {
|
||||
let r = data[i + 2];
|
||||
let g = data[i + 1];
|
||||
let b = data[i + 0];
|
||||
let a = data[i + 3];
|
||||
data[i + 0] = ((r as u32) * (a as u32) / 255) as u8;
|
||||
data[i + 1] = ((g as u32) * (a as u32) / 255) as u8;
|
||||
data[i + 2] = ((b as u32) * (a as u32) / 255) as u8;
|
||||
|
||||
if premultiply_alpha {
|
||||
data[i + 0] = ((r as u32) * (a as u32) / 255) as u8;
|
||||
data[i + 1] = ((g as u32) * (a as u32) / 255) as u8;
|
||||
data[i + 2] = ((b as u32) * (a as u32) / 255) as u8;
|
||||
} else {
|
||||
data[i + 0] = r;
|
||||
data[i + 1] = g;
|
||||
data[i + 2] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +70,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
|||
height: image.height as u32,
|
||||
format: PixelFormat::RGBA8,
|
||||
bytes: IpcSharedMemory::from_bytes(&image.data[..]),
|
||||
id: None,
|
||||
})
|
||||
}
|
||||
stb_image2::LoadResult::ImageF32(_image) => {
|
||||
|
@ -83,6 +96,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
|||
height: rgba.height(),
|
||||
format: PixelFormat::RGBA8,
|
||||
bytes: IpcSharedMemory::from_bytes(&*rgba),
|
||||
id: None,
|
||||
})
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue