Implement Canvas pixel manipulation

This commit is contained in:
Edit Balint 2015-01-15 17:20:26 +01:00 committed by Josh Matthews
parent e68d6d2924
commit 325400dce4
14 changed files with 305 additions and 84 deletions

View file

@ -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();