Make sure that everything is always in the correct pixel format#31
Make sure that everything is always in the correct pixel format#31jaytaph wants to merge 5 commits into
Conversation
Added additional benchmarking
|
I feel like this has a lot of other changes form the other PR's. I think the stacking might not have worked properly |
It did.. but the other PR's are rebased on upstream/main, so I need to manually update each PR on every merge. |
|
@Sharktheone it's rebased now |
| &mut self, | ||
| width: usize, | ||
| height: usize, | ||
| data: Vec<u8>, |
There was a problem hiding this comment.
Btw, in general i think this should not be a Vec here, but more a Arc<[u8]>
There was a problem hiding this comment.
Or maybe even Bytes from the bytes crate
| let texture_id = texture_store.add( | ||
| w, | ||
| h, | ||
| data.to_vec(), |
There was a problem hiding this comment.
we might also have this be something else entirely. so we don't have to copy the data here
| pub fn to_rgba<'a>(self, data: &'a [u8]) -> std::borrow::Cow<'a, [u8]> { | ||
| match self { | ||
| PixelFormat::Rgba8 => std::borrow::Cow::Borrowed(data), | ||
| PixelFormat::PreMulArgb32 => std::borrow::Cow::Owned(swap_rb(data)), | ||
| } | ||
| } | ||
|
|
||
| /// Returns `data` with bytes in `[B, G, R, A]` order (little-endian ARGB32), | ||
| /// copying (and swapping R/B) only when the source is not already in that order. | ||
| pub fn to_argb32<'a>(self, data: &'a [u8]) -> std::borrow::Cow<'a, [u8]> { | ||
| match self { | ||
| PixelFormat::PreMulArgb32 => std::borrow::Cow::Borrowed(data), | ||
| PixelFormat::Rgba8 => std::borrow::Cow::Owned(swap_rb(data)), | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I feel like we can do this more efficiently by passing in a &mut [u8] and swapping it in place
There are some inconsistencies between mac and linux binaries when it comes to RGB/BGR formats.