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

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::cmp::{PartialOrd, PartialEq, Ordering};
use std::iter::range_step;
#[cfg(test)]
use std::fmt::Debug;
@ -64,6 +65,17 @@ impl<T:PartialEq + PartialOrd + Ord> Comparator<T,T> for DefaultComparator {
}
}
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
pub 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;
}
}
#[cfg(test)]
fn test_find_all_elems<T: PartialEq + PartialOrd + Eq + Ord>(arr: &[T]) {
let mut i = 0;