fast image operations
bump
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/affine.rs | 4 | ||||
| -rw-r--r-- | src/lib.rs | 7 | ||||
| -rw-r--r-- | src/overlay.rs | 4 | ||||
| -rw-r--r-- | src/uninit.rs | 10 |
5 files changed, 11 insertions, 16 deletions
@@ -1,6 +1,6 @@ [package] name = "fimg" -version = "0.4.32" +version = "0.4.33" authors = ["bend-n <[email protected]>"] license = "MIT" edition = "2021" diff --git a/src/affine.rs b/src/affine.rs index 9fc7b3c..d18d210 100644 --- a/src/affine.rs +++ b/src/affine.rs @@ -207,10 +207,10 @@ unsafe fn transpose<const CHANNELS: usize, T: AsMut<[u8]> + AsRef<[u8]>>( ) { debug_assert_eq!(img.width(), img.height()); if img.width().is_power_of_two() { - // SAFETY: caller gurantees + // SAFETY: caller guarantees unsafe { transpose_diag(img, 0, img.width() as usize) }; } else { - // SAFETY: caller gurantees + // SAFETY: caller guarantees unsafe { transpose_non_power_of_two(img) }; } } @@ -8,7 +8,8 @@ //! //! - [`Image`]: the main image type. //! - [`DynImage`]: This is the image type you use when, say, loading a png. You should immediately convert this into a -//! - [`ImageCloner`]: this is... a [`Image`], but about to be cloned. It just allows some simple out-of-place optimizations, that `.clone().op()` dont allow. (produce with [`Image::cloner`]) +//! - [`ImageCloner`]: This is... a [`Image`], but about to be cloned. It just allows some simple out-of-place optimizations, that `.clone().op()` dont allow. (produce with [`Image::cloner`]) +//! - [`uninit::Image`]: A uninitialized image. Used for performance optimization. //! //! ### Operations //! @@ -283,7 +284,7 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> { /// # Safety /// - /// the output index is not guranteed to be in bounds + /// the output index is not guaranteed to be in bounds #[inline] fn at(&self, x: u32, y: u32) -> usize { (self.width(), self.height()).at::<CHANNELS>(x, y) @@ -418,7 +419,7 @@ impl<T, const CHANNELS: usize> Image<T, CHANNELS> { /// # Safety /// - /// the output index is not guranteed to be in bounds + /// the output index is not guaranteed to be in bounds #[inline] fn slice<U>(&self, x: u32, y: u32) -> Range<usize> where diff --git a/src/overlay.rs b/src/overlay.rs index eef4272..d2d6c85 100644 --- a/src/overlay.rs +++ b/src/overlay.rs @@ -76,7 +76,7 @@ unsafe fn blit(rgb: &mut [u8], rgba: &[u8]) { while dsti + 16 <= rgb.len() { // SAFETY: i think it ok let old: Simd<u8, 16> = Simd::from_slice(unsafe { rgb.get_unchecked(dsti..dsti + 16) }); - // SAFETY: definetly ok + // SAFETY: definitly ok let new: Simd<u8, 16> = Simd::from_slice(unsafe { rgba.get_unchecked(srci..srci + 16) }); let threshold = new.simd_ge(Simd::splat(128)).to_int().cast::<u8>(); @@ -98,7 +98,7 @@ unsafe fn blit(rgb: &mut [u8], rgba: &[u8]) { } while dsti + 3 <= rgb.len() { - // SAFETY: caller gurantees slice is big enough + // SAFETY: caller guarantees slice is big enough if unsafe { *rgba.get_unchecked(srci + 3) } >= 128 { // SAFETY: slice is big enough! let src = unsafe { rgba.get_unchecked(srci..=srci + 2) }; diff --git a/src/uninit.rs b/src/uninit.rs index c4c341b..5be941f 100644 --- a/src/uninit.rs +++ b/src/uninit.rs @@ -1,14 +1,8 @@ //! the houser of uninitialized memory. €$@!0В!℡ //! //! contains [`Image`], an uninitialized image. -use std::{ - hint::assert_unchecked, - mem::MaybeUninit, - num::NonZeroU32, - ops::{Index, IndexMut}, -}; - use crate::{span::Span, CopyWithinUnchecked}; +use std::{hint::assert_unchecked, mem::MaybeUninit, num::NonZeroU32, ops::Index}; /// A uninitialized image. Be sure to initialize it! pub struct Image<T: Copy, const CHANNELS: usize> { @@ -72,7 +66,7 @@ impl<T: Copy, const CHANNELS: usize> Image<T, CHANNELS> { /// # Safety /// - /// the output index is not guranteed to be in bounds + /// the output index is not guaranteed to be in bounds #[inline] pub fn at(&self, x: u32, y: u32) -> usize { crate::At::at::<CHANNELS>((self.width(), self.height()), x, y) |