Implement Infrastructure to reuse previous frames for brush drawing

Implement Infrastructuro to reuse the previous evaluation of the
node graph to blend the new stroke with instead of drawing the
entire trace from scratch.
This does not transition to a blending based approach because that still
caused regressions but allows the brush node to work with input data
natively.

Test Plan:
- Use the brush tool in the editor and check for regressions
- Evaluate the performance

Reviewers: Keavon

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1190
This commit is contained in:
Dennis Kobert
2023-05-03 13:14:41 +02:00
committed by GitHub
parent 7c115b3b26
commit a3498fe182
19 changed files with 282 additions and 172 deletions

View File

@@ -39,8 +39,9 @@ pub trait Node<'i, Input: 'i>: 'i {
type Output: 'i;
fn eval(&'i self, input: Input) -> Self::Output;
fn reset(self: Pin<&mut Self>) {}
#[cfg(feature = "alloc")]
fn serialize(&self) -> Option<String> {
#[cfg(feature = "std")]
fn serialize(&self) -> Option<std::sync::Arc<dyn core::any::Any>> {
log::warn!("Node::serialize not implemented for {}", core::any::type_name::<Self>());
None
}
}

View File

@@ -139,6 +139,7 @@ pub trait UnassociatedAlpha: RGB + Alpha {
pub trait Alpha {
type AlphaChannel: Channel;
const TRANSPARENT: Self;
fn alpha(&self) -> Self::AlphaChannel;
fn a(&self) -> Self::AlphaChannel {
self.alpha()

View File

@@ -96,6 +96,8 @@ impl Pixel for Color {
impl Alpha for Color {
type AlphaChannel = f32;
const TRANSPARENT: Self = Self::TRANSPARENT;
fn alpha(&self) -> f32 {
self.alpha
}