Skip to content

Commit

Permalink
Update WR (CPU text optimizations, image format renames).
Browse files Browse the repository at this point in the history
  • Loading branch information
gw3583 committed Jun 16, 2017
1 parent e3a5253 commit e7b1e04
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/canvas/canvas_paint_thread.rs
Expand Up @@ -564,7 +564,7 @@ impl<'a> CanvasPaintThread<'a> {
width: size.width as u32,
height: size.height as u32,
stride: None,
format: webrender_traits::ImageFormat::RGBA8,
format: webrender_traits::ImageFormat::BGRA8,
offset: 0,
is_opaque: false,
};
Expand Down
2 changes: 1 addition & 1 deletion components/canvas/webgl_paint_thread.rs
Expand Up @@ -254,7 +254,7 @@ impl WebGLPaintThread {
width: width as u32,
height: height as u32,
stride: None,
format: webrender_traits::ImageFormat::RGBA8,
format: webrender_traits::ImageFormat::BGRA8,
offset: 0,
is_opaque: false,
};
Expand Down
2 changes: 1 addition & 1 deletion components/layout/display_list_builder.rs
Expand Up @@ -1951,7 +1951,7 @@ impl FragmentDisplayListBuilding for Fragment {
webrender_image: WebRenderImageInfo {
width: computed_width as u32,
height: computed_height as u32,
format: PixelFormat::RGBA8,
format: PixelFormat::BGRA8,
key: Some(canvas_data.image_key),
},
image_data: None,
Expand Down
6 changes: 3 additions & 3 deletions components/net/image_cache.rs
Expand Up @@ -40,7 +40,7 @@ fn convert_format(format: PixelFormat) -> webrender_traits::ImageFormat {
panic!("Not support by webrender yet");
}
PixelFormat::RGB8 => webrender_traits::ImageFormat::RGB8,
PixelFormat::RGBA8 => webrender_traits::ImageFormat::RGBA8,
PixelFormat::BGRA8 => webrender_traits::ImageFormat::BGRA8,
}
}

Expand All @@ -66,7 +66,7 @@ fn set_webrender_image_key(webrender_api: &webrender_traits::RenderApi, image: &
let format = convert_format(image.format);
let mut bytes = Vec::new();
bytes.extend_from_slice(&*image.bytes);
if format == webrender_traits::ImageFormat::RGBA8 {
if format == webrender_traits::ImageFormat::BGRA8 {
premultiply(bytes.as_mut_slice());
}
let descriptor = webrender_traits::ImageDescriptor {
Expand All @@ -87,7 +87,7 @@ fn set_webrender_image_key(webrender_api: &webrender_traits::RenderApi, image: &
// Consider using SIMD to speed this up if it shows in profiles.
fn is_image_opaque(format: webrender_traits::ImageFormat, bytes: &[u8]) -> bool {
match format {
webrender_traits::ImageFormat::RGBA8 => {
webrender_traits::ImageFormat::BGRA8 => {
let mut is_opaque = true;
for i in 0..(bytes.len() / 4) {
if bytes[i * 4 + 3] != 255 {
Expand Down
4 changes: 2 additions & 2 deletions components/net_traits/image/base.rs
Expand Up @@ -16,7 +16,7 @@ pub enum PixelFormat {
/// RGB, 8 bits per channel
RGB8,
/// RGB + alpha, 8 bits per channel
RGBA8,
BGRA8,
}

#[derive(Clone, Deserialize, Serialize, HeapSizeOf)]
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
Some(Image {
width: rgba.width(),
height: rgba.height(),
format: PixelFormat::RGBA8,
format: PixelFormat::BGRA8,
bytes: IpcSharedMemory::from_bytes(&*rgba),
id: None,
})
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/canvasrenderingcontext2d.rs
Expand Up @@ -431,7 +431,7 @@ impl CanvasRenderingContext2D {

let image_size = Size2D::new(img.width as i32, img.height as i32);
let image_data = match img.format {
PixelFormat::RGBA8 => img.bytes.to_vec(),
PixelFormat::BGRA8 => img.bytes.to_vec(),
PixelFormat::K8 => panic!("K8 color type not supported"),
PixelFormat::RGB8 => panic!("RGB8 color type not supported"),
PixelFormat::KA8 => panic!("KA8 color type not supported"),
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/paintworkletglobalscope.rs
Expand Up @@ -75,7 +75,7 @@ impl PaintWorkletGlobalScope {
let image = Image {
width: width,
height: height,
format: PixelFormat::RGBA8,
format: PixelFormat::BGRA8,
bytes: IpcSharedMemory::from_bytes(&*self.buffer.borrow()),
id: None,
};
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/webglrenderingcontext.rs
Expand Up @@ -690,9 +690,9 @@ impl WebGLRenderingContext {

let size = Size2D::new(img.width as i32, img.height as i32);

// For now Servo's images are all stored as RGBA8 internally.
// For now Servo's images are all stored as BGRA8 internally.
let mut data = match img.format {
PixelFormat::RGBA8 => img.bytes.to_vec(),
PixelFormat::BGRA8 => img.bytes.to_vec(),
_ => unimplemented!(),
};

Expand Down

0 comments on commit e7b1e04

Please sign in to comment.