mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Update GPU execution and quantization to new node system (#1070)
* Update GPU and quantization to new node system Squashed commit of the following: commit 3b69bdafed79f0bb1279609537a8eeead3f06830 Author: Dennis Kobert <dennis@kobert.dev> Date: Sun Mar 5 11:37:17 2023 +0100 Disable dev tools by default commit dbbbedd68e48d1162442574ad8877c9922d40e4a Merge: b1018eb5 a8f6e11e Author: Dennis Kobert <dennis@kobert.dev> Date: Sun Mar 5 10:45:00 2023 +0100 Merge branch 'vite' into tauri-restructure-lite commit b1018eb5ee56c2d23f9d5a4f034608ec684bd746 Merge: 3195833e0512cb24
Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 17:06:21 2023 +0100 Merge branch 'master' into tauri-restructure-lite commit 3195833e4088a4ed7984955c72617b27b7e39bfc Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 17:06:02 2023 +0100 Bump number of samples commit 3e57e1e3280759cf4f75726635e31d2b8e9387f9 Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 16:55:52 2023 +0100 Move part of quantization code to gcore commit 10c15b0bc6ffb51e2bf2d94cd4eb0e24d761fb6f Merge: 2b3db45a8fe8896c
Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 14:28:56 2023 +0100 Merge remote-tracking branch 'origin/master' into tauri-restructure-lite commit 2b3db45aee44a20660f0b1204666bb81e5a7e4b6 Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 14:17:11 2023 +0100 Fix types in node registry commit 9122f35c0ba9a86255709680d744a48d3c7dcac4 Merge: 26eefc432cf4ee0f
Author: Dennis Kobert <dennis@kobert.dev> Date: Fri Mar 3 01:04:55 2023 +0100 Merge remote-tracking branch 'origin/master' into tauri-restructure-lite commit 26eefc437eaad873f8d38fdb1fae0a1e3ec189e4 Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Mar 2 23:05:53 2023 +0100 Add Quantize node to document_node_types commit 3f7606a91329200b2c025010d4a0cffee840a11c Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Mar 2 17:47:51 2023 +0100 Add quantization nodes to node registry commit 22d8e477ef79eef5b57b1dc9805e41bbf81cae43 Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Mar 2 17:13:28 2023 +0100 Introduce scopes (#1053) * Implement let binding * Add lambda inputs * Fix tests * Fix proto network formatting * Generate a template Scoped network by default * Add comment to explain the lambda parameter * Move binding wrapping out of the template * Fix errors cause by image frames commit 9e0c29d92a164d4a4063e93480e1e289ef5243fe Author: Alexandru Ică <alexandru@seyhanlee.com> Date: Thu Mar 2 15:55:10 2023 +0200 Make use of ImageFrame in the node system more extensively (#1055) (#1062) Make the node system use ImageFrame more extensively (#1055) commit 5912ef9a1a807917eeb90c1f4835bd8a5de9c821 Author: Dennis Kobert <dennis@kobert.dev> Date: Wed Mar 1 16:15:21 2023 +0100 Split quantization into multiple nodes commit 285d7b76c176b3e2679ea24eecb38ef867a79f3b Author: Dennis Kobert <dennis@kobert.dev> Date: Mon Feb 27 12:35:57 2023 +0100 Fix gpu support commit e0b6327eebba8caf7545c4fedc6670abc4c3652e Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Feb 16 22:08:53 2023 +0100 Don't watch frontend files when using tauri commit 58ae146f6da935cfd37afbd25e1c331b615252da Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Feb 16 21:48:54 2023 +0100 Migrate vue code base to vite commit f996390cc312618a60f98ccb9cd515f1bae5006d Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Feb 16 19:34:33 2023 +0100 Start migrating vue to use vite commit 29d752f47cfd1c74ee51fac6f3d75557a378471c Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Feb 16 19:00:53 2023 +0100 Kill cargo watch process automatically commit 4d1c76b07acadbf609dbab7d57d9a7769b81d4b5 Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Feb 16 17:37:27 2023 +0100 Start playing around with vite infrastructure commit 8494f5e9227aa433fd5ca75b268a6a96b2706b36 Author: Locria Cyber <74560659+locriacyber@users.noreply.github.com> Date: Thu Jan 19 18:40:46 2023 +0000 Fix import style and eslint rules commit 92490f7774a7351bb40091bcec78f79c28704768 Author: Locria Cyber <74560659+locriacyber@users.noreply.github.com> Date: Thu Jan 19 18:25:09 2023 +0000 Fix icons commit dc67821abad87f8ff780b12ae96668af2f7bb355 Author: Locria Cyber <74560659+locriacyber@users.noreply.github.com> Date: Thu Jan 19 18:20:48 2023 +0000 Add license generator with rollup commit 441e339d31b76dac4f91321d39a39900b5a79bc1 Author: Locria Cyber <74560659+locriacyber@users.noreply.github.com> Date: Thu Jan 19 18:14:22 2023 +0000 Use eslint --fix to fix TS-in-svelte type imports. Now it compiles. commit 2e847d339e7dcd51ed4c4677ed337c1e20636724 Author: Locria Cyber <74560659+locriacyber@users.noreply.github.com> Date: Thu Jan 19 17:31:49 2023 +0000 Remove webpack and plugins commit 3adab1b7f40ff17b91163e7ca47a403ef3c02fbc Author: Dennis Kobert <dennis@kobert.dev> Date: Thu Mar 2 16:10:19 2023 +0100 Fix errors cause by image frames commit 4e5f838995e213b4696225a473b9c56c0084e7a8 Author: Alexandru Ică <alexandru@seyhanlee.com> Date: Thu Mar 2 15:55:10 2023 +0200 Make use of ImageFrame in the node system more extensively (#1055) (#1062) Make the node system use ImageFrame more extensively (#1055) commit 1d4b0e29c693a53c068f1a30f0e857a9c1a59587 Author: Dennis Kobert <dennis@kobert.dev> Date: Wed Mar 1 15:13:51 2023 +0100 Update node graph guide readme with new syntax (#1061) commit 6735d8c61f5709e22d2b22abd037bab417e868d6 Author: Rob Nadal <Robnadal44@gmail.com> Date: Tue Feb 28 18:59:06 2023 -0500 Bezier-rs: Add function to smoothly join bezier curves (#1037) * Added bezier join * Stylistic changes per review commit cd1d7aa7fbcce39fbbf7762d131ee16ad9cb46dd Author: Dennis Kobert <dennis@kobert.dev> Date: Wed Feb 22 23:42:32 2023 +0100 Implement let binding Add lambda inputs Fix tests Fix proto network formatting Generate a template Scoped network by default Add comment to explain the lambda parameter Move binding wrapping out of the template * Update package-lock.json * Regenerate package-lock.json and fix lint errors * Readd git keep dir * Revert change to panic.ts * Fix clippy warnings * Apply code review * Clean up node_registry * Fix test / spriv -> spirv typos
This commit is contained in:
parent
4ea3802df1
commit
b55e233fff
38 changed files with 2282 additions and 1924 deletions
|
@ -158,6 +158,6 @@ mod tests {
|
|||
let compiler = Compiler {};
|
||||
let protograph = compiler.compile_single(network, true).expect("Graph should be generated");
|
||||
|
||||
let exec = DynamicExecutor::new(protograph).map(|e| panic!("The network should not type check: {:#?}", e)).unwrap_err();
|
||||
let _exec = DynamicExecutor::new(protograph).map(|e| panic!("The network should not type check: {:#?}", e)).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ use crate::executor::NodeContainer;
|
|||
|
||||
use dyn_any::StaticType;
|
||||
|
||||
use graphene_core::quantization::QuantizationChannels;
|
||||
|
||||
macro_rules! construct_node {
|
||||
($args: ident, $path:ty, [$($type:tt),*]) => {{
|
||||
let mut args: Vec<TypeErasedPinnedRef<'static>> = $args.clone();
|
||||
|
@ -133,6 +135,8 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
register_node!(graphene_core::ops::AddParameterNode<_>, input: f64, params: [&f64]),
|
||||
register_node!(graphene_core::ops::AddParameterNode<_>, input: &f64, params: [&f64]),
|
||||
register_node!(graphene_core::ops::SomeNode, input: ImageFrame, params: []),
|
||||
#[cfg(feature = "gpu")]
|
||||
register_node!(graphene_std::executor::MapGpuSingleImageNode<_>, input: Image, params: [String]),
|
||||
vec![(
|
||||
NodeIdentifier::new("graphene_core::structural::ComposeNode<_, _, _>"),
|
||||
|args| {
|
||||
|
@ -292,9 +296,23 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
},
|
||||
NodeIOTypes::new(concrete!(Image), concrete!(&Image), vec![]),
|
||||
),
|
||||
(
|
||||
NodeIdentifier::new("graphene_std::memo::CacheNode"),
|
||||
|_| {
|
||||
let node: CacheNode<QuantizationChannels> = graphene_std::memo::CacheNode::new();
|
||||
let any = DynAnyRefNode::new(node);
|
||||
any.into_type_erased()
|
||||
},
|
||||
NodeIOTypes::new(concrete!(QuantizationChannels), concrete!(&QuantizationChannels), vec![]),
|
||||
),
|
||||
],
|
||||
register_node!(graphene_core::structural::ConsNode<_, _>, input: Image, params: [&str]),
|
||||
register_node!(graphene_std::raster::ImageFrameNode<_>, input: Image, params: [DAffine2]),
|
||||
#[cfg(feature = "quantization")]
|
||||
register_node!(graphene_std::quantization::GenerateQuantizationNode<_, _>, input: ImageFrame, params: [u32, u32]),
|
||||
raster_node!(graphene_core::quantization::QuantizeNode<_>, params: [QuantizationChannels]),
|
||||
raster_node!(graphene_core::quantization::DeQuantizeNode<_>, params: [QuantizationChannels]),
|
||||
register_node!(graphene_core::ops::CloneNode<_>, input: &QuantizationChannels, params: []),
|
||||
register_node!(graphene_core::vector::TransformNode<_, _, _, _>, input: VectorData, params: [DVec2, f64, DVec2, DVec2]),
|
||||
register_node!(graphene_core::vector::SetFillNode<_, _, _, _, _, _, _>, input: VectorData, params: [ graphene_core::vector::style::FillType, graphene_core::Color, graphene_core::vector::style::GradientType, DVec2, DVec2, DAffine2, Vec<(f64, Option<graphene_core::Color>)>]),
|
||||
register_node!(graphene_core::vector::SetStrokeNode<_, _, _, _, _, _, _>, input: VectorData, params: [graphene_core::Color, f64, Vec<f32>, f64, graphene_core::vector::style::LineCap, graphene_core::vector::style::LineJoin, f64]),
|
||||
|
@ -304,158 +322,6 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
input: graphene_core::vector::bezier_rs::Subpath<graphene_core::uuid::ManipulatorGroupId>,
|
||||
params: []
|
||||
),
|
||||
/*
|
||||
(NodeIdentifier::new("graphene_std::raster::ImageNode", &[concrete!("&str")]), |_proto_node, stack| {
|
||||
stack.push_fn(|_nodes| {
|
||||
let image = FnNode::new(|s: &str| graphene_std::raster::image_node::<&str>().eval(s).unwrap());
|
||||
let node: DynAnyNode<_, &str, _, _> = DynAnyNode::new(image);
|
||||
node.into_type_erased()
|
||||
})
|
||||
}),
|
||||
(NodeIdentifier::new("graphene_std::raster::ExportImageNode", &[concrete!("&str")]), |proto_node, stack| {
|
||||
stack.push_fn(|nodes| {
|
||||
let pre_node = nodes.get(proto_node.input.unwrap_node() as usize).unwrap();
|
||||
|
||||
let image = FnNode::new(|input: (Image, &str)| graphene_std::raster::export_image_node().eval(input).unwrap());
|
||||
let node: DynAnyNode<_, (Image, &str), _, _> = DynAnyNode::new(image);
|
||||
let node = (pre_node).then(node);
|
||||
node.into_type_erased()
|
||||
})
|
||||
}),
|
||||
(
|
||||
NodeIdentifier::new("graphene_core::structural::ConsNode", &[concrete!("Image"), concrete!("&str")]),
|
||||
|proto_node, stack| {
|
||||
let node_id = proto_node.input.unwrap_node() as usize;
|
||||
if let ConstructionArgs::Nodes(cons_node_arg) = proto_node.construction_args {
|
||||
stack.push_fn(move |nodes| {
|
||||
let pre_node = nodes.get(node_id).unwrap();
|
||||
let cons_node_arg = nodes.get(cons_node_arg[0] as usize).unwrap();
|
||||
|
||||
let cons_node = ConsNode::new(DowncastNode::<_, &str>::new(cons_node_arg));
|
||||
let node: DynAnyNode<_, Image, _, _> = DynAnyNode::new(cons_node);
|
||||
let node = (pre_node).then(node);
|
||||
node.into_type_erased()
|
||||
})
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
},
|
||||
),
|
||||
(NodeIdentifier::new("graphene_std::vector::generator_nodes::UnitCircleGenerator", &[]), |_proto_node, stack| {
|
||||
stack.push_fn(|_nodes| DynAnyNode::new(graphene_std::vector::generator_nodes::UnitCircleGenerator).into_type_erased())
|
||||
}),
|
||||
(NodeIdentifier::new("graphene_std::vector::generator_nodes::UnitSquareGenerator", &[]), |_proto_node, stack| {
|
||||
stack.push_fn(|_nodes| DynAnyNode::new(graphene_std::vector::generator_nodes::UnitSquareGenerator).into_type_erased())
|
||||
}),
|
||||
(NodeIdentifier::new("graphene_std::vector::generator_nodes::BlitSubpath", &[]), |proto_node, stack| {
|
||||
stack.push_fn(move |nodes| {
|
||||
let ConstructionArgs::Nodes(construction_nodes) = proto_node.construction_args else { unreachable!("BlitSubpath without subpath input") };
|
||||
let value_node = nodes.get(construction_nodes[0] as usize).unwrap();
|
||||
let input_node: DowncastBothNode<_, (), Subpath> = DowncastBothNode::new(value_node);
|
||||
let node = DynAnyNode::new(graphene_std::vector::generator_nodes::BlitSubpath::new(input_node));
|
||||
|
||||
if let ProtoNodeInput::Node(node_id) = proto_node.input {
|
||||
let pre_node = nodes.get(node_id as usize).unwrap();
|
||||
(pre_node).then(node).into_type_erased()
|
||||
} else {
|
||||
node.into_type_erased()
|
||||
}
|
||||
})
|
||||
}),
|
||||
(NodeIdentifier::new("graphene_std::vector::generator_nodes::TransformSubpathNode", &[]), |proto_node, stack| {
|
||||
stack.push_fn(move |nodes| {
|
||||
let ConstructionArgs::Nodes(construction_nodes) = proto_node.construction_args else { unreachable!("TransformSubpathNode without subpath input") };
|
||||
let translate_node: DowncastBothNode<_, (), DVec2> = DowncastBothNode::new(nodes.get(construction_nodes[0] as usize).unwrap());
|
||||
let rotate_node: DowncastBothNode<_, (), f64> = DowncastBothNode::new(nodes.get(construction_nodes[1] as usize).unwrap());
|
||||
let scale_node: DowncastBothNode<_, (), DVec2> = DowncastBothNode::new(nodes.get(construction_nodes[2] as usize).unwrap());
|
||||
let shear_node: DowncastBothNode<_, (), DVec2> = DowncastBothNode::new(nodes.get(construction_nodes[3] as usize).unwrap());
|
||||
|
||||
let node = DynAnyNode::new(graphene_std::vector::generator_nodes::TransformSubpathNode::new(translate_node, rotate_node, scale_node, shear_node));
|
||||
|
||||
if let ProtoNodeInput::Node(node_id) = proto_node.input {
|
||||
let pre_node = nodes.get(node_id as usize).unwrap();
|
||||
(pre_node).then(node).into_type_erased()
|
||||
} else {
|
||||
node.into_type_erased()
|
||||
}
|
||||
})
|
||||
}),
|
||||
#[cfg(feature = "gpu")]
|
||||
(
|
||||
NodeIdentifier::new("graphene_std::executor::MapGpuNode", &[concrete!("&TypeErasedNode"), concrete!("Color"), concrete!("Color")]),
|
||||
|proto_node, stack| {
|
||||
if let ConstructionArgs::Nodes(operation_node_id) = proto_node.construction_args {
|
||||
stack.push_fn(move |nodes| {
|
||||
info!("Map image Depending upon id {:?}", operation_node_id);
|
||||
let operation_node = nodes.get(operation_node_id[0] as usize).unwrap();
|
||||
let input_node: DowncastBothNode<_, (), &graph_craft::document::NodeNetwork> = DowncastBothNode::new(operation_node);
|
||||
let map_node: graphene_std::executor::MapGpuNode<_, Vec<u32>, u32, u32> = graphene_std::executor::MapGpuNode::new(input_node);
|
||||
let map_node = DynAnyNode::new(map_node);
|
||||
|
||||
if let ProtoNodeInput::Node(node_id) = proto_node.input {
|
||||
let pre_node = nodes.get(node_id as usize).unwrap();
|
||||
(pre_node).then(map_node).into_type_erased()
|
||||
} else {
|
||||
map_node.into_type_erased()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
},
|
||||
),
|
||||
#[cfg(feature = "gpu")]
|
||||
(
|
||||
NodeIdentifier::new("graphene_std::executor::MapGpuSingleImageNode", &[concrete!("&TypeErasedNode")]),
|
||||
|proto_node, stack| {
|
||||
if let ConstructionArgs::Nodes(operation_node_id) = proto_node.construction_args {
|
||||
stack.push_fn(move |nodes| {
|
||||
info!("Map image Depending upon id {:?}", operation_node_id);
|
||||
let operation_node = nodes.get(operation_node_id[0] as usize).unwrap();
|
||||
let input_node: DowncastBothNode<_, (), String> = DowncastBothNode::new(operation_node);
|
||||
let map_node = graphene_std::executor::MapGpuSingleImageNode(input_node);
|
||||
let map_node = DynAnyNode::new(map_node);
|
||||
|
||||
if let ProtoNodeInput::Node(node_id) = proto_node.input {
|
||||
let pre_node = nodes.get(node_id as usize).unwrap();
|
||||
(pre_node).then(map_node).into_type_erased()
|
||||
} else {
|
||||
map_node.into_type_erased()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
},
|
||||
),
|
||||
#[cfg(feature = "quantization")]
|
||||
(
|
||||
NodeIdentifier::new("graphene_std::quantization::GenerateQuantizationNode", &[concrete!("&TypeErasedNode")]),
|
||||
|proto_node, stack| {
|
||||
if let ConstructionArgs::Nodes(operation_node_id) = proto_node.construction_args {
|
||||
stack.push_fn(move |nodes| {
|
||||
info!("Quantization Depending upon id {:?}", operation_node_id);
|
||||
let samples_node = nodes.get(operation_node_id[0] as usize).unwrap();
|
||||
let index_node = nodes.get(operation_node_id[1] as usize).unwrap();
|
||||
let samples_node: DowncastBothNode<_, (), u32> = DowncastBothNode::new(samples_node);
|
||||
let index_node: DowncastBothNode<_, (), u32> = DowncastBothNode::new(index_node);
|
||||
let map_node = graphene_std::quantization::GenerateQuantizationNode::new(samples_node, index_node);
|
||||
let map_node = DynAnyNode::new(map_node);
|
||||
|
||||
if let ProtoNodeInput::Node(node_id) = proto_node.input {
|
||||
let pre_node = nodes.get(node_id as usize).unwrap();
|
||||
(pre_node).then(map_node).into_type_erased()
|
||||
} else {
|
||||
map_node.into_type_erased()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
},
|
||||
),
|
||||
<<<<<<< HEAD
|
||||
*/
|
||||
];
|
||||
let mut map: HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> = HashMap::new();
|
||||
for (id, c, types) in node_types.into_iter().flatten() {
|
||||
|
@ -466,101 +332,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
|
||||
pub static NODE_REGISTRY: Lazy<HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>> = Lazy::new(|| node_registry());
|
||||
|
||||
/*
|
||||
#[cfg(test)]
|
||||
mod protograph_testing {
|
||||
use borrow_stack::BorrowStack;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn add_values() {
|
||||
let stack = FixedSizeStack::new(256);
|
||||
let val_1_protonode = ProtoNode::value(ConstructionArgs::Value(Box::new(2u32)));
|
||||
constrcut_node(val_1_protonode, &stack);
|
||||
|
||||
let val_2_protonode = ProtoNode::value(ConstructionArgs::Value(Box::new(40u32)));
|
||||
constrcut_node(val_2_protonode, &stack);
|
||||
|
||||
let cons_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![1]),
|
||||
input: ProtoNodeInput::Node(0),
|
||||
identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[concrete!("u32"), concrete!("u32")]),
|
||||
};
|
||||
constrcut_node(cons_protonode, &stack);
|
||||
|
||||
let add_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||
input: ProtoNodeInput::Node(2),
|
||||
identifier: NodeIdentifier::new("graphene_core::ops::AddNode", &[concrete!("u32"), concrete!("u32")]),
|
||||
};
|
||||
constrcut_node(add_protonode, &stack);
|
||||
|
||||
let result = unsafe { stack.get()[3].eval(Box::new(())) };
|
||||
let val = *dyn_any::downcast::<u32>(result).unwrap();
|
||||
assert_eq!(val, 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grayscale_color() {
|
||||
let stack = FixedSizeStack::new(256);
|
||||
let val_protonode = ProtoNode::value(ConstructionArgs::Value(Box::new(Color::from_rgb8(10, 20, 30))));
|
||||
constrcut_node(val_protonode, &stack);
|
||||
|
||||
let grayscale_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||
input: ProtoNodeInput::Node(0),
|
||||
identifier: NodeIdentifier::new("graphene_core::raster::GrayscaleColorNode", &[]),
|
||||
};
|
||||
constrcut_node(grayscale_protonode, &stack);
|
||||
|
||||
let result = unsafe { stack.get()[1].eval(Box::new(())) };
|
||||
let val = *dyn_any::downcast::<Color>(result).unwrap();
|
||||
assert_eq!(val, Color::from_rgb8(20, 20, 20));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_image() {
|
||||
let stack = FixedSizeStack::new(256);
|
||||
let image_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||
input: ProtoNodeInput::None,
|
||||
identifier: NodeIdentifier::new("graphene_std::raster::ImageNode", &[concrete!("&str")]),
|
||||
};
|
||||
constrcut_node(image_protonode, &stack);
|
||||
|
||||
let result = unsafe { stack.get()[0].eval(Box::new("../gstd/test-image-1.png")) };
|
||||
let image = *dyn_any::downcast::<Image>(result).unwrap();
|
||||
assert_eq!(image.height, 240);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grayscale_map_image() {
|
||||
let stack = FixedSizeStack::new(256);
|
||||
let image_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||
input: ProtoNodeInput::None,
|
||||
identifier: NodeIdentifier::new("graphene_std::raster::ImageNode", &[concrete!("&str")]),
|
||||
};
|
||||
constrcut_node(image_protonode, &stack);
|
||||
|
||||
let grayscale_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||
input: ProtoNodeInput::None,
|
||||
identifier: NodeIdentifier::new("graphene_core::raster::GrayscaleColorNode", &[]),
|
||||
};
|
||||
constrcut_node(grayscale_protonode, &stack);
|
||||
|
||||
let image_map_protonode = ProtoNode {
|
||||
construction_args: ConstructionArgs::Nodes(vec![1]),
|
||||
input: ProtoNodeInput::Node(0),
|
||||
identifier: NodeIdentifier::new("graphene_std::raster::MapImageNode", &[]),
|
||||
};
|
||||
constrcut_node(image_map_protonode, &stack);
|
||||
|
||||
let result = unsafe { stack.get()[2].eval(Box::new("../gstd/test-image-1.png")) };
|
||||
let image = *dyn_any::downcast::<Image>(result).unwrap();
|
||||
assert!(!image.data.iter().any(|c| c.r() != c.b() || c.b() != c.g()));
|
||||
}
|
||||
// TODO: adde tests testing the node registry
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue