mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Bump version of dyn-any to address missues which could lead to ub (#1145)
* Make StaticType trait unsafe * Mark StaticTypeSized and StaticTypeClone as unsafe as well * Update dyn-any dependency * Update manifest links
This commit is contained in:
committed by
Keavon Chambers
parent
9db5ad43bf
commit
1d6c4f13dd
@@ -42,7 +42,7 @@ impl<'n, T: 'n + dyn_any::StaticTypeSized> FixedSizeStack<T> {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len.load(Ordering::SeqCst) == 0
|
||||
}
|
||||
pub fn push_fn<'a>(&self, f: impl FnOnce(&'a [T::Static]) -> T) {
|
||||
pub fn push_fn<'a>(&self, f: impl FnOnce(&'a [<T as StaticTypeSized>::Static]) -> T) {
|
||||
assert_eq!(std::mem::size_of::<T>(), std::mem::size_of::<T::Static>());
|
||||
unsafe { self.push(f(self.get())) }
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ pub struct ImageSlice<'a, Pixel> {
|
||||
pub data: &'a (),
|
||||
}
|
||||
|
||||
impl<P: StaticTypeSized> StaticType for ImageSlice<'_, P> {
|
||||
unsafe impl<P: StaticTypeSized> StaticType for ImageSlice<'_, P> {
|
||||
type Static = ImageSlice<'static, P::Static>;
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ mod image {
|
||||
pub data: Vec<P>,
|
||||
}
|
||||
|
||||
impl<P: StaticTypeSized + Pixel> StaticType for Image<P>
|
||||
unsafe impl<P: StaticTypeSized + Pixel> StaticType for Image<P>
|
||||
where
|
||||
P::Static: Pixel,
|
||||
{
|
||||
@@ -770,7 +770,7 @@ mod image {
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: StaticTypeSized + Pixel> StaticType for ImageFrame<P>
|
||||
unsafe impl<P: StaticTypeSized + Pixel> StaticType for ImageFrame<P>
|
||||
where
|
||||
P::Static: Pixel,
|
||||
{
|
||||
|
||||
@@ -358,10 +358,6 @@ pub struct BlendNode<BlendMode, Opacity> {
|
||||
opacity: Opacity,
|
||||
}
|
||||
|
||||
impl<Opacity: dyn_any::StaticTypeSized, Blend: dyn_any::StaticTypeSized> StaticType for BlendNode<Blend, Opacity> {
|
||||
type Static = BlendNode<Blend::Static, Opacity::Static>;
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(BlendNode)]
|
||||
fn blend_node(input: (Color, Color), blend_mode: BlendMode, opacity: f64) -> Color {
|
||||
let opacity = opacity / 100.;
|
||||
|
||||
@@ -16,10 +16,6 @@ impl<'i, const N: u32> Node<'i, ()> for IntNode<N> {
|
||||
#[derive(Default, Debug)]
|
||||
pub struct ValueNode<T>(pub T);
|
||||
|
||||
impl<T: StaticTypeSized> StaticType for ValueNode<T> {
|
||||
type Static = ValueNode<T::Static>;
|
||||
}
|
||||
|
||||
impl<'i, T: 'i> Node<'i, ()> for ValueNode<T> {
|
||||
type Output = &'i T;
|
||||
fn eval<'s: 'i>(&'s self, _input: ()) -> Self::Output {
|
||||
@@ -48,13 +44,6 @@ impl<T: Clone + Copy> Copy for ValueNode<T> {}
|
||||
#[derive(Clone)]
|
||||
pub struct ClonedNode<T: Clone>(pub T);
|
||||
|
||||
impl<T: Clone + StaticTypeSized> StaticType for ClonedNode<T>
|
||||
where
|
||||
T::Static: Clone,
|
||||
{
|
||||
type Static = ClonedNode<T::Static>;
|
||||
}
|
||||
|
||||
impl<'i, T: Clone + 'i> Node<'i, ()> for ClonedNode<T> {
|
||||
type Output = T;
|
||||
fn eval<'s: 'i>(&'s self, _input: ()) -> Self::Output {
|
||||
|
||||
@@ -264,10 +264,6 @@ pub struct BlendImageTupleNode<P, MapFn> {
|
||||
_p: PhantomData<P>,
|
||||
}
|
||||
|
||||
impl<MapFn: StaticTypeSized, P: StaticTypeSized> StaticType for BlendImageTupleNode<P, MapFn> {
|
||||
type Static = BlendImageTupleNode<P::Static, MapFn::Static>;
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(BlendImageTupleNode<_P>)]
|
||||
fn blend_image_tuple<_P: Pixel + Debug, MapFn>(images: (ImageFrame<_P>, ImageFrame<_P>), map_fn: &'any_input MapFn) -> ImageFrame<_P>
|
||||
where
|
||||
@@ -286,10 +282,6 @@ pub struct BlendImageNode<P, Background, MapFn> {
|
||||
_p: PhantomData<P>,
|
||||
}
|
||||
|
||||
impl<P: StaticTypeSized, Background: StaticTypeSized, MapFn: StaticTypeSized> StaticType for BlendImageNode<P, Background, MapFn> {
|
||||
type Static = BlendImageNode<P::Static, Background::Static, MapFn::Static>;
|
||||
}
|
||||
|
||||
// TODO: Implement proper blending
|
||||
#[node_macro::node_fn(BlendImageNode<_P>)]
|
||||
fn blend_image<_P: Clone, MapFn, Frame: Sample<Pixel = _P> + Transform, Background: RasterMut<Pixel = _P> + Transform>(
|
||||
|
||||
Reference in New Issue
Block a user