Add Table<Color> as a graphical type (#3033)

* Reduce code duplication in bounding box impls on Table

* Working Table<Color> rendering in the graph

* Implement color and fix other rendering with Vello and polish
This commit is contained in:
Keavon Chambers
2025-08-10 01:34:33 -07:00
committed by GitHub
parent 81abfe147a
commit 2f4aef34e5
24 changed files with 462 additions and 198 deletions

View File

@@ -2,7 +2,7 @@ use crate::brush_cache::BrushCache;
use crate::brush_stroke::{BrushStroke, BrushStyle};
use glam::{DAffine2, DVec2};
use graphene_core::blending::BlendMode;
use graphene_core::bounds::BoundingBox;
use graphene_core::bounds::{BoundingBox, RenderBoundingBox};
use graphene_core::color::{Alpha, Color, Pixel, Sample};
use graphene_core::generic::FnNode;
use graphene_core::math::bbox::{AxisAlignedBbox, Bbox};
@@ -186,7 +186,8 @@ async fn brush(_: impl Ctx, mut image_frame_table: Table<Raster<CPU>>, strokes:
// TODO: Find a way to handle more than one row
let table_row = image_frame_table.iter().next().expect("Expected the one row we just pushed").into_cloned();
let [start, end] = Table::new_from_row(table_row.clone()).bounding_box(DAffine2::IDENTITY, false).unwrap_or([DVec2::ZERO, DVec2::ZERO]);
let bounds = Table::new_from_row(table_row.clone()).bounding_box(DAffine2::IDENTITY, false);
let [start, end] = if let RenderBoundingBox::Rectangle(rect) = bounds { rect } else { [DVec2::ZERO, DVec2::ZERO] };
let image_bbox = AxisAlignedBbox { start, end };
let stroke_bbox = strokes.iter().map(|s| s.bounding_box()).reduce(|a, b| a.union(&b)).unwrap_or(AxisAlignedBbox::ZERO);
let bbox = if image_bbox.size().length() < 0.1 { stroke_bbox } else { stroke_bbox.union(&image_bbox) };

View File

@@ -1,5 +1,5 @@
use crate::blending::AlphaBlending;
use crate::bounds::BoundingBox;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::math::quad::Quad;
use crate::raster_types::{CPU, GPU, Raster};
use crate::table::{Table, TableRow};
@@ -42,15 +42,16 @@ impl Artboard {
}
impl BoundingBox for Artboard {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
let artboard_bounds = (transform * Quad::from_box([self.location.as_dvec2(), self.location.as_dvec2() + self.dimensions.as_dvec2()])).bounding_box();
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
let artboard_bounds = || (transform * Quad::from_box([self.location.as_dvec2(), self.location.as_dvec2() + self.dimensions.as_dvec2()])).bounding_box();
if self.clip {
Some(artboard_bounds)
} else {
[self.content.bounding_box(transform, include_stroke), Some(artboard_bounds)]
.into_iter()
.flatten()
.reduce(Quad::combine_bounds)
return RenderBoundingBox::Rectangle(artboard_bounds());
}
match self.content.bounding_box(transform, include_stroke) {
RenderBoundingBox::Rectangle(content_bounds) => RenderBoundingBox::Rectangle(Quad::combine_bounds(content_bounds, artboard_bounds())),
other => other,
}
}
}
@@ -88,12 +89,6 @@ pub fn migrate_artboard<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Re
})
}
impl BoundingBox for Table<Artboard> {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
self.iter().filter_map(|row| row.element.bounding_box(transform, include_stroke)).reduce(Quad::combine_bounds)
}
}
#[node_macro::node(category(""))]
async fn create_artboard<T: Into<Table<Graphic>> + 'n>(
ctx: impl ExtractAll + CloneVarArgs + Ctx,
@@ -102,6 +97,7 @@ async fn create_artboard<T: Into<Table<Graphic>> + 'n>(
Context -> Table<Vector>,
Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>,
Context -> Table<Color>,
Context -> DAffine2,
)]
content: impl Node<Context<'static>, Output = T>,

View File

@@ -34,6 +34,13 @@ impl MultiplyAlpha for Table<Raster<CPU>> {
}
}
}
impl MultiplyAlpha for Table<Color> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
}
}
}
pub(super) trait MultiplyFill {
fn multiply_fill(&mut self, factor: f64);
@@ -64,6 +71,13 @@ impl MultiplyFill for Table<Raster<CPU>> {
}
}
}
impl MultiplyFill for Table<Color> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
}
}
}
trait SetBlendMode {
fn set_blend_mode(&mut self, blend_mode: BlendMode);
@@ -90,6 +104,13 @@ impl SetBlendMode for Table<Raster<CPU>> {
}
}
}
impl SetBlendMode for Table<Color> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
}
}
}
trait SetClip {
fn set_clip(&mut self, clip: bool);
@@ -116,6 +137,13 @@ impl SetClip for Table<Raster<CPU>> {
}
}
}
impl SetClip for Table<Color> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
}
}
}
#[node_macro::node(category("Style"))]
fn blend_mode<T: SetBlendMode>(
@@ -124,6 +152,7 @@ fn blend_mode<T: SetBlendMode>(
Table<Graphic>,
Table<Vector>,
Table<Raster<CPU>>,
Table<Color>,
)]
mut value: T,
blend_mode: BlendMode,
@@ -140,6 +169,7 @@ fn opacity<T: MultiplyAlpha>(
Table<Graphic>,
Table<Vector>,
Table<Raster<CPU>>,
Table<Color>,
)]
mut value: T,
#[default(100.)] opacity: Percentage,
@@ -156,6 +186,7 @@ fn blending<T: SetBlendMode + MultiplyAlpha + MultiplyFill + SetClip>(
Table<Graphic>,
Table<Vector>,
Table<Raster<CPU>>,
Table<Color>,
)]
mut value: T,
blend_mode: BlendMode,

View File

@@ -1,15 +1,23 @@
use crate::Color;
use glam::{DAffine2, DVec2};
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub enum RenderBoundingBox {
#[default]
None,
Infinite,
Rectangle([DVec2; 2]),
}
pub trait BoundingBox {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]>;
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox;
}
macro_rules! none_impl {
($t:path) => {
impl BoundingBox for $t {
fn bounding_box(&self, _transform: DAffine2, _include_stroke: bool) -> Option<[DVec2; 2]> {
None
fn bounding_box(&self, _transform: DAffine2, _include_stroke: bool) -> RenderBoundingBox {
RenderBoundingBox::None
}
}
};
@@ -20,5 +28,11 @@ none_impl!(bool);
none_impl!(f32);
none_impl!(f64);
none_impl!(DVec2);
none_impl!(Option<Color>);
none_impl!(Vec<Color>);
none_impl!(Option<Color>); // TODO: Remove this?
none_impl!(Vec<Color>); // TODO: Remove this?
impl BoundingBox for Color {
fn bounding_box(&self, _transform: DAffine2, _include_stroke: bool) -> RenderBoundingBox {
RenderBoundingBox::Infinite
}
}

View File

@@ -1,6 +1,5 @@
use crate::blending::AlphaBlending;
use crate::bounds::BoundingBox;
use crate::math::quad::Quad;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::raster_types::{CPU, GPU, Raster};
use crate::table::{Table, TableRow};
use crate::uuid::NodeId;
@@ -17,11 +16,12 @@ pub enum Graphic {
Vector(Table<Vector>),
RasterCPU(Table<Raster<CPU>>),
RasterGPU(Table<Raster<GPU>>),
Color(Table<Color>),
}
impl Default for Graphic {
fn default() -> Self {
Self::Graphic(Default::default())
Self::Graphic(Table::new())
}
}
@@ -98,6 +98,48 @@ impl From<Table<Raster<GPU>>> for Table<Graphic> {
}
}
// Color
impl From<Color> for Graphic {
fn from(color: Color) -> Self {
Graphic::Color(Table::new_from_element(color))
}
}
impl From<Table<Color>> for Graphic {
fn from(color: Table<Color>) -> Self {
Graphic::Color(color)
}
}
impl From<Color> for Table<Graphic> {
fn from(color: Color) -> Self {
Table::new_from_element(Graphic::Color(Table::new_from_element(color)))
}
}
impl From<Table<Color>> for Table<Graphic> {
fn from(color: Table<Color>) -> Self {
Table::new_from_element(Graphic::Color(color))
}
}
// Option<Color>
impl From<Option<Color>> for Graphic {
fn from(color: Option<Color>) -> Self {
if let Some(color) = color {
Graphic::Color(Table::new_from_element(color))
} else {
Graphic::default()
}
}
}
impl From<Option<Color>> for Table<Graphic> {
fn from(color: Option<Color>) -> Self {
if let Some(color) = color {
Table::new_from_element(Graphic::Color(Table::new_from_element(color)))
} else {
Table::new()
}
}
}
// DAffine2
impl From<DAffine2> for Graphic {
fn from(_: DAffine2) -> Self {
@@ -159,6 +201,7 @@ impl Graphic {
Graphic::Graphic(graphic) => graphic.iter().all(|row| row.alpha_blending.clip),
Graphic::RasterCPU(raster) => raster.iter().all(|row| row.alpha_blending.clip),
Graphic::RasterGPU(raster) => raster.iter().all(|row| row.alpha_blending.clip),
Graphic::Color(color) => color.iter().all(|row| row.alpha_blending.clip),
}
}
@@ -175,28 +218,21 @@ impl Graphic {
}
impl BoundingBox for Graphic {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
match self {
Graphic::Vector(vector) => vector.bounding_box(transform, include_stroke),
Graphic::RasterCPU(raster) => raster.bounding_box(transform, include_stroke),
Graphic::RasterGPU(raster) => raster.bounding_box(transform, include_stroke),
Graphic::Graphic(graphic) => graphic.bounding_box(transform, include_stroke),
Graphic::Color(color) => color.bounding_box(transform, include_stroke),
}
}
}
impl BoundingBox for Table<Graphic> {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
self.iter()
.filter_map(|element| element.element.bounding_box(transform * *element.transform, include_stroke))
.reduce(Quad::combine_bounds)
}
}
#[node_macro::node(category(""))]
async fn source_node_id<I: 'n + Send + Clone>(
_: impl Ctx,
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)] content: Table<I>,
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)] content: Table<I>,
node_path: Vec<NodeId>,
) -> Table<I> {
// Get the penultimate element of the node path, or None if the path is too short
@@ -216,11 +252,11 @@ async fn source_node_id<I: 'n + Send + Clone>(
async fn extend<I: 'n + Send + Clone>(
_: impl Ctx,
/// The table whose rows will appear at the start of the extended table.
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)]
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)]
base: Table<I>,
/// The table whose rows will appear at the end of the extended table.
#[expose]
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)]
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)]
new: Table<I>,
) -> Table<I> {
let mut base = base;
@@ -233,9 +269,9 @@ async fn extend<I: 'n + Send + Clone>(
#[node_macro::node(category(""))]
async fn legacy_layer_extend<I: 'n + Send + Clone>(
_: impl Ctx,
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)] base: Table<I>,
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)] base: Table<I>,
#[expose]
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)]
#[implementations(Table<Artboard>, Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)]
new: Table<I>,
nested_node_path: Vec<NodeId>,
) -> Table<I> {
@@ -260,6 +296,9 @@ async fn wrap_graphic<T: Into<Graphic> + 'n>(
Table<Vector>,
Table<Raster<CPU>>,
Table<Raster<GPU>>,
Table<Color>,
Color,
Option<Color>,
DAffine2,
)]
content: T,
@@ -277,6 +316,9 @@ async fn to_graphic<T: Into<Table<Graphic>> + 'n>(
Table<Vector>,
Table<Raster<CPU>>,
Table<Raster<GPU>>,
Table<Color>,
Color,
Option<Color>,
)]
content: T,
) -> Table<Graphic> {

View File

@@ -1,8 +1,7 @@
use crate::Color;
use crate::bounds::BoundingBox;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::math::quad::Quad;
use crate::raster::Image;
use crate::table::Table;
use core::ops::Deref;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
@@ -199,17 +198,16 @@ mod gpu_common {
}
}
impl<T> BoundingBox for Table<Raster<T>>
impl<T> BoundingBox for Raster<T>
where
Raster<T>: Storage,
{
fn bounding_box(&self, transform: DAffine2, _include_stroke: bool) -> Option<[DVec2; 2]> {
self.iter()
.filter(|row| !row.element.is_empty()) // Eliminate empty images
.flat_map(|row| {
let transform = transform * *row.transform;
(transform.matrix2.determinant() != 0.).then(|| (transform * Quad::from_box([DVec2::ZERO, DVec2::ONE])).bounding_box())
})
.reduce(Quad::combine_bounds)
fn bounding_box(&self, transform: DAffine2, _include_stroke: bool) -> RenderBoundingBox {
if self.is_empty() || transform.matrix2.determinant() == 0. {
return RenderBoundingBox::None;
}
let unit_rectangle = Quad::from_box([DVec2::ZERO, DVec2::ONE]);
RenderBoundingBox::Rectangle((transform * unit_rectangle).bounding_box())
}
}

View File

@@ -29,6 +29,7 @@ impl RenderComplexity for Graphic {
Self::Vector(table) => table.render_complexity(),
Self::RasterCPU(table) => table.render_complexity(),
Self::RasterGPU(table) => table.render_complexity(),
Self::Color(table) => table.render_complexity(),
}
}
}
@@ -52,6 +53,12 @@ impl RenderComplexity for Raster<GPU> {
}
}
impl RenderComplexity for Color {
fn render_complexity(&self) -> usize {
1
}
}
impl RenderComplexity for String {}
impl RenderComplexity for bool {}
impl RenderComplexity for f32 {}

View File

@@ -1,6 +1,7 @@
use crate::AlphaBlending;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::transform::ApplyTransform;
use crate::uuid::NodeId;
use crate::{AlphaBlending, math::quad::Quad};
use dyn_any::StaticType;
use glam::DAffine2;
use std::hash::Hash;
@@ -125,6 +126,28 @@ impl<T> Table<T> {
}
}
impl<T: BoundingBox> BoundingBox for Table<T> {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
let mut combined_bounds = None;
for row in self.iter() {
match row.element.bounding_box(transform * *row.transform, include_stroke) {
RenderBoundingBox::None => continue,
RenderBoundingBox::Infinite => return RenderBoundingBox::Infinite,
RenderBoundingBox::Rectangle(bounds) => match combined_bounds {
Some(existing) => combined_bounds = Some(Quad::combine_bounds(existing, bounds)),
None => combined_bounds = Some(bounds),
},
}
}
match combined_bounds {
Some(bounds) => RenderBoundingBox::Rectangle(bounds),
None => RenderBoundingBox::None,
}
}
}
impl<T> IntoIterator for Table<T> {
type Item = TableRow<T>;
type IntoIter = TableRowIter<T>;

View File

@@ -2,7 +2,7 @@ use crate::Artboard;
use crate::math::bbox::AxisAlignedBbox;
pub use crate::vector::ReferencePoint;
use core::f64;
use glam::{DAffine2, DMat2, DVec2};
use glam::{DAffine2, DMat2, DVec2, UVec2};
pub trait Transform {
fn transform(&self) -> DAffine2;
@@ -89,7 +89,7 @@ pub struct Footprint {
/// Inverse of the transform which will be applied to the node output during the rendering process
pub transform: DAffine2,
/// Resolution of the target output area in pixels
pub resolution: glam::UVec2,
pub resolution: UVec2,
/// Quality of the render, this may be used by caching nodes to decide if the cached render is sufficient
pub quality: RenderQuality,
}
@@ -103,7 +103,7 @@ impl Default for Footprint {
impl Footprint {
pub const DEFAULT: Self = Self {
transform: DAffine2::IDENTITY,
resolution: glam::UVec2::new(1920, 1080),
resolution: UVec2::new(1920, 1080),
quality: RenderQuality::Full,
};
@@ -112,7 +112,7 @@ impl Footprint {
matrix2: DMat2::from_diagonal(DVec2::splat(f64::INFINITY)),
translation: DVec2::ZERO,
},
resolution: glam::UVec2::new(0, 0),
resolution: UVec2::ZERO,
quality: RenderQuality::Full,
};

View File

@@ -5,6 +5,7 @@ use crate::vector::Vector;
use crate::{CloneVarArgs, Context, Ctx, ExtractAll, Graphic, OwnedContextImpl};
use core::f64;
use glam::{DAffine2, DVec2};
use graphene_core_shaders::color::Color;
#[node_macro::node(category(""))]
async fn transform<T: ApplyTransform + 'n + 'static>(
@@ -43,7 +44,7 @@ async fn transform<T: ApplyTransform + 'n + 'static>(
#[node_macro::node(category(""))]
fn replace_transform<Data, TransformInput: Transform>(
_: impl Ctx,
#[implementations(Table<Vector>, Table<Raster<CPU>>, Table<Graphic>)] mut data: Table<Data>,
#[implementations(Table<Vector>, Table<Raster<CPU>>, Table<Graphic>, Table<Color>)] mut data: Table<Data>,
#[implementations(DAffine2)] transform: TransformInput,
) -> Table<Data> {
for data_transform in data.iter_mut() {
@@ -60,6 +61,7 @@ async fn extract_transform<T>(
Table<Vector>,
Table<Raster<CPU>>,
Table<Raster<GPU>>,
Table<Color>,
)]
vector: Table<T>,
) -> DAffine2 {
@@ -94,6 +96,7 @@ async fn boundless_footprint<T: 'n + 'static>(
Context -> Table<Graphic>,
Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>,
Context -> Table<Color>,
Context -> String,
Context -> f64,
)]
@@ -112,6 +115,7 @@ async fn freeze_real_time<T: 'n + 'static>(
Context -> Table<Graphic>,
Context -> Table<Raster<CPU>>,
Context -> Table<Raster<GPU>>,
Context -> Table<Color>,
Context -> String,
Context -> f64,
)]

View File

@@ -3,6 +3,7 @@ use crate::table::{Table, TableRowRef};
use crate::vector::Vector;
use crate::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractIndex, ExtractVarArgs, Graphic, OwnedContextImpl};
use glam::DVec2;
use graphene_core_shaders::color::Color;
#[node_macro::node(name("Instance on Points"), category("Instancing"), path(graphene_core::vector))]
async fn instance_on_points<T: Into<Graphic> + Default + Send + Clone + 'static>(
@@ -11,7 +12,8 @@ async fn instance_on_points<T: Into<Graphic> + Default + Send + Clone + 'static>
#[implementations(
Context -> Table<Graphic>,
Context -> Table<Vector>,
Context -> Table<Raster<CPU>>
Context -> Table<Raster<CPU>>,
Context -> Table<Color>,
)]
instance: impl Node<'n, Context<'static>, Output = Table<T>>,
reverse: bool,
@@ -52,7 +54,8 @@ async fn instance_repeat<T: Into<Graphic> + Default + Send + Clone + 'static>(
#[implementations(
Context -> Table<Graphic>,
Context -> Table<Vector>,
Context -> Table<Raster<CPU>>
Context -> Table<Raster<CPU>>,
Context -> Table<Color>,
)]
instance: impl Node<'n, Context<'static>, Output = Table<T>>,
#[default(1)] count: u64,

