use crate::image_store::CheckStoreDensity;
use crate::validation::validate_sizes;
use crate::{ImageSize, ImageStore, ImageStoreMut, PicScaleError, ResamplingPlan};
use std::fmt::Debug;
use std::marker::PhantomData;
pub(crate) struct NoopPlan<T: Send + Sync, const N: usize> {
pub(crate) source_size: ImageSize,
pub(crate) target_size: ImageSize,
pub(crate) _phantom: PhantomData<T>,
}
impl<T: Copy + Send + Sync + Clone + Debug + Default, const N: usize> ResamplingPlan<T, N>
for NoopPlan<T, N>
where
for<'a> ImageStoreMut<'a, T, N>: CheckStoreDensity,
{
fn resample(
&self,
store: &ImageStore<'_, T, N>,
into: &mut ImageStoreMut<'_, T, N>,
) -> Result<(), PicScaleError> {
validate_sizes!(store, into, self.source_size, self.target_size);
if into.should_have_bit_depth() && !(1..=16).contains(&into.bit_depth) {
return Err(PicScaleError::UnsupportedBitDepth(into.bit_depth));
}
Ok(())
}
fn resample_with_scratch(
&self,
store: &ImageStore<'_, T, N>,
into: &mut ImageStoreMut<'_, T, N>,
_scratch: &mut [T],
) -> Result<(), PicScaleError> {
self.resample(store, into)
}
fn alloc_scratch(&self) -> Vec<T> {
vec![]
}
fn scratch_size(&self) -> usize {
0
}
fn target_size(&self) -> ImageSize {
self.target_size
}
fn source_size(&self) -> ImageSize {
self.source_size
}
}