mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement Canvas pixel manipulation
This commit is contained in:
parent
e68d6d2924
commit
325400dce4
14 changed files with 305 additions and 84 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue