aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas_traits/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/canvas_traits/lib.rs')
-rw-r--r--components/canvas_traits/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs
index 98eaa159077..db945750a0c 100644
--- a/components/canvas_traits/lib.rs
+++ b/components/canvas_traits/lib.rs
@@ -539,3 +539,16 @@ impl ToAzColor for RGBA {
self.alpha as AzFloat)
}
}
+
+// 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();
+ // FIXME(rust #27741): Range::step_by is not stable yet as of this writing.
+ let mut i = 0;
+ while i < length {
+ let r = data[i + 2];
+ data[i + 2] = data[i + 0];
+ data[i + 0] = r;
+ i += 4;
+ }
+}