View File

@@ -4,7 +4,7 @@ use super::algorithms::spline::{solve_spline_first_handle_closed, solve_spline_f
use super::misc::{CentroidType, bezpath_from_manipulator_groups, bezpath_to_manipulator_groups, point_to_dvec2};
use super::style::{Fill, Gradient, GradientStops, Stroke};
use super::{PointId, SegmentDomain, SegmentId, StrokeId, Vector, VectorExt};
use crate::bounds::BoundingBox;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::raster_types::{CPU, GPU, Raster};
use crate::registry::types::{Angle, Fraction, IntegerCount, Length, Multiplier, Percentage, PixelLength, PixelSize, SeedValue};
use crate::table::{Table, TableRow, TableRowMut};
@@ -106,7 +106,7 @@ where
}
#[node_macro::node(category("Vector: Style"), path(graphene_core::vector), properties("fill_properties"))]
async fn fill<F: Into<Fill> + 'n + Send, V>(
async fn fill<F: Into<Fill> + 'n + Send, V: VectorTableIterMut + 'n + Send>(
_: impl Ctx,
#[implementations(
Table<Vector>,
@@ -116,7 +116,7 @@ async fn fill<F: Into<Fill> + 'n + Send, V>(
Table<Graphic>,
Table<Graphic>,
Table<Graphic>,
Table<Graphic>
Table<Graphic>,
)]
/// The content with vector paths to apply the fill style to.
mut content: V,
@@ -135,10 +135,7 @@ async fn fill<F: Into<Fill> + 'n + Send, V>(
fill: F,
_backup_color: Option<Color>,
_backup_gradient: Gradient,
) -> V
where
V: VectorTableIterMut + 'n + Send,
{
) -> V {
let fill: Fill = fill.into();
for vector in content.vector_iter_mut() {
let mut fill = fill.clone();
@@ -219,7 +216,7 @@ where
async fn repeat<I: 'n + Send + Clone>(
_: impl Ctx,
// TODO: Implement other graphical types.
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>)] instance: Table<I>,
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Color>)] instance: Table<I>,
#[default(100., 100.)]
// TODO: When using a custom Properties panel layout in document_node_definitions.rs and this default is set, the widget weirdly doesn't show up in the Properties panel. Investigation is needed.
direction: PixelSize,
@@ -255,7 +252,7 @@ async fn repeat<I: 'n + Send + Clone>(
async fn circular_repeat<I: 'n + Send + Clone>(
_: impl Ctx,
// TODO: Implement other graphical types.
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>)] instance: Table<I>,
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Color>)] instance: Table<I>,
angle_offset: Angle,
#[unit(" px")]
#[default(5)]
@@ -291,7 +288,7 @@ async fn copy_to_points<I: 'n + Send + Clone>(
points: Table<Vector>,
#[expose]
/// Artwork to be copied and placed at each point.
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>)]
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Color>)]
instance: Table<I>,
/// Minimum range of randomized sizes given to each instance.
#[default(1)]
@@ -366,7 +363,7 @@ async fn copy_to_points<I: 'n + Send + Clone>(
#[node_macro::node(category("Instancing"), path(graphene_core::vector))]
async fn mirror<I: 'n + Send + Clone>(
_: impl Ctx,
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>)] instance: Table<I>,
#[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Color>)] content: Table<I>,
#[default(ReferencePoint::Center)] relative_to_bounds: ReferencePoint,
#[unit(" px")] offset: f64,
#[range((-90., 90.))] angle: Angle,
@@ -375,14 +372,12 @@ async fn mirror<I: 'n + Send + Clone>(
where
Table<I>: BoundingBox,
{
let mut result_table = Table::new();
// Normalize the direction vector
let normal = DVec2::from_angle(angle.to_radians());
// The mirror reference is based on the bounding box (at least for now, until we have proper local layer origins)
let Some(bounding_box) = instance.bounding_box(DAffine2::IDENTITY, false) else {
return result_table;
// The mirror reference may be based on the bounding box if an explicit reference point is chosen
let RenderBoundingBox::Rectangle(bounding_box) = content.bounding_box(DAffine2::IDENTITY, false) else {
return content;
};
let reference_point_location = relative_to_bounds.point_in_bounding_box((bounding_box[0], bounding_box[1]).into());
@@ -404,15 +399,17 @@ where
reflection * DAffine2::from_translation(DVec2::from_angle(angle.to_radians()) * DVec2::splat(-offset))
};
let mut result_table = Table::new();
// Add original instance depending on the keep_original flag
if keep_original {
for instance in instance.clone().into_iter() {
for instance in content.clone().into_iter() {
result_table.push(instance);
}
}
// Create and add mirrored instance
for mut row in instance.into_iter() {
for mut row in content.into_iter() {
row.transform = reflected_transform * row.transform;
result_table.push(row);
}
@@ -1901,7 +1898,7 @@ fn point_inside(_: impl Ctx, source: Table<Vector>, point: DVec2) -> bool {
}
#[node_macro::node(category("General"), path(graphene_core::vector))]
async fn count_elements<I>(_: impl Ctx, #[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>)] source: Table<I>) -> u64 {
async fn count_elements<I>(_: impl Ctx, #[implementations(Table<Graphic>, Table<Vector>, Table<Raster<CPU>>, Table<Raster<GPU>>, Table<Color>)] source: Table<I>) -> u64 {
source.len() as u64
}

View File

@@ -2,7 +2,7 @@ use super::misc::dvec2_to_point;
use super::style::{PathStyle, Stroke};
pub use super::vector_attributes::*;
pub use super::vector_modification::*;
use crate::bounds::BoundingBox;
use crate::bounds::{BoundingBox, RenderBoundingBox};
use crate::math::quad::Quad;
use crate::table::Table;
use crate::transform::Transform;
@@ -437,8 +437,9 @@ impl Vector {
}
impl BoundingBox for Table<Vector> {
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
self.iter()
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> RenderBoundingBox {
let bounds = self
.iter()
.flat_map(|row| {
if !include_stroke {
return row.element.bounding_box_with_transform(transform * *row.transform);
@@ -455,7 +456,12 @@ impl BoundingBox for Table<Vector> {
row.element.bounding_box_with_transform(transform * *row.transform).map(|[a, b]| [a - offset, b + offset])
})
.reduce(Quad::combine_bounds)
.reduce(Quad::combine_bounds);
match bounds {
Some(bounds) => RenderBoundingBox::Rectangle(bounds),
None => RenderBoundingBox::None,
}
}
}

View File

@@ -280,6 +280,21 @@ fn flatten_vector(graphic_table: &Table<Graphic>) -> Table<Vector> {
unioned.into_iter().collect::<Vec<_>>()
}
Graphic::Color(color) => color
.into_iter()
.map(|row| {
let mut element = Vector::default();
element.style.set_fill(Fill::Solid(row.element));
element.style.set_stroke_transform(DAffine2::IDENTITY);
TableRow {
element,
transform: row.transform,
alpha_blending: row.alpha_blending,
source_node_id: row.source_node_id,
}
})
.collect::<Vec<_>>(),
}
})
.collect()

View File

@@ -193,6 +193,7 @@ tagged_value! {
#[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::artboard::migrate_artboard"))] // TODO: Eventually remove this migration document upgrade code
#[serde(alias = "ArtboardGroup")]
Artboard(Table<Artboard>),
ColorTable(Table<Color>), // TODO: Rename to Color
// ============
// STRUCT TYPES
// ============

View File

@@ -8,6 +8,7 @@ use graphene_core::math::bbox::Bbox;
use graphene_core::raster::image::Image;
use graphene_core::raster_types::{CPU, Raster};
use graphene_core::table::Table;
#[cfg(target_family = "wasm")]
use graphene_core::transform::Footprint;
use graphene_core::vector::Vector;
use graphene_core::{Color, Context, Ctx, ExtractFootprint, Graphic, OwnedContextImpl, WasmNotSend};
@@ -137,7 +138,9 @@ fn decode_image(_: impl Ctx, data: Arc<[u8]>) -> Table<Raster<CPU>> {
Table::new_from_element(Raster::new_cpu(image))
}
fn render_svg(data: impl Render, mut render: SvgRender, render_params: RenderParams, footprint: Footprint) -> RenderOutputType {
fn render_svg(data: impl Render, mut render: SvgRender, render_params: RenderParams) -> RenderOutputType {
let footprint = render_params.footprint;
if !data.contains_artboard() && !render_params.hide_artboards {
render.leaf_tag("rect", |attributes| {
attributes.push("x", "0");
@@ -217,6 +220,7 @@ async fn rasterize<T: WasmNotSend + 'n>(
Table<Vector>,
Table<Raster<CPU>>,
Table<Graphic>,
Table<Color>,
)]
mut data: Table<T>,
footprint: Footprint,
@@ -237,7 +241,7 @@ where
let size = aabb.size();
let resolution = footprint.resolution;
let render_params = RenderParams {
culling_bounds: None,
footprint,
for_export: true,
..Default::default()
};
@@ -282,11 +286,11 @@ async fn render<'a: 'n, T: 'n + Render + WasmNotSend>(
render_config: RenderConfig,
editor_api: impl Node<Context<'static>, Output = &'a WasmEditorApi>,
#[implementations(
Context -> Table<Artboard>,
Context -> Table<Graphic>,
Context -> Table<Vector>,
Context -> Table<Raster<CPU>>,
Context -> Table<Graphic>,
Context -> Table<Artboard>,
Context -> Artboard,
Context -> Table<Color>,
Context -> Option<Color>,
Context -> Vec<Color>,
Context -> bool,
@@ -308,7 +312,7 @@ async fn render<'a: 'n, T: 'n + Render + WasmNotSend>(
let RenderConfig { hide_artboards, for_export, .. } = render_config;
let render_params = RenderParams {
view_mode: render_config.view_mode,
culling_bounds: None,
footprint,
thumbnail: false,
hide_artboards,
for_export,
@@ -333,7 +337,7 @@ async fn render<'a: 'n, T: 'n + Render + WasmNotSend>(
let output_format = render_config.export_format;
let data = match output_format {
ExportFormat::Svg => render_svg(data, SvgRender::new(), render_params, footprint),
ExportFormat::Svg => render_svg(data, SvgRender::new(), render_params),
ExportFormat::Canvas => {
if use_vello && editor_api.application_io.as_ref().unwrap().gpu_executor().is_some() {
#[cfg(all(feature = "vello", not(test)))]
@@ -342,9 +346,9 @@ async fn render<'a: 'n, T: 'n + Render + WasmNotSend>(
metadata,
};
#[cfg(any(not(feature = "vello"), test))]
render_svg(data, SvgRender::new(), render_params, footprint)
render_svg(data, SvgRender::new(), render_params)
} else {
render_svg(data, SvgRender::new(), render_params, footprint)
render_svg(data, SvgRender::new(), render_params)
}
}
_ => todo!("Non-SVG render output for {output_format:?}"),

View File

@@ -5,8 +5,10 @@ use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use graphene_core::blending::BlendMode;
use graphene_core::bounds::BoundingBox;
use graphene_core::bounds::RenderBoundingBox;
use graphene_core::color::Color;
use graphene_core::math::quad::Quad;
use graphene_core::raster::BitmapMut;
use graphene_core::raster::Image;
use graphene_core::raster_types::{CPU, GPU, Raster};
use graphene_core::render_complexity::RenderComplexity;
@@ -155,7 +157,7 @@ pub struct RenderContext {
#[derive(Default)]
pub struct RenderParams {
pub view_mode: ViewMode,
pub culling_bounds: Option<[DVec2; 2]>,
pub footprint: Footprint,
pub thumbnail: bool,
/// Don't render the rectangle for an artboard to allow exporting with a transparent background.
pub hide_artboards: bool,
@@ -301,13 +303,13 @@ impl Render for Table<Graphic> {
ViewMode::Outline => peniko::Mix::Normal,
_ => alpha_blending.blend_mode.to_peniko(),
};
let mut bounds = None;
let mut bounds = RenderBoundingBox::None;
let opacity = row.alpha_blending.opacity(render_params.for_mask);
if opacity < 1. || (render_params.view_mode != ViewMode::Outline && alpha_blending.blend_mode != BlendMode::default()) {
bounds = row.element.bounding_box(transform, true);
if let Some(bounds) = bounds {
if let RenderBoundingBox::Rectangle(bounds) = bounds {
scene.push_layer(
peniko::BlendMode::new(blend_mode, peniko::Compose::SrcOver),
opacity,
@@ -331,7 +333,7 @@ impl Render for Table<Graphic> {
bounds = row.element.bounding_box(transform, true);
}
if let Some(bounds) = bounds {
if let RenderBoundingBox::Rectangle(bounds) = bounds {
let rect = kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y);
scene.push_layer(peniko::Mix::Normal, 1., kurbo::Affine::IDENTITY, &rect);
@@ -341,7 +343,7 @@ impl Render for Table<Graphic> {
row.element.render_to_vello(scene, transform, context, render_params);
if bounds.is_some() {
if matches!(bounds, RenderBoundingBox::Rectangle(_)) {
scene.pop_layer();
scene.pop_layer();
}
@@ -956,7 +958,9 @@ impl Render for Table<Raster<CPU>> {
state.finish()
});
if !render.image_data.iter().any(|(old_id, _)| *old_id == id) {
render.image_data.push((id, image.data().clone()));
let mut image = image.data().clone();
image.map_pixels(|p| p.to_unassociated_alpha());
render.image_data.push((id, image));
}
render.parent_tag(
"foreignObject",
@@ -1043,7 +1047,7 @@ impl Render for Table<Raster<CPU>> {
let mut layer = false;
if opacity < 1. || alpha_blending.blend_mode != BlendMode::default() {
if let Some(bounds) = self.bounding_box(transform, false) {
if let RenderBoundingBox::Rectangle(bounds) = self.bounding_box(transform, false) {
let blending = peniko::BlendMode::new(blend_mode, peniko::Compose::SrcOver);
let rect = kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y);
scene.push_layer(blending, opacity, kurbo::Affine::IDENTITY, &rect);
@@ -1095,7 +1099,7 @@ impl Render for Table<Raster<GPU>> {
let blend_mode = *row.alpha_blending;
let mut layer = false;
if blend_mode != Default::default() {
if let Some(bounds) = self.bounding_box(transform, true) {
if let RenderBoundingBox::Rectangle(bounds) = self.bounding_box(transform, true) {
let blending = peniko::BlendMode::new(blend_mode.blend_mode.to_peniko(), peniko::Compose::SrcOver);
let rect = kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y);
scene.push_layer(blending, blend_mode.opacity, kurbo::Affine::IDENTITY, &rect);
@@ -1145,6 +1149,7 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.render_svg(render, render_params),
Graphic::RasterCPU(raster) => raster.render_svg(render, render_params),
Graphic::RasterGPU(_) => (),
Graphic::Color(color) => color.render_svg(render, render_params),
}
}
@@ -1155,6 +1160,7 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.render_to_vello(scene, transform, context, render_params),
Graphic::RasterCPU(raster) => raster.render_to_vello(scene, transform, context, render_params),
Graphic::RasterGPU(raster) => raster.render_to_vello(scene, transform, context, render_params),
Graphic::Color(color) => color.render_to_vello(scene, transform, context, render_params),
}
}
@@ -1172,20 +1178,28 @@ impl Render for Graphic {
metadata.local_transforms.insert(element_id, *vector.transform);
}
}
Graphic::RasterCPU(raster_frame) => {
Graphic::RasterCPU(raster) => {
metadata.upstream_footprints.insert(element_id, footprint);
// TODO: Find a way to handle more than one row of images
if let Some(image) = raster_frame.iter().next() {
metadata.local_transforms.insert(element_id, *image.transform);
if let Some(raster) = raster.iter().next() {
metadata.local_transforms.insert(element_id, *raster.transform);
}
}
Graphic::RasterGPU(raster_frame) => {
Graphic::RasterGPU(raster) => {
metadata.upstream_footprints.insert(element_id, footprint);
// TODO: Find a way to handle more than one row of images
if let Some(image) = raster_frame.iter().next() {
metadata.local_transforms.insert(element_id, *image.transform);
if let Some(raster) = raster.iter().next() {
metadata.local_transforms.insert(element_id, *raster.transform);
}
}
Graphic::Color(color) => {
metadata.upstream_footprints.insert(element_id, footprint);
// TODO: Find a way to handle more than one row of images
if let Some(color) = color.iter().next() {
metadata.local_transforms.insert(element_id, *color.transform);
}
}
}
@@ -1196,6 +1210,7 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.collect_metadata(metadata, footprint, element_id),
Graphic::RasterCPU(raster) => raster.collect_metadata(metadata, footprint, element_id),
Graphic::RasterGPU(raster) => raster.collect_metadata(metadata, footprint, element_id),
Graphic::Color(color) => color.collect_metadata(metadata, footprint, element_id),
}
}
@@ -1205,6 +1220,7 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.add_upstream_click_targets(click_targets),
Graphic::RasterCPU(raster) => raster.add_upstream_click_targets(click_targets),
Graphic::RasterGPU(raster) => raster.add_upstream_click_targets(click_targets),
Graphic::Color(color) => color.add_upstream_click_targets(click_targets),
}
}
@@ -1214,6 +1230,7 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.contains_artboard(),
Graphic::RasterCPU(raster) => raster.contains_artboard(),
Graphic::RasterGPU(raster) => raster.contains_artboard(),
Graphic::Color(color) => color.contains_artboard(),
}
}
@@ -1223,6 +1240,71 @@ impl Render for Graphic {
Graphic::Vector(vector) => vector.new_ids_from_hash(reference),
Graphic::RasterCPU(_) => (),
Graphic::RasterGPU(_) => (),
Graphic::Color(_) => (),
}
}
}
impl Render for Table<Color> {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
for row in self.iter() {
render.leaf_tag("rect", |attributes| {
attributes.push("width", render_params.footprint.resolution.x.to_string());
attributes.push("height", render_params.footprint.resolution.y.to_string());
let matrix = format_transform_matrix(render_params.footprint.transform.inverse());
if !matrix.is_empty() {
attributes.push("transform", matrix);
}
let color = row.element;
attributes.push("fill", format!("#{}", color.to_rgb_hex_srgb_from_gamma()));
if color.a() < 1. {
attributes.push("fill-opacity", ((color.a() * 1000.).round() / 1000.).to_string());
}
let opacity = row.alpha_blending.opacity(render_params.for_mask);
if opacity < 1. {
attributes.push("opacity", opacity.to_string());
}
if row.alpha_blending.blend_mode != BlendMode::default() {
attributes.push("style", row.alpha_blending.blend_mode.render());
}
});
}
}
#[cfg(feature = "vello")]
fn render_to_vello(&self, scene: &mut Scene, parent_transform: DAffine2, _context: &mut RenderContext, render_params: &RenderParams) {
use vello::peniko;
for row in self.iter() {
let alpha_blending = *row.alpha_blending;
let blend_mode = alpha_blending.blend_mode.to_peniko();
let opacity = alpha_blending.opacity(render_params.for_mask);
let transform = parent_transform * render_params.footprint.transform.inverse();
let color = row.element;
let vello_color = peniko::Color::new([color.r(), color.g(), color.b(), color.a()]);
let rect = kurbo::Rect::from_origin_size(
kurbo::Point::ZERO,
kurbo::Size::new(render_params.footprint.resolution.x as f64, render_params.footprint.resolution.y as f64),
);
let mut layer = false;
if opacity < 1. || alpha_blending.blend_mode != BlendMode::default() {
let blending = peniko::BlendMode::new(blend_mode, peniko::Compose::SrcOver);
scene.push_layer(blending, opacity, kurbo::Affine::IDENTITY, &rect);
layer = true;
}
scene.fill(peniko::Fill::NonZero, kurbo::Affine::new(transform.to_cols_array()), vello_color, None, &rect);
if layer {
scene.pop_layer();
}
}
}
}
@@ -1251,27 +1333,50 @@ impl<P: Primitive> Render for P {
}
impl Render for Option<Color> {
fn render_svg(&self, render: &mut SvgRender, _render_params: &RenderParams) {
let Some(color) = self else {
render.parent_tag("text", |_| {}, |render| render.leaf_node("Empty color"));
return;
};
let color_info = format!("{:?} #{} {:?}", color, color.to_rgba_hex_srgb(), color.to_rgba8_srgb());
render.leaf_tag("rect", |attributes| {
attributes.push("width", "100");
attributes.push("height", "100");
attributes.push("y", "40");
attributes.push("fill", format!("#{}", color.to_rgb_hex_srgb_from_gamma()));
if color.a() < 1. {
attributes.push("fill-opacity", ((color.a() * 1000.).round() / 1000.).to_string());
}
});
render.parent_tag("text", text_attributes, |render| render.leaf_node(color_info))
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
if let Some(color) = self {
color.render_svg(render, render_params);
}
}
#[cfg(feature = "vello")]
fn render_to_vello(&self, _scene: &mut Scene, _transform: DAffine2, _context: &mut RenderContext, _render_params: &RenderParams) {}
fn render_to_vello(&self, scene: &mut Scene, parent_transform: DAffine2, _context: &mut RenderContext, render_params: &RenderParams) {
if let Some(color) = self {
color.render_to_vello(scene, parent_transform, _context, render_params);
}
}
}
impl Render for Color {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
render.leaf_tag("rect", |attributes| {
attributes.push("width", render_params.footprint.resolution.x.to_string());
attributes.push("height", render_params.footprint.resolution.y.to_string());
let matrix = format_transform_matrix(render_params.footprint.transform.inverse());
if !matrix.is_empty() {
attributes.push("transform", matrix);
}
attributes.push("fill", format!("#{}", self.to_rgb_hex_srgb_from_gamma()));
if self.a() < 1. {
attributes.push("fill-opacity", ((self.a() * 1000.).round() / 1000.).to_string());
}
});
}
#[cfg(feature = "vello")]
fn render_to_vello(&self, scene: &mut Scene, parent_transform: DAffine2, _context: &mut RenderContext, render_params: &RenderParams) {
let transform = parent_transform * render_params.footprint.transform.inverse();
let vello_color = peniko::Color::new([self.r(), self.g(), self.b(), self.a()]);
let rect = kurbo::Rect::from_origin_size(
kurbo::Point::ZERO,
kurbo::Size::new(render_params.footprint.resolution.x as f64, render_params.footprint.resolution.y as f64),
);
scene.fill(peniko::Fill::NonZero, kurbo::Affine::new(transform.to_cols_array()), vello_color, None, &rect);
}
}
impl Render for Vec<Color> {

View File

@@ -56,6 +56,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]),
#[cfg(feature = "gpu")]
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<GPU>>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Table<Color>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Color]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Option<Color>]),
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => String]),
@@ -86,10 +87,12 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
// ==========
// MEMO NODES
// ==========
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Image<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Artboard>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Graphic>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Vector>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Graphic>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Table<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Image<Color>]),
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Vec<DVec2>]),
#[cfg(feature = "gpu")]
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Arc<WasmSurfaceHandle>]),
@@ -113,6 +116,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<CPU>>]),
#[cfg(feature = "gpu")]
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Table<Raster<GPU>>]),
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Table<Color>]),
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => WgpuSurface]),
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Option<WgpuSurface>]),
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),