mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
Incremental compilation and stable node IDs (#977)
* Generate stable node ids * checkpoint * Implement borrow tree * Add eval function on borrow tree * Refactor Node trait to fix lifetime issues * Compiler infinite loop * Impl compose pair * Transition to double lifetime on trait * Change node trait to use a generic arg for the input * Start adapting node_macro * Migrate more nodes to new macro * Fix raster tests * Port vector nodes * Make Node trait object safe * Fix FlatMapResultNode * Translate most of gstd * Fix DowncastBothNode * Refactor node trait once again to allow for HRTB for type erased nodes * Start working on type erased nodes * Try getting DowncastBothNode to work * Introduce Upcasting node + work on BorrowTree * Make enough 'static to get the code to compile * Transition DynamicExecutor to use borrow tree * Make Compose Node use HRTB's * Fix MapResultNode * Disable blur test * Add workaround for Composing type erased nodes * Convert more nodes in the node_registry * Convert more of the node_registry * Add update tree fn and hook up to frontend * Fix blur node * Implement CacheNode * Make frontend use graph compiler * Fix document_node_types type declaration for most nodes * Remove unused imports * Move comment down * Reuse nodes via borrow tree * Deprecate trait based value in favor of TaggedValue * Remove unsafe code in buffer creation * Fix blur node * Fix stable node id generation * Fix types for Image adjustment document nodes * Fix Imaginate Node * Remove unused imports * Remove log * Fix off by one error * Remove macro generated imaginate node entry * Create parameterized add node * Fix test case * Remove link from layer_panel.rs * Fix formatting
This commit is contained in:
committed by
Keavon Chambers
parent
12d6818d73
commit
004e87ca3e
@@ -7,11 +7,6 @@ extern crate alloc;
|
||||
#[cfg(feature = "log")]
|
||||
extern crate log;
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
use alloc::boxed::Box;
|
||||
#[cfg(feature = "async")]
|
||||
use async_trait::async_trait;
|
||||
|
||||
pub mod generic;
|
||||
pub mod ops;
|
||||
pub mod structural;
|
||||
@@ -26,100 +21,32 @@ pub mod raster;
|
||||
#[cfg(feature = "alloc")]
|
||||
pub mod vector;
|
||||
|
||||
pub trait Node<T> {
|
||||
type Output;
|
||||
|
||||
fn eval(self, input: T) -> Self::Output;
|
||||
// pub trait Node: for<'n> NodeIO<'n> {
|
||||
pub trait Node<'i, Input: 'i>: 'i {
|
||||
type Output: 'i;
|
||||
fn eval<'s: 'i>(&'s self, input: Input) -> Self::Output;
|
||||
}
|
||||
|
||||
trait Input<I> {
|
||||
unsafe fn input(&self, input: I);
|
||||
}
|
||||
/*impl<'i, I: 'i, O: 'i> Node<'i, I> for &'i dyn for<'n> Node<'n, I, Output = O> {
|
||||
type Output = O;
|
||||
|
||||
pub trait RefNode<T> {
|
||||
type Output;
|
||||
|
||||
fn eval_ref(&self, input: T) -> Self::Output;
|
||||
}
|
||||
|
||||
impl<'n, N: 'n, I> RefNode<I> for &'n N
|
||||
where
|
||||
&'n N: Node<I>,
|
||||
Self: 'n,
|
||||
{
|
||||
type Output = <&'n N as Node<I>>::Output;
|
||||
fn eval_ref(&self, input: I) -> Self::Output {
|
||||
self.eval(input)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AsRefNode<'n, T>
|
||||
where
|
||||
&'n Self: Node<T>,
|
||||
Self: 'n,
|
||||
{
|
||||
type Output;
|
||||
fn eval_box(&'n self, input: T) -> <Self>::Output;
|
||||
}
|
||||
|
||||
impl<'n, N: 'n, I> AsRefNode<'n, I> for N
|
||||
where
|
||||
&'n N: Node<I>,
|
||||
N: Node<I>,
|
||||
Self: 'n,
|
||||
{
|
||||
type Output = <&'n N as Node<I>>::Output;
|
||||
fn eval_box(&'n self, input: I) -> <Self>::Output {
|
||||
self.eval(input)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'n, T> Node<T> for &'n (dyn AsRefNode<'n, T, Output = T> + 'n) {
|
||||
type Output = T;
|
||||
fn eval(self, input: T) -> Self::Output {
|
||||
self.eval_box(input)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
#[async_trait]
|
||||
pub trait AsyncNode<T> {
|
||||
type Output;
|
||||
|
||||
async fn eval_async(self, input: T) -> Self::Output;
|
||||
}
|
||||
|
||||
/*#[cfg(feature = "async")]
|
||||
#[async_trait]
|
||||
impl<'n, N: Node<T> + Send + Sync + 'n, T: Send + 'n> AsyncNode<T> for N {
|
||||
type Output = N::Output;
|
||||
|
||||
async fn eval_async(self, input: T) -> Self::Output {
|
||||
Node::eval(self, input)
|
||||
fn eval<'s: 'i>(&'s self, input: I) -> Self::Output {
|
||||
(**self).eval(input)
|
||||
}
|
||||
}*/
|
||||
impl<'i, 'n: 'i, I: 'i, O: 'i> Node<'i, I> for &'n dyn for<'a> Node<'a, I, Output = O> {
|
||||
type Output = O;
|
||||
|
||||
pub trait Cache {
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
impl<N, I> Node<I> for Box<N>
|
||||
where
|
||||
N: Node<I>,
|
||||
{
|
||||
type Output = <N as Node<I>>::Output;
|
||||
fn eval(self, input: I) -> Self::Output {
|
||||
(*self).eval(input)
|
||||
fn eval<'s: 'i>(&'s self, input: I) -> Self::Output {
|
||||
(**self).eval(input)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "async")]
|
||||
impl<'n, N, I> Node<I> for &'n Box<N>
|
||||
where
|
||||
&'n N: Node<I>,
|
||||
{
|
||||
type Output = <&'n N as Node<I>>::Output;
|
||||
fn eval(self, input: I) -> Self::Output {
|
||||
self.as_ref().eval(input)
|
||||
use core::pin::Pin;
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<'i, I: 'i, O: 'i> Node<'i, I> for Pin<Box<dyn for<'a> Node<'a, I, Output = O> + 'i>> {
|
||||
type Output = O;
|
||||
|
||||
fn eval<'s: 'i>(&'s self, input: I) -> Self::Output {
|
||||
(**self).eval(input)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user