mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Implement Canvas pixel manipulation
This commit is contained in:
parent
e68d6d2924
commit
325400dce4
14 changed files with 305 additions and 84 deletions
|
@ -5,6 +5,7 @@
|
|||
use std::iter::range_step;
|
||||
use stb_image::image as stb_image;
|
||||
use png;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
// FIXME: Images must not be copied every frame. Instead we should atomically
|
||||
// reference count them.
|
||||
|
@ -17,16 +18,6 @@ pub fn test_image_bin() -> Vec<u8> {
|
|||
TEST_IMAGE.iter().map(|&x| x).collect()
|
||||
}
|
||||
|
||||
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
|
||||
fn byte_swap(data: &mut [u8]) {
|
||||
let length = data.len();
|
||||
for i in range_step(0, length, 4) {
|
||||
let r = data[i + 2];
|
||||
data[i + 2] = data[i + 0];
|
||||
data[i + 0] = r;
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue