Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WR (CPU text optimizations, image format renames). #17352

Merged
merged 1 commit into from Jun 16, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Some generated files are not rendered by default. Learn more.

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

@@ -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 {
@@ -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 {
@@ -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)]
@@ -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,
})
@@ -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"),
@@ -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,
};
@@ -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!(),
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.