aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2018-11-15 10:04:52 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2018-11-16 12:37:34 +0100
commita5779ad372b2b3c1c236c94680d01c60a99f19a4 (patch)
treee2732aa371e93e0fa0b71a3b2a31e87d825d21c7
parentadf363a2085f8af08a38046fae148131d0cbdd06 (diff)
downloadservo-a5779ad372b2b3c1c236c94680d01c60a99f19a4.tar.gz
servo-a5779ad372b2b3c1c236c94680d01c60a99f19a4.zip
Prefix some pixels functions with rgba8_
-rw-r--r--components/canvas/canvas_data.rs6
-rw-r--r--components/canvas/webgl_thread.rs2
-rw-r--r--components/canvas_traits/webgl.rs2
-rw-r--r--components/net/image_cache.rs2
-rw-r--r--components/net_traits/image/base.rs2
-rw-r--r--components/pixels/lib.rs8
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs2
-rw-r--r--components/script/dom/imagedata.rs2
-rw-r--r--components/script/dom/webglrenderingcontext.rs4
9 files changed, 15 insertions, 15 deletions
diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs
index d07ee2cd9cf..1c2e5d09118 100644
--- a/components/canvas/canvas_data.rs
+++ b/components/canvas/canvas_data.rs
@@ -69,7 +69,7 @@ impl<'a> CanvasData<'a> {
let source_rect = source_rect.ceil();
// It discards the extra pixels (if any) that won't be painted
let image_data = if Rect::from_size(image_size).contains_rect(&source_rect) {
- pixels::get_rect(&image_data, image_size.to_u32(), source_rect.to_u32()).into()
+ pixels::rgba8_get_rect(&image_data, image_size.to_u32(), source_rect.to_u32()).into()
} else {
image_data.into()
};
@@ -510,7 +510,7 @@ impl<'a> CanvasData<'a> {
pub fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u32>) {
assert_eq!(imagedata.len() % 4, 0);
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
- pixels::byte_swap_and_premultiply_inplace(&mut imagedata);
+ pixels::rgba8_byte_swap_and_premultiply_inplace(&mut imagedata);
let source_surface = self
.drawtarget
.create_source_surface_from_data(
@@ -602,7 +602,7 @@ impl<'a> CanvasData<'a> {
return vec![];
}
let data_surface = self.drawtarget.snapshot().get_data_surface();
- pixels::get_rect(
+ pixels::rgba8_get_rect(
unsafe { data_surface.data() },
canvas_size.to_u32(),
read_rect.to_u32(),
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index dec2ad33263..67ac2f49789 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -635,7 +635,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
let src_slice = &orig_pixels[src_start..src_start + stride];
(&mut pixels[dst_start..dst_start + stride]).clone_from_slice(&src_slice[..stride]);
}
- pixels::byte_swap_colors_inplace(&mut pixels);
+ pixels::rgba8_byte_swap_colors_inplace(&mut pixels);
pixels
}
diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs
index a493a4a58cb..29236615b79 100644
--- a/components/canvas_traits/webgl.rs
+++ b/components/canvas_traits/webgl.rs
@@ -950,7 +950,7 @@ pub fn rgba8_image_to_tex_image_data(
pub fn premultiply_inplace(format: TexFormat, data_type: TexDataType, pixels: &mut [u8]) {
match (format, data_type) {
(TexFormat::RGBA, TexDataType::UnsignedByte) => {
- pixels::premultiply_inplace(pixels);
+ pixels::rgba8_premultiply_inplace(pixels);
},
(TexFormat::LuminanceAlpha, TexDataType::UnsignedByte) => {
for la in pixels.chunks_mut(2) {
diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs
index cf95d3fc1fd..5686b154831 100644
--- a/components/net/image_cache.rs
+++ b/components/net/image_cache.rs
@@ -56,7 +56,7 @@ fn set_webrender_image_key(webrender_api: &webrender_api::RenderApi, image: &mut
let is_opaque = match image.format {
PixelFormat::BGRA8 => {
bytes.extend_from_slice(&*image.bytes);
- pixels::premultiply_inplace(bytes.as_mut_slice())
+ pixels::rgba8_premultiply_inplace(bytes.as_mut_slice())
},
PixelFormat::RGB8 => {
for bgr in image.bytes.chunks(3) {
diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs
index 6e67e5b7cd1..05175084162 100644
--- a/components/net_traits/image/base.rs
+++ b/components/net_traits/image/base.rs
@@ -65,7 +65,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
DynamicImage::ImageRgba8(rgba) => rgba,
image => image.to_rgba(),
};
- pixels::byte_swap_colors_inplace(&mut *rgba);
+ pixels::rgba8_byte_swap_colors_inplace(&mut *rgba);
Some(Image {
width: rgba.width(),
height: rgba.height(),
diff --git a/components/pixels/lib.rs b/components/pixels/lib.rs
index 16c93b7b6af..de9a3cb3aa8 100644
--- a/components/pixels/lib.rs
+++ b/components/pixels/lib.rs
@@ -5,7 +5,7 @@
use euclid::{Point2D, Rect, Size2D};
use std::borrow::Cow;
-pub fn get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
+pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
assert!(!rect.is_empty());
assert!(Rect::from_size(size).contains_rect(&rect));
assert_eq!(pixels.len() % 4, 0);
@@ -29,7 +29,7 @@ pub fn get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]>
}
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
-pub fn byte_swap_colors_inplace(pixels: &mut [u8]) {
+pub fn rgba8_byte_swap_colors_inplace(pixels: &mut [u8]) {
assert!(pixels.len() % 4 == 0);
for rgba in pixels.chunks_mut(4) {
let b = rgba[0];
@@ -38,7 +38,7 @@ pub fn byte_swap_colors_inplace(pixels: &mut [u8]) {
}
}
-pub fn byte_swap_and_premultiply_inplace(pixels: &mut [u8]) {
+pub fn rgba8_byte_swap_and_premultiply_inplace(pixels: &mut [u8]) {
assert!(pixels.len() % 4 == 0);
for rgba in pixels.chunks_mut(4) {
let b = rgba[0];
@@ -49,7 +49,7 @@ pub fn byte_swap_and_premultiply_inplace(pixels: &mut [u8]) {
}
/// Returns true if the pixels were found to be completely opaque.
-pub fn premultiply_inplace(pixels: &mut [u8]) -> bool {
+pub fn rgba8_premultiply_inplace(pixels: &mut [u8]) -> bool {
assert!(pixels.len() % 4 == 0);
let mut is_opaque = true;
for rgba in pixels.chunks_mut(4) {
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index 3a031095dc8..18d6c978cae 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -403,7 +403,7 @@ impl CanvasRenderingContext2D {
) -> ErrorResult {
debug!("Fetching image {}.", url);
let (mut image_data, image_size) = self.fetch_image_data(url).ok_or(Error::InvalidState)?;
- pixels::premultiply_inplace(&mut image_data);
+ pixels::rgba8_premultiply_inplace(&mut image_data);
let image_size = image_size.to_f64();
let dw = dw.unwrap_or(image_size.width);
diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs
index 84280ec0724..714c66bf747 100644
--- a/components/script/dom/imagedata.rs
+++ b/components/script/dom/imagedata.rs
@@ -162,7 +162,7 @@ impl ImageData {
#[allow(unsafe_code)]
pub unsafe fn get_rect(&self, rect: Rect<u32>) -> Cow<[u8]> {
- pixels::get_rect(self.as_slice(), self.get_size(), rect)
+ pixels::rgba8_get_rect(self.as_slice(), self.get_size(), rect)
}
pub fn get_size(&self) -> Size2D<u32> {
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index b5b22f4f464..97e35b058e8 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -559,7 +559,7 @@ impl WebGLRenderingContext {
_ => unimplemented!(),
};
- pixels::byte_swap_colors_inplace(&mut data);
+ pixels::rgba8_byte_swap_colors_inplace(&mut data);
TexPixels::new(data, size, false)
},
@@ -572,7 +572,7 @@ impl WebGLRenderingContext {
}
if let Some((mut data, size)) = canvas.fetch_all_data() {
// Pixels got from Canvas have already alpha premultiplied
- pixels::byte_swap_colors_inplace(&mut data);
+ pixels::rgba8_byte_swap_colors_inplace(&mut data);
TexPixels::new(data, size, true)
} else {
return Ok(None);