mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
Add GPU support for node graph
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
use core::{borrow::Borrow, marker::PhantomData};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use crate::Node;
|
||||
pub struct FnNode<T: Fn(&In) -> O, In, O>(T, PhantomData<In>, PhantomData<O>);
|
||||
impl<'n, T: Fn(&In) -> O, In, O: 'n> Node<'n, In> for FnNode<T, In, O> {
|
||||
pub struct FnNode<T: Fn(In) -> O, In, O>(T, PhantomData<In>, PhantomData<O>);
|
||||
impl<'n, T: Fn(In) -> O, In, O: 'n> Node<'n, In> for FnNode<T, In, O> {
|
||||
type Output = O;
|
||||
|
||||
fn eval(&'n self, input: &'n In) -> Self::Output {
|
||||
self.0(input.borrow())
|
||||
fn eval(&'n self, input: In) -> Self::Output {
|
||||
self.0(input)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Fn(&In) -> O, In, O> FnNode<T, In, O> {
|
||||
impl<T: Fn(In) -> O, In, O> FnNode<T, In, O> {
|
||||
pub fn new(f: T) -> Self {
|
||||
FnNode(f, PhantomData::default(), PhantomData::default())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FnNodeWithState<T: Fn(&In, &State) -> O, In, O, State>(
|
||||
pub struct FnNodeWithState<T: Fn(In, &State) -> O, In, O, State>(
|
||||
T,
|
||||
State,
|
||||
PhantomData<In>,
|
||||
PhantomData<O>,
|
||||
);
|
||||
impl<'n, T: Fn(&In, &State) -> O, In, O: 'n, State> Node<'n, In>
|
||||
impl<'n, T: Fn(In, &State) -> O, In, O: 'n, State> Node<'n, In>
|
||||
for FnNodeWithState<T, In, O, State>
|
||||
{
|
||||
type Output = O;
|
||||
|
||||
fn eval(&'n self, input: &'n In) -> Self::Output {
|
||||
self.0(input.borrow(), &self.1)
|
||||
fn eval(&'n self, input: In) -> Self::Output {
|
||||
self.0(input, &self.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Fn(&In, &State) -> O, In, O, State> FnNodeWithState<T, In, O, State> {
|
||||
impl<T: Fn(In, &State) -> O, In, O, State> FnNodeWithState<T, In, O, State> {
|
||||
pub fn new(f: T, state: State) -> Self {
|
||||
FnNodeWithState(f, state, PhantomData::default(), PhantomData::default())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user