mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 15:53:26 -10:00
Remove the obsolete 'Monitor' node and its supporting infrastructure (#4962)
* Remove the obsolete 'Monitor' node and its supporting infrastructure * Make the 'Merge' and 'Artboard' migration test check the rebuilt network
This commit is contained in:
1 parent
cf1f7dec80
commit
7b2715146c
39 files changed
+138
-346
No files matched your search
@@ -1,7 +1,6 @@
|
||||
pub mod node {
|
||||
pub const CALL_ARGUMENT: &str = "call_argument";
|
||||
pub const VISIBLE: &str = "visible";
|
||||
pub const SKIP_DEDUPLICATION: &str = "skip_deduplication";
|
||||
pub const REFLECTION_METADATA: &str = "reflection_metadata";
|
||||
|
||||
pub mod input {
|
||||
|
||||
@@ -382,9 +382,6 @@ fn convert_node<M: NodeMetadataSource + ?Sized>(
|
||||
attributes
|
||||
.set_if_not_default(node::VISIBLE, &doc_node.visible, &true, timestamp)
|
||||
.map_err(map_serialization_error(node::VISIBLE))?;
|
||||
attributes
|
||||
.set_if_not_default(node::SKIP_DEDUPLICATION, &doc_node.skip_deduplication, &false, timestamp)
|
||||
.map_err(map_serialization_error(node::SKIP_DEDUPLICATION))?;
|
||||
|
||||
write_ui_attributes(&mut attributes, ctx.metadata, network, runtime_node_id, timestamp)?;
|
||||
|
||||
|
||||
@@ -260,8 +260,7 @@ fn test_metadata_preservation() {
|
||||
inputs: vec![NodeInput::import(concrete!(f64), 0), NodeInput::import(Type::Generic(Cow::Borrowed("T")), 1)],
|
||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("test::NodeWithMetadata")),
|
||||
call_argument: concrete!(String),
|
||||
visible: false, // Non-default value
|
||||
skip_deduplication: true, // Non-default value
|
||||
visible: false, // Non-default value
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
@@ -296,9 +295,6 @@ fn test_metadata_preservation() {
|
||||
// Verify visible is preserved
|
||||
assert_eq!(orig_node_0.visible, conv_node_0.visible, "visible should be preserved");
|
||||
|
||||
// Verify skip_deduplication is preserved
|
||||
assert_eq!(orig_node_0.skip_deduplication, conv_node_0.skip_deduplication, "skip_deduplication should be preserved");
|
||||
|
||||
// Verify import_type is preserved for Import inputs
|
||||
match (&orig_node_0.inputs[0], &conv_node_0.inputs[0]) {
|
||||
(NodeInput::Import { import_type: orig_type, .. }, NodeInput::Import { import_type: conv_type, .. }) => {
|
||||
@@ -354,11 +350,6 @@ fn test_demo_artwork_round_trip() {
|
||||
artwork_name, node_id
|
||||
);
|
||||
assert_eq!(orig_node.visible, conv_node.visible, "{}: visible should be preserved for node {:?}", artwork_name, node_id);
|
||||
assert_eq!(
|
||||
orig_node.skip_deduplication, conv_node.skip_deduplication,
|
||||
"{}: skip_deduplication should be preserved for node {:?}",
|
||||
artwork_name, node_id
|
||||
);
|
||||
|
||||
// Check input count
|
||||
assert_eq!(
|
||||
|
||||
@@ -457,7 +457,6 @@ fn convert_node(context: &ConversionContext, node: &crate::Node) -> Result<Docum
|
||||
call_argument: node.attributes.get_or(node::CALL_ARGUMENT, concrete!(core_types::Context)),
|
||||
implementation: convert_implementation(context, &node.implementation)?,
|
||||
visible: node.attributes.get_or(node::VISIBLE, true),
|
||||
skip_deduplication: node.attributes.get_or(node::SKIP_DEDUPLICATION, false),
|
||||
// Regenerated during compilation; not stored.
|
||||
compile_metadata: None,
|
||||
original_location: Default::default(),
|
||||
|
||||
@@ -4,3 +4,5 @@ use migration_core::rename;
|
||||
|
||||
// Version 2 is where old Upload Texture nodes join the lineage, and stored Passthrough nodes already have its layout
|
||||
rename!("graphene_core::ops::PassthroughNode"@1 => @2);
|
||||
// The removed Monitor node passes its one input on, as a Passthrough does
|
||||
rename!("graphene_core::memo::MonitorNode"@1 => "graphene_core::ops::PassthroughNode"@2);
|
||||
@@ -262,9 +262,6 @@ fn diff_document_node(out: &mut String, expected: &graph_craft::document::Docume
|
||||
if expected.visible != actual.visible {
|
||||
let _ = writeln!(out, " visible: expected={} actual={}", expected.visible, actual.visible);
|
||||
}
|
||||
if expected.skip_deduplication != actual.skip_deduplication {
|
||||
let _ = writeln!(out, " skip_deduplication: expected={} actual={}", expected.skip_deduplication, actual.skip_deduplication);
|
||||
}
|
||||
if expected.compile_metadata != actual.compile_metadata {
|
||||
let _ = writeln!(out, " compile_metadata: expected={:?} actual={:?}", expected.compile_metadata, actual.compile_metadata);
|
||||
}
|
||||
|
||||
@@ -4894,7 +4894,7 @@ mod document_message_handler_tests {
|
||||
}
|
||||
|
||||
// Merging nodes whose output isn't wired downstream produces an encapsulating subnetwork with no exports.
|
||||
// Inspecting it via the Data panel (which splices in a monitor node) must not leave a dangling reference that crashes compilation.
|
||||
// Inspecting it via the Data panel must not leave a dangling reference that crashes compilation.
|
||||
#[tokio::test]
|
||||
async fn merge_selected_nodes_while_inspecting_does_not_crash() {
|
||||
let mut editor = EditorTestUtils::create();
|
||||
@@ -4909,7 +4909,7 @@ mod document_message_handler_tests {
|
||||
let merged = editor.active_document().network_interface.selected_nodes_in_nested_network(&[]).unwrap().0.clone();
|
||||
assert_eq!(merged.len(), 1, "merge should leave one encapsulating node selected");
|
||||
|
||||
// Simulate the Data panel inspecting the merged node, which compiles the graph with a monitor node spliced in
|
||||
// Simulate the Data panel inspecting the merged node
|
||||
let portfolio = &mut editor.editor.dispatcher.message_handlers.portfolio_message_handler;
|
||||
let document_id = portfolio.active_document_id.unwrap();
|
||||
let document = portfolio.documents.get_mut(&document_id).unwrap();
|
||||
|
||||
@@ -802,10 +802,6 @@ fn static_node_inspector() -> NodeInspector {
|
||||
map.insert("grid_inspector".to_string(), Box::new(node_inspector::grid_inspector));
|
||||
map.insert("spiral_inspector".to_string(), Box::new(node_inspector::spiral_inspector));
|
||||
map.insert("sample_polyline_inspector".to_string(), Box::new(node_inspector::sample_polyline_inspector));
|
||||
map.insert(
|
||||
"monitor_inspector".to_string(),
|
||||
Box::new(|_node_id, _context| node_inspector::string_inspector("Used internally by the editor to read the data passing through it.")),
|
||||
);
|
||||
map
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ pub(super) fn post_process_nodes(custom: Vec<DocumentNodeDefinition>) -> HashMap
|
||||
|
||||
// Add the rest of the protonodes from the macro.
|
||||
// Typed nodes are registered in `core_types::NODE_REGISTRY` via the macro's auto-generated `register_node` codegen.
|
||||
// `skip_impl` nodes (e.g. Cache, Monitor) bypass that registration but are wired up manually in
|
||||
// `skip_impl` nodes (e.g. Cache) bypass that registration but are wired up manually in
|
||||
// `interpreted_executor::node_registry::NODE_REGISTRY` via `async_node!`. We consult that extended registry as a
|
||||
// fallback when deriving `call_argument` so it reflects the impls actually registered, which will usually be `Context`.
|
||||
let extended_node_registry = &*interpreted_executor::node_registry::NODE_REGISTRY;
|
||||
|
||||
@@ -1222,7 +1222,6 @@ impl NodeNetworkInterface {
|
||||
node.inputs = old_node.inputs;
|
||||
node.call_argument = old_node.manual_composition.unwrap_or_default();
|
||||
node.visible = old_node.visible;
|
||||
node.skip_deduplication = old_node.skip_deduplication;
|
||||
node.original_location = old_node.original_location;
|
||||
node_metadata.persistent_metadata.display_name = old_node.alias;
|
||||
node_metadata.persistent_metadata.locked = old_node.locked;
|
||||
|
||||
@@ -221,7 +221,7 @@ impl NodeNetworkInterface {
|
||||
return;
|
||||
};
|
||||
|
||||
let deltas = if current.implementation == target.implementation && current.skip_deduplication == target.skip_deduplication {
|
||||
let deltas = if current.implementation == target.implementation {
|
||||
field_deltas(location, local_id, (current, current_metadata), (&target, &target_metadata))
|
||||
} else {
|
||||
vec![
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ static INPUT_CONVERSIONS: Lazy<HashMap<ProtoNodeIdentifier, Vec<Option<&'static
|
||||
.collect()
|
||||
});
|
||||
|
||||
/// Proto nodes whose every implementation returns its one input's type unchanged (like Monitor and Memoize), so a wire through one is constrained by what it feeds.
|
||||
/// Proto nodes whose every implementation returns its one input's type unchanged (like Memoize), so a wire through one is constrained by what it feeds.
|
||||
static TYPE_PRESERVING_NODES: Lazy<HashSet<ProtoNodeIdentifier>> = Lazy::new(|| {
|
||||
NODE_REGISTRY
|
||||
.iter()
|
||||
@@ -420,7 +420,7 @@ impl NodeNetworkInterface {
|
||||
}
|
||||
|
||||
/// A check of which wire types an input accepts, built once so testing many types searches the node's matching implementations only once.
|
||||
/// Unlike [`Self::input_accepts_type`], a node passing its input's type through unchanged (like Monitor) also needs the inputs it feeds to accept the type.
|
||||
/// Unlike [`Self::input_accepts_type`], a node passing its input's type through unchanged (like Memoize) also needs the inputs it feeds to accept the type.
|
||||
fn type_acceptor(&self, input_connector: &InputConnector, network_path: &[NodeId]) -> Box<dyn Fn(&Type) -> bool> {
|
||||
let accepts_here: Box<dyn Fn(&Type) -> bool> = match input_connector {
|
||||
InputConnector::Export(export_index) => match network_path.split_last() {
|
||||
|
||||
@@ -21,8 +21,6 @@ pub struct NodeTemplate {
|
||||
pub implementation: NodeTemplateImplementation,
|
||||
/// Represents the eye icon for hiding/showing the node in the graph UI.
|
||||
pub visible: bool,
|
||||
/// Prevents identical proto nodes from being deduplicated during compilation, e.g. for monitor nodes.
|
||||
pub skip_deduplication: bool,
|
||||
/// A name chosen by the user for this instance of the node. Empty indicates no given name, in which case the implementation name is displayed in italics.
|
||||
pub display_name: String,
|
||||
/// Metadata to override the Inspector widgets for each input. Kept the same length as `inputs`.
|
||||
@@ -57,7 +55,6 @@ impl Default for NodeTemplate {
|
||||
call_argument: concrete!(Context),
|
||||
implementation: NodeTemplateImplementation::default(),
|
||||
visible: true,
|
||||
skip_deduplication: false,
|
||||
display_name: String::new(),
|
||||
input_metadata: Vec::new(),
|
||||
output_names: Vec::new(),
|
||||
@@ -110,7 +107,6 @@ impl NodeTemplate {
|
||||
call_argument,
|
||||
implementation,
|
||||
visible,
|
||||
skip_deduplication,
|
||||
compile_metadata: _,
|
||||
original_location: _,
|
||||
} = document_node;
|
||||
@@ -161,7 +157,6 @@ impl NodeTemplate {
|
||||
call_argument,
|
||||
implementation,
|
||||
visible,
|
||||
skip_deduplication,
|
||||
display_name,
|
||||
input_metadata,
|
||||
output_names,
|
||||
@@ -179,7 +174,6 @@ impl NodeTemplate {
|
||||
call_argument,
|
||||
implementation,
|
||||
visible,
|
||||
skip_deduplication,
|
||||
display_name,
|
||||
mut input_metadata,
|
||||
mut output_names,
|
||||
@@ -211,7 +205,6 @@ impl NodeTemplate {
|
||||
call_argument,
|
||||
implementation,
|
||||
visible,
|
||||
skip_deduplication,
|
||||
compile_metadata: None,
|
||||
original_location: Default::default(),
|
||||
};
|
||||
|
||||
@@ -117,10 +117,6 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[
|
||||
"raster_nodes::std_nodes::SampleImageNode",
|
||||
],
|
||||
},
|
||||
NodeReplacement {
|
||||
node: graphene_std::memo::monitor::IDENTIFIER,
|
||||
aliases: &["graphene_core::memo::MonitorNode"],
|
||||
},
|
||||
NodeReplacement {
|
||||
node: graphene_std::memo::memoize::IDENTIFIER,
|
||||
aliases: &["graphene_core::memo::MemoNode", "graphene_core::memo::ImpureMemoNode"],
|
||||
@@ -1163,6 +1159,14 @@ pub fn document_migration_replace_resources_referenced_by_hash(document_serializ
|
||||
(out, hash_to_id)
|
||||
}
|
||||
|
||||
/// The removed Monitor node, which old documents still hold.
|
||||
const MONITOR_IDENTIFIER: ProtoNodeIdentifier = ProtoNodeIdentifier::new("graphene_core::memo::MonitorNode");
|
||||
|
||||
/// Whether the implementation is the removed Monitor node, with or without the type arguments it was once stored with.
|
||||
fn is_monitor(implementation: &DocumentNodeImplementation) -> bool {
|
||||
matches!(implementation, DocumentNodeImplementation::ProtoNode(identifier) if identifier.as_str().split('<').next() == Some(MONITOR_IDENTIFIER.as_str()))
|
||||
}
|
||||
|
||||
/// Whether the node is a subgraph that feeds its first input through a Monitor into a Transform proto node and forwards the other four inputs unchanged, making it equivalent to a bare Transform node.
|
||||
fn is_monitored_transform_subgraph(node: &DocumentNode, document_network: &graph_craft::document::NodeNetwork) -> bool {
|
||||
let Some(network) = document_network.implementation_network(&node.implementation) else {
|
||||
@@ -1178,7 +1182,7 @@ fn is_monitored_transform_subgraph(node: &DocumentNode, document_network: &graph
|
||||
_ => false,
|
||||
})
|
||||
};
|
||||
let Some((monitor_id, monitor)) = find_proto_node(&graphene_std::memo::monitor::IDENTIFIER) else {
|
||||
let Some((monitor_id, monitor)) = find_proto_node(&MONITOR_IDENTIFIER) else {
|
||||
return false;
|
||||
};
|
||||
let Some((transform_id, transform)) = find_proto_node(&graphene_std::transform_nodes::transform::IDENTIFIER) else {
|
||||
@@ -1404,8 +1408,7 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
||||
let reference = document.network_interface.reference(node_id, &path)?;
|
||||
let is_merge_or_artboard = [DefinitionIdentifier::Network("Merge".into()), DefinitionIdentifier::Network("Artboard".into())].contains(&reference);
|
||||
|
||||
let monitor = DocumentNodeImplementation::ProtoNode(graphene_std::memo::monitor::IDENTIFIER);
|
||||
let has_monitor = network.nodes.values().any(|inner_node| inner_node.implementation == monitor);
|
||||
let has_monitor = network.nodes.values().any(|inner_node| is_monitor(&inner_node.implementation));
|
||||
|
||||
(is_merge_or_artboard && has_monitor).then_some((*node_id, path, reference))
|
||||
})
|
||||
@@ -1415,6 +1418,23 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
||||
document.network_interface.replace_implementation(node_id, network_path, &mut definition.default_node_template());
|
||||
}
|
||||
|
||||
// Any Monitor still left becomes a Passthrough of its content, once the passes above have used it to recognize old networks
|
||||
let monitors: Vec<(NodeId, Vec<NodeId>)> = document
|
||||
.network_interface
|
||||
.document_network()
|
||||
.recursive_nodes()
|
||||
.filter(|(_, node, _)| is_monitor(&node.implementation))
|
||||
.map(|(node_id, _, path)| (*node_id, path))
|
||||
.collect();
|
||||
for (node_id, network_path) in &monitors {
|
||||
let mut passthrough = NodeTemplate {
|
||||
implementation: NodeTemplateImplementation::ProtoNode(graphene_std::ops::passthrough::IDENTIFIER),
|
||||
..Default::default()
|
||||
};
|
||||
document.network_interface.replace_implementation(node_id, network_path, &mut passthrough);
|
||||
document.network_interface.set_call_argument(node_id, network_path, passthrough.call_argument);
|
||||
}
|
||||
|
||||
// The old "Math" node evaluated an expression over "A" and "B". A lexable static expression not reading a wired `B` becomes "Math Function"
|
||||
// with `A` as `x` and a constant `B` inlined. Anything else becomes "Extend" feeding "Math Formula", which reads the pair as `a` and `b`.
|
||||
let math_nodes: Vec<(NodeId, Vec<NodeId>, Vec<NodeInput>)> = document
|
||||
@@ -4941,7 +4961,7 @@ mod tests {
|
||||
let content = std::mem::replace(&mut extend.inputs[1], NodeInput::node(monitor_id, 0));
|
||||
let monitor_template = NodeTemplate {
|
||||
inputs: vec![content],
|
||||
implementation: NodeTemplateImplementation::ProtoNode(graphene_std::memo::monitor::IDENTIFIER),
|
||||
implementation: NodeTemplateImplementation::ProtoNode(MONITOR_IDENTIFIER),
|
||||
..Default::default()
|
||||
};
|
||||
network_template.nodes.insert(monitor_id, monitor_template);
|
||||
@@ -4956,14 +4976,34 @@ mod tests {
|
||||
else {
|
||||
panic!("{name} should stay a network node")
|
||||
};
|
||||
let monitor = DocumentNodeImplementation::ProtoNode(graphene_std::memo::monitor::IDENTIFIER);
|
||||
assert!(
|
||||
network.nodes.values().all(|inner_node| inner_node.implementation != monitor),
|
||||
"{name} should no longer have a Monitor node"
|
||||
);
|
||||
// A Monitor left in place would become a Passthrough, so only the rebuilt network has the definition's node count
|
||||
let NodeTemplateImplementation::Network(shipped) = resolve_network_node_type(name).expect("The definition should exist").default_node_template().implementation else {
|
||||
panic!("{name} should be a network node")
|
||||
};
|
||||
assert_eq!(network.nodes.len(), shipped.nodes.len(), "{name} should be rebuilt from its definition, without the Monitor node");
|
||||
}
|
||||
}
|
||||
|
||||
// The removed Monitor node keeps passing on its content wherever it's left
|
||||
#[test]
|
||||
fn a_monitor_node_becomes_a_passthrough() {
|
||||
let node_id = NodeId(1);
|
||||
let mut document = DocumentMessageHandler::default();
|
||||
let content = NodeInput::value(TaggedValue::Number(42.), false);
|
||||
let monitor_template = NodeTemplate {
|
||||
inputs: vec![content.clone()],
|
||||
implementation: NodeTemplateImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::MonitorNode<_, _, _>")),
|
||||
..Default::default()
|
||||
};
|
||||
document.network_interface.insert_node(node_id, monitor_template, &[]);
|
||||
|
||||
migrate(&mut document);
|
||||
|
||||
let node = &document.network_interface.document_network().nodes[&node_id];
|
||||
assert_eq!(node.implementation, DocumentNodeImplementation::ProtoNode(graphene_std::ops::passthrough::IDENTIFIER));
|
||||
assert_eq!(node.inputs, [content]);
|
||||
}
|
||||
|
||||
// Regex Find's Match Index is now an integer, so an old instance rounds its stored F64 index and rebuilds the subgraph
|
||||
// that fed the decimal index to its two item-at-index nodes
|
||||
#[test]
|
||||
|
||||
@@ -76,8 +76,8 @@ mod test_ellipse {
|
||||
let node_graph_layer = NodeGraphLayer::new(layer, &document.network_interface);
|
||||
let ellipse_node = node_graph_layer.upstream_node_id_from_protonode(ellipse::IDENTIFIER)?;
|
||||
Some(ResolvedEllipse {
|
||||
radius_x: instrumented.grab_ranked_input::<ellipse::RadiusXInput, f64>(&vec![ellipse_node], &editor.runtime).unwrap(),
|
||||
radius_y: instrumented.grab_ranked_input::<ellipse::RadiusYInput, f64>(&vec![ellipse_node], &editor.runtime).unwrap(),
|
||||
radius_x: instrumented.grab_ranked_input::<ellipse::RadiusXInput, f64>(&[ellipse_node], &editor.runtime).unwrap(),
|
||||
radius_y: instrumented.grab_ranked_input::<ellipse::RadiusYInput, f64>(&[ellipse_node], &editor.runtime).unwrap(),
|
||||
transform: document.metadata().transform_to_document(layer),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -280,18 +280,25 @@ fn whole_expanse_rect(layer: LayerNodeIdentifier, document: &DocumentMessageHand
|
||||
#[cfg(test)]
|
||||
mod test_fill {
|
||||
pub use crate::test_utils::test_prelude::*;
|
||||
use graphene_std::Graphic;
|
||||
use graphene_std::color::SRGBA8;
|
||||
use graphene_std::list::Item;
|
||||
use graphene_std::vector::fill;
|
||||
|
||||
// The Fill tool writes solid colors, whose stored values the input monitor records as `Item<Color>` wires
|
||||
// The Fill tool writes solid colors, which reach the paint input embedded as `Graphic` items
|
||||
async fn get_fills(editor: &mut EditorTestUtils) -> Vec<Item<Color>> {
|
||||
let instrumented = match editor.eval_graph_until_finished().await {
|
||||
Ok(instrumented) => instrumented,
|
||||
Err(e) => panic!("Failed to evaluate graph: {e}"),
|
||||
};
|
||||
|
||||
instrumented.grab_all_input::<fill::PaintInput, Item<Color>>(&editor.runtime).collect()
|
||||
instrumented
|
||||
.grab_all_input::<fill::PaintInput, Item<Graphic>>(&editor.runtime)
|
||||
.filter_map(|paint| match paint.into_element() {
|
||||
Graphic::Color(color) => Some(color),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -243,14 +243,14 @@ impl NodeGraphExecutor {
|
||||
.expect("Failed to send the thumbnails in view");
|
||||
}
|
||||
|
||||
/// Updates the network to monitor all inputs. Useful for the testing.
|
||||
/// Updates the network, giving back the paths of its proto nodes so tests can read what their inputs received.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn update_node_graph_instrumented(&mut self, document: &mut DocumentMessageHandler) -> Result<Instrumented, String> {
|
||||
// We should always invalidate the cache.
|
||||
self.node_graph_hash = crate::application::generate_uuid();
|
||||
let mut network = document.network_interface.document_network().clone();
|
||||
network.inline_definitions().map_err(|error| error.to_string())?;
|
||||
let instrumented = Instrumented::new(&mut network);
|
||||
let instrumented = Instrumented::new(&network);
|
||||
|
||||
let resources = document.resources.registry.clone();
|
||||
|
||||
@@ -1218,120 +1218,73 @@ pub use test::Instrumented;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::*;
|
||||
use crate::messages::portfolio::document::utility_types::network_interface::NodeNetworkInterface;
|
||||
use crate::test_utils::test_prelude::{self, NodeGraphLayer};
|
||||
use graph_craft::ProtoNodeIdentifier;
|
||||
use graph_craft::document::{DocumentNode, NodeNetwork};
|
||||
use graphene_std::Context;
|
||||
use graph_craft::document::NodeNetwork;
|
||||
use graphene_std::NodeParameter;
|
||||
use graphene_std::list::Item;
|
||||
use graphene_std::memo::IORecord;
|
||||
use test_prelude::LayerNodeIdentifier;
|
||||
|
||||
/// Stores all of the monitor nodes that have been attached to a graph
|
||||
/// The path of each proto node in an evaluated graph, by which tests read the values its inputs received.
|
||||
#[derive(Default)]
|
||||
pub struct Instrumented {
|
||||
protonodes_by_name: HashMap<ProtoNodeIdentifier, Vec<Vec<Vec<NodeId>>>>,
|
||||
protonodes_by_path: HashMap<Vec<NodeId>, Vec<Vec<NodeId>>>,
|
||||
protonodes_by_name: HashMap<ProtoNodeIdentifier, Vec<Vec<NodeId>>>,
|
||||
}
|
||||
|
||||
impl Instrumented {
|
||||
/// Adds montior nodes to the network
|
||||
fn add(&mut self, network: &mut NodeNetwork, path: &mut Vec<NodeId>) {
|
||||
// Required to do seperately to satiate the borrow checker.
|
||||
let mut monitor_nodes = Vec::new();
|
||||
for (id, node) in network.nodes.iter_mut() {
|
||||
// Recursively instrument
|
||||
if let DocumentNodeImplementation::Network(nested) = &mut node.implementation {
|
||||
path.push(*id);
|
||||
self.add(nested, path);
|
||||
path.pop();
|
||||
/// Records the path of each proto node in the network and the networks nested in it.
|
||||
fn add(&mut self, network: &NodeNetwork, path: &mut Vec<NodeId>) {
|
||||
for (id, node) in &network.nodes {
|
||||
path.push(*id);
|
||||
match &node.implementation {
|
||||
DocumentNodeImplementation::Network(nested) => self.add(nested, path),
|
||||
DocumentNodeImplementation::ProtoNode(identifier) => self.protonodes_by_name.entry(identifier.clone()).or_default().push(path.clone()),
|
||||
_ => {}
|
||||
}
|
||||
let mut monitor_node_ids = Vec::with_capacity(node.inputs.len());
|
||||
for input in &mut node.inputs {
|
||||
let node_id = NodeId::new();
|
||||
path.push(node_id);
|
||||
monitor_node_ids.push(path.clone());
|
||||
path.pop();
|
||||
|
||||
// A None value has nothing to record and a reflection must stay on the node it describes, so such a slot stays a dead path that introspects as absent
|
||||
let is_none = matches!(input, NodeInput::Value { tagged_value, .. } if matches!(&**tagged_value, graph_craft::document::value::TaggedValue::None));
|
||||
if is_none || matches!(input, NodeInput::Reflection(_)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let old_input = std::mem::replace(input, NodeInput::node(node_id, 0));
|
||||
monitor_nodes.push((old_input, node_id));
|
||||
}
|
||||
if let DocumentNodeImplementation::ProtoNode(identifier) = &mut node.implementation {
|
||||
path.push(*id);
|
||||
self.protonodes_by_name.entry(identifier.clone()).or_default().push(monitor_node_ids.clone());
|
||||
self.protonodes_by_path.insert(path.clone(), monitor_node_ids);
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
for (input, monitor_id) in monitor_nodes {
|
||||
let monitor_node = DocumentNode {
|
||||
inputs: vec![input],
|
||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::memo::monitor::IDENTIFIER),
|
||||
call_argument: graph_craft::generic!(T),
|
||||
skip_deduplication: true,
|
||||
..Default::default()
|
||||
};
|
||||
network.nodes.insert(monitor_id, monitor_node);
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/// Instrument a graph and return a new [Instrumented] state.
|
||||
pub fn new(network: &mut NodeNetwork) -> Self {
|
||||
pub fn new(network: &NodeNetwork) -> Self {
|
||||
let mut instrumented = Self::default();
|
||||
instrumented.add(network, &mut Vec::new());
|
||||
instrumented
|
||||
}
|
||||
|
||||
/// Pulls a concrete output type out of a monitor record, tolerating the three context shapes the executor records against.
|
||||
fn downcast_record<Output: Send + Sync + Clone + 'static>(dynamic: Arc<dyn std::any::Any + Send + Sync>) -> Option<Output> {
|
||||
if let Some(x) = dynamic.downcast_ref::<IORecord<(), Output>>() {
|
||||
Some(x.output.clone())
|
||||
} else if let Some(x) = dynamic.downcast_ref::<IORecord<Footprint, Output>>() {
|
||||
Some(x.output.clone())
|
||||
} else {
|
||||
dynamic.downcast_ref::<IORecord<Context, Output>>().map(|x| x.output.clone())
|
||||
}
|
||||
/// Reads the value an input of the proto node at this path received, if it has the `Output` type.
|
||||
/// Only the value types the Data panel can show come through.
|
||||
fn grab_input<Output: Clone + 'static>(path: &[NodeId], input_index: usize, runtime: &NodeRuntime) -> Option<Output> {
|
||||
let observation = Observation {
|
||||
node_path: path.to_vec(),
|
||||
connector: ObservedConnector::Input(input_index),
|
||||
overrides: ContextOverrides::default(),
|
||||
};
|
||||
runtime.observe(observation)?.downcast_ref::<Output>().cloned()
|
||||
}
|
||||
|
||||
/// Grab all of the values of the input every time it occurs in the graph, downcast to the recorded `Output` type.
|
||||
/// A record whose type does not match `Output` is skipped, so a wrong `Output` yields an empty iterator rather than an error.
|
||||
pub fn grab_all_input<'a, Input: NodeParameter + 'a, Output: Send + Sync + Clone + 'static>(&'a self, runtime: &'a NodeRuntime) -> impl Iterator<Item = Output> + 'a {
|
||||
/// Grab all of the values of the input every time it occurs in the graph, downcast to the received `Output` type.
|
||||
/// A value whose type does not match `Output` is skipped, so a wrong `Output` yields an empty iterator rather than an error.
|
||||
pub fn grab_all_input<'a, Input: NodeParameter + 'a, Output: Clone + 'static>(&'a self, runtime: &'a NodeRuntime) -> impl Iterator<Item = Output> + 'a {
|
||||
self.protonodes_by_name
|
||||
.get(&Input::NODE_IDENTIFIER)
|
||||
.map_or([].as_slice(), |x| x.as_slice())
|
||||
.map_or([].as_slice(), |paths| paths.as_slice())
|
||||
.iter()
|
||||
.filter_map(|inputs| inputs.get(Input::INDEX))
|
||||
.filter_map(|input_monitor_node| runtime.executor.introspect(input_monitor_node).ok())
|
||||
.filter_map(Instrumented::downcast_record::<Output>)
|
||||
.filter_map(|path| Self::grab_input::<Output>(path, Input::INDEX, runtime))
|
||||
}
|
||||
|
||||
pub fn grab_protonode_input<Input: NodeParameter, Output: Send + Sync + Clone + 'static>(&self, path: &Vec<NodeId>, runtime: &NodeRuntime) -> Option<Output> {
|
||||
let input_monitor_node = self.protonodes_by_path.get(path)?.get(Input::INDEX)?;
|
||||
|
||||
let dynamic = runtime.executor.introspect(input_monitor_node).ok()?;
|
||||
|
||||
Self::downcast_record::<Output>(dynamic)
|
||||
pub fn grab_protonode_input<Input: NodeParameter, Output: Clone + 'static>(&self, path: &[NodeId], runtime: &NodeRuntime) -> Option<Output> {
|
||||
Self::grab_input::<Output>(path, Input::INDEX, runtime)
|
||||
}
|
||||
|
||||
/// Grabs a ranked input's recorded value as its bare element `Element`.
|
||||
/// A stored value materializes as an `Item<Element>` wire, so the monitor records the whole cell and this unwraps its element.
|
||||
pub fn grab_ranked_input<Input: NodeParameter, Element: Send + Sync + Clone + 'static>(&self, path: &Vec<NodeId>, runtime: &NodeRuntime) -> Option<Element> {
|
||||
let input_monitor_node = self.protonodes_by_path.get(path)?.get(Input::INDEX)?;
|
||||
let dynamic = runtime.executor.introspect(input_monitor_node).ok()?;
|
||||
Self::downcast_record::<Item<Element>>(dynamic).map(|item| item.into_element())
|
||||
/// Grabs a ranked input's received value as its bare element `Element`.
|
||||
/// A stored value materializes as an `Item<Element>` wire, so the input receives the whole cell and this unwraps its element.
|
||||
pub fn grab_ranked_input<Input: NodeParameter, Element: Clone + 'static>(&self, path: &[NodeId], runtime: &NodeRuntime) -> Option<Element> {
|
||||
Self::grab_input::<Item<Element>>(path, Input::INDEX, runtime).map(Item::into_element)
|
||||
}
|
||||
|
||||
pub fn grab_input_from_layer<Input: NodeParameter, Output: Send + Sync + Clone + 'static>(
|
||||
pub fn grab_input_from_layer<Input: NodeParameter, Output: Clone + 'static>(
|
||||
&self,
|
||||
layer: LayerNodeIdentifier,
|
||||
network_interface: &NodeNetworkInterface,
|
||||
@@ -1339,7 +1292,7 @@ mod test {
|
||||
) -> Option<Output> {
|
||||
let node_graph_layer = NodeGraphLayer::new(layer, network_interface);
|
||||
let node = node_graph_layer.upstream_node_id_from_protonode(Input::NODE_IDENTIFIER)?;
|
||||
self.grab_protonode_input::<Input, Output>(&vec![node], runtime)
|
||||
self.grab_protonode_input::<Input, Output>(&[node], runtime)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ async fn compile_and_run(editor: &mut EditorTestUtils) {
|
||||
}
|
||||
|
||||
/// The proto node IDs compiled for the document node paths that pass `keep`. The executor keeps the nodes an update drops
|
||||
/// for one more update, so a first update clears those of the test harness's instrumented graph.
|
||||
/// for one more update, so a first update clears those of the graph before it.
|
||||
async fn compiled_ids(editor: &mut EditorTestUtils, keep: impl Fn(&[NodeId]) -> bool) -> HashSet<NodeId> {
|
||||
compile_and_run(editor).await;
|
||||
compile_and_run(editor).await;
|
||||
|
||||
@@ -390,6 +390,14 @@ impl NodeRuntime {
|
||||
self.sender.send(NodeGraphUpdate::ExecutionResponse(Box::new(response))).expect("Failed to send response");
|
||||
}
|
||||
|
||||
/// Reads one observation from the last evaluation, apart from the observations the runtime keeps.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn observe(&self, observation: Observation) -> Option<ObservedValue> {
|
||||
let mut observer = Observer::default();
|
||||
observer.set((), Some(observation));
|
||||
observer.evaluate(&self.executor, self.old_graph.as_ref()).remove(&())?.data
|
||||
}
|
||||
|
||||
async fn read_back(&self, texture: Texture) -> Raster<CPU> {
|
||||
let application_io = self.editor_api.application_io.as_ref().unwrap();
|
||||
let executor = application_io.gpu_executor().expect("GPU executor should be available when we receive a texture");
|
||||
|
||||
@@ -14,7 +14,6 @@ pub struct DocumentNode {
|
||||
pub call_argument: Type,
|
||||
pub implementation: DocumentNodeImplementation,
|
||||
pub visible: bool,
|
||||
pub skip_deduplication: bool,
|
||||
pub compile_metadata: Option<NodeCompileMetadata>,
|
||||
pub original_location: OriginalLocation,
|
||||
}
|
||||
@@ -139,7 +138,7 @@ When the document graph is executed, the following steps occur:
|
||||
- The constructor functions are run with the `ConstructionArgs` enum. Constructors generally evaluate the result of these inputs, e.g. if you have a `Pi` node that is used as the second input to an `Add` node, the `Add` node's constructor will evaluate the `Pi` node. This is visible if you place a log statement in the `Pi` node's implementation.
|
||||
- The resolved functions are stored in a `BorrowTree`, which allows previous proto-nodes to be referenced as inputs by later nodes. The `BorrowTree` ensures nodes can't be removed while being referenced by other nodes.
|
||||
|
||||
The registry rows for a node declared with the `node` macro are generated by it, one per `#[implementations(...)]` pairing. The rows written by hand in `node_registry.rs` are for the adapters that convert between wire types and for executor-internal nodes such as the memoize and monitor nodes.
|
||||
The registry rows for a node declared with the `node` macro are generated by it, one per `#[implementations(...)]` pairing. The rows written by hand in `node_registry.rs` are for the adapters that convert between wire types and for executor-internal nodes such as the memoize nodes.
|
||||
|
||||
## Debugging
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ impl DocumentNode {
|
||||
}
|
||||
|
||||
impl NodeNetwork {
|
||||
/// Populate the [`DocumentNode::path`], which stores the location of the document node to allow for matching the resulting proto nodes to the document node for the purposes of typing and finding monitor nodes.
|
||||
/// Populate the [`DocumentNode::path`], which stores the location of the document node to allow for matching the resulting proto nodes to the document node for the purposes of typing and observing node values.
|
||||
///
|
||||
/// Table entries are not visited, since each instance gets its paths when [`Self::flatten`] copies the entry.
|
||||
pub fn generate_node_paths(&mut self, prefix: &[NodeId]) {
|
||||
|
||||
@@ -28,7 +28,6 @@ impl DocumentNode {
|
||||
call_argument: self.call_argument,
|
||||
construction_args,
|
||||
original_location: self.original_location,
|
||||
skip_deduplication: self.skip_deduplication,
|
||||
compile_metadata: self.compile_metadata.unwrap_or_default(),
|
||||
upstream_context_features: Default::default(),
|
||||
}
|
||||
|
||||
@@ -44,11 +44,6 @@ pub struct DocumentNode {
|
||||
/// Represents the eye icon for hiding/showing the node in the graph UI. When hidden, a node gets replaced with a passthrough node during the graph flattening step.
|
||||
#[serde(default = "return_true")]
|
||||
pub visible: bool,
|
||||
/// When two different proto nodes hash to the same value (e.g. two value nodes each containing `2_u32` or two multiply nodes that have the same node IDs as input), the duplicates are removed.
|
||||
/// See [`ProtoNetwork::generate_stable_node_ids`] for details.
|
||||
/// However sometimes this is not desirable, for example in the case of a [`graphene_core::memo::MonitorNode`] that needs to be accessed outside of the graph.
|
||||
#[serde(default)]
|
||||
pub skip_deduplication: bool,
|
||||
#[serde(skip)]
|
||||
pub compile_metadata: Option<NodeCompileMetadata>,
|
||||
/// The path to this node and its inputs and outputs as of when [`NodeNetwork::generate_node_paths`] was called.
|
||||
@@ -82,7 +77,6 @@ impl Default for DocumentNode {
|
||||
call_argument: concrete!(Context),
|
||||
implementation: Default::default(),
|
||||
visible: true,
|
||||
skip_deduplication: Default::default(),
|
||||
original_location: OriginalLocation::default(),
|
||||
compile_metadata: Default::default(),
|
||||
}
|
||||
@@ -817,7 +811,6 @@ impl core_types::graphene_hash::CacheHash for DocumentNode {
|
||||
self.call_argument.cache_hash(state);
|
||||
self.implementation.cache_hash(state);
|
||||
self.visible.cache_hash(state);
|
||||
self.skip_deduplication.cache_hash(state);
|
||||
self.compile_metadata.cache_hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,6 @@ pub struct OldDocumentNode {
|
||||
pub locked: bool,
|
||||
/// Metadata about the node including its position in the graph UI. Ensure the click target in the encapsulating network is updated when the node moves by using network.update_click_target(node_id).
|
||||
pub metadata: OldDocumentNodeMetadata,
|
||||
/// When two different proto nodes hash to the same value (e.g. two value nodes each containing `2_u32` or two multiply nodes that have the same node IDs as input), the duplicates are removed.
|
||||
/// See [`ProtoNetwork::generate_stable_node_ids`] for details.
|
||||
/// However sometimes this is not desirable, for example in the case of a [`graphene_core::memo::MonitorNode`] that needs to be accessed outside of the graph.
|
||||
#[serde(default)]
|
||||
pub skip_deduplication: bool,
|
||||
/// The path to this node and its inputs and outputs as of when [`NodeNetwork::generate_node_paths`] was called.
|
||||
#[serde(skip)]
|
||||
pub original_location: OriginalLocation,
|
||||
|
||||
@@ -124,7 +124,6 @@ pub struct ProtoNode {
|
||||
pub call_argument: Type,
|
||||
pub identifier: ProtoNodeIdentifier,
|
||||
pub original_location: OriginalLocation,
|
||||
pub skip_deduplication: bool,
|
||||
pub(crate) compile_metadata: NodeCompileMetadata,
|
||||
/// The context features read by this node and everything upstream of it.
|
||||
pub upstream_context_features: ContextFeatures,
|
||||
@@ -137,7 +136,6 @@ impl Default for ProtoNode {
|
||||
construction_args: ConstructionArgs::Value(value::TaggedValue::Integer(0).into()),
|
||||
call_argument: concrete!(()),
|
||||
original_location: OriginalLocation::default(),
|
||||
skip_deduplication: false,
|
||||
compile_metadata: Default::default(),
|
||||
upstream_context_features: ContextFeatures::empty(),
|
||||
}
|
||||
@@ -146,16 +144,12 @@ impl Default for ProtoNode {
|
||||
|
||||
impl ProtoNode {
|
||||
/// A stable node ID is a hash of a node that should stay constant. This is used in order to remove duplicates from the graph.
|
||||
/// In the case of `skip_deduplication`, the `document_node_path` is also hashed in order to avoid duplicate monitor nodes from being removed (which would make it impossible to load thumbnails).
|
||||
pub fn stable_node_id(&self) -> Option<NodeId> {
|
||||
use std::hash::Hasher;
|
||||
let mut hasher = rustc_hash::FxHasher::default();
|
||||
|
||||
self.identifier.as_str().hash(&mut hasher);
|
||||
self.construction_args.cache_hash(&mut hasher);
|
||||
if self.skip_deduplication {
|
||||
self.original_location.path.hash(&mut hasher);
|
||||
}
|
||||
|
||||
std::mem::discriminant(&self.call_argument).hash(&mut hasher);
|
||||
self.call_argument.hash(&mut hasher);
|
||||
@@ -173,7 +167,6 @@ impl ProtoNode {
|
||||
path: Some(path),
|
||||
..Default::default()
|
||||
},
|
||||
skip_deduplication: false,
|
||||
compile_metadata: Default::default(),
|
||||
upstream_context_features: ContextFeatures::empty(),
|
||||
}
|
||||
@@ -355,7 +348,6 @@ impl ProtoNetwork {
|
||||
},
|
||||
compile_metadata: forwarding,
|
||||
upstream_context_features: features,
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
|
||||
@@ -387,7 +379,6 @@ impl ProtoNetwork {
|
||||
},
|
||||
compile_metadata: forwarding,
|
||||
upstream_context_features: features,
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
nullification_node_id
|
||||
|
||||
@@ -113,11 +113,6 @@ impl DynamicExecutor {
|
||||
Ok(ResolvedDocumentNodeTypesDelta { add, remove })
|
||||
}
|
||||
|
||||
/// Calls the `Node::serialize` for that specific node, returning for example the cached value for a monitor node. The node path must match the document node path.
|
||||
pub fn introspect(&self, node_path: &[NodeId]) -> Result<Arc<dyn std::any::Any + Send + Sync + 'static>, IntrospectError> {
|
||||
self.tree.introspect(node_path)
|
||||
}
|
||||
|
||||
pub fn input_type(&self) -> Option<Type> {
|
||||
self.typing_context.type_of(self.output).map(|node_io| node_io.call_argument.clone())
|
||||
}
|
||||
@@ -311,13 +306,6 @@ impl BorrowTree {
|
||||
self.nodes.insert(id, (node, path, inputs));
|
||||
}
|
||||
|
||||
/// Calls the `Node::serialize` for that specific node, returning for example the cached value for a monitor node. The node path must match the document node path.
|
||||
pub fn introspect(&self, node_path: &[NodeId]) -> Result<Arc<dyn std::any::Any + Send + Sync + 'static>, IntrospectError> {
|
||||
let (id, _) = self.source_map.get(node_path).ok_or_else(|| IntrospectError::PathNotFound(node_path.to_vec()))?;
|
||||
let (node, _path, _) = self.nodes.get(id).ok_or(IntrospectError::ProtoNodeNotFound(*id))?;
|
||||
node.node().serialize().ok_or(IntrospectError::NoData)
|
||||
}
|
||||
|
||||
pub fn get(&self, id: NodeId) -> Option<SharedNodeContainer> {
|
||||
self.nodes.get(&id).map(|(node, _, _)| node.clone() as SharedNodeContainer)
|
||||
}
|
||||
|
||||
@@ -34,50 +34,6 @@ use std::sync::Arc;
|
||||
// TODO: turn into hashmap
|
||||
fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> {
|
||||
let mut node_types: Vec<(ProtoNodeIdentifier, NodeConstructor, NodeIOTypes)> = vec![
|
||||
// =============
|
||||
// MONITOR NODES
|
||||
// =============
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Artboard>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Graphic>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Vector>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Raster<CPU>>]),
|
||||
#[cfg(feature = "gpu")]
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Raster<GPU>>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Color>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<Gradient>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Artboard>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Graphic>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Vector>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<CPU>>]),
|
||||
#[cfg(feature = "gpu")]
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Raster<GPU>>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Color>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Gradient>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<DashPattern>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<BoxCorners>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<TransferCurve>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<String>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<f64>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<DAffine2>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<Footprint>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<DVec2>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<bool>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<BlendMode>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<String>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<NodeIdPath>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<f64>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<DVec2>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<bool>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<DAffine2>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<BlendMode>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<GradientForm>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<GradientSpread>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<GradientSpace>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<GradientHueDirection>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<GradientInterpolation>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Item<AttributeValueDyn>]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ListDyn]),
|
||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => List<graphene_std::brush::Stroke>]),
|
||||
// Context nullification
|
||||
#[cfg(feature = "gpu")]
|
||||
async_node!(graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => Item<Arc<PlatformEditorApi>>, Context => Item<graphene_std::ContextModification>]),
|
||||
@@ -298,8 +254,8 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
}};
|
||||
}
|
||||
// The single list of value/enum element types that ride ranked wires as framable node parameters.
|
||||
// Each needs both a rank promotion adapter and a cache chain (memoize/monitor/context),
|
||||
// so both registrations below are driven from here by callback, which is what keeps a value type from ending up monitorable but not promotable, or vice versa.
|
||||
// Each needs both a rank promotion adapter and a cache chain (memoize/context),
|
||||
// so both registrations below are driven from here by callback, which is what keeps a value type from ending up cacheable but not promotable, or vice versa.
|
||||
macro_rules! ranked_value_types {
|
||||
($register:ident) => {
|
||||
$register!(
|
||||
@@ -354,7 +310,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
)
|
||||
};
|
||||
}
|
||||
// Primary element types (graphical data and scalars) get promotion adapters here; their monitor/memoize rows are the
|
||||
// Primary element types (graphical data and scalars) get promotion adapters here; their memoize rows are the
|
||||
// explicit ones near the top of the registry, so they are deliberately absent from the shared value-type list above
|
||||
node_types.extend(rank_adapter_nodes!(
|
||||
Vector,
|
||||
@@ -438,14 +394,12 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
||||
));
|
||||
#[cfg(feature = "gpu")]
|
||||
node_types.extend(bundle_adapter_nodes!(Raster<GPU>));
|
||||
// The memoize + monitor + context-nullification triple for each value type in the shared list above: the compiler wraps
|
||||
// a ranked connector's broadcast sibling in a Memoize + context-nullification pair, and test instrumentation monitors any wire.
|
||||
// The memoize + context-nullification pair the compiler wraps a ranked connector's broadcast sibling in, for each value type in the shared list above.
|
||||
// Node identifiers are passed explicitly since `stringify!` would mangle the path's whitespace through this nested macro.
|
||||
macro_rules! cache_chain_nodes {
|
||||
(each: $value:ty) => {{
|
||||
let entries: Vec<(ProtoNodeIdentifier, NodeConstructor, NodeIOTypes)> = vec![
|
||||
async_node!(identifier: graphene_core::memo::memoize::IDENTIFIER, graphene_core::memo::MemoizeNode<_, _>, input: Context, fn_params: [Context => $value]),
|
||||
async_node!(identifier: graphene_core::memo::monitor::IDENTIFIER, graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => $value]),
|
||||
async_node!(identifier: graphene_core::context_modification::context_modification::IDENTIFIER, graphene_core::context_modification::ContextModificationNode<_, _>, input: Context, fn_params: [Context => $value, Context => Item<graphene_std::ContextModification>]),
|
||||
];
|
||||
entries
|
||||
|
||||
@@ -55,11 +55,6 @@ pub trait Node<Input: ?Sized> {
|
||||
fn node_name(&self) -> &'static str {
|
||||
std::any::type_name::<Self>()
|
||||
}
|
||||
/// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes.
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
log::warn!("Node::serialize not implemented for {}", std::any::type_name::<Self>());
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
mod types;
|
||||
@@ -107,9 +102,6 @@ impl<I: ?Sized, N: Node<I> + ?Sized> Node<I> for &N {
|
||||
fn node_name(&self) -> &'static str {
|
||||
(**self).node_name()
|
||||
}
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
(**self).serialize()
|
||||
}
|
||||
}
|
||||
impl<I: ?Sized, N: Node<I> + ?Sized> Node<I> for Box<N> {
|
||||
type Output = N::Output;
|
||||
@@ -120,9 +112,6 @@ impl<I: ?Sized, N: Node<I> + ?Sized> Node<I> for Box<N> {
|
||||
fn node_name(&self) -> &'static str {
|
||||
(**self).node_name()
|
||||
}
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
(**self).serialize()
|
||||
}
|
||||
}
|
||||
impl<I: ?Sized, N: Node<I> + ?Sized> Node<I> for std::sync::Arc<N> {
|
||||
type Output = N::Output;
|
||||
@@ -133,9 +122,6 @@ impl<I: ?Sized, N: Node<I> + ?Sized> Node<I> for std::sync::Arc<N> {
|
||||
fn node_name(&self) -> &'static str {
|
||||
(**self).node_name()
|
||||
}
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
(**self).serialize()
|
||||
}
|
||||
}
|
||||
|
||||
/// A compile-time symbol naming one parameter of one proto node.
|
||||
|
||||
@@ -4,13 +4,6 @@ use std::hash::{Hash, Hasher};
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Stores both what a node was called with and what it returned.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct IORecord<I, O> {
|
||||
pub input: I,
|
||||
pub output: O,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MemoHash<T: CacheHash> {
|
||||
hash: u64,
|
||||
|
||||
@@ -17,10 +17,6 @@ where
|
||||
fn eval(&self, input: &I) -> Poll<O> {
|
||||
self.0.eval(input)
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
self.0.serialize()
|
||||
}
|
||||
}
|
||||
impl<N: Node<I>, I> TypeNode<N, I, <N as Node<I>>::Output> {
|
||||
pub fn new(node: N) -> Self {
|
||||
|
||||
@@ -351,10 +351,6 @@ where
|
||||
.unwrap_or_else(|_| panic!("DowncastBothNode wrong output type: expected {} in: \n{}", std::any::type_name::<O>(), self.node.node().node_name()))
|
||||
})
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
self.node.node().serialize()
|
||||
}
|
||||
}
|
||||
impl<I, O> DowncastBothNode<I, O> {
|
||||
pub const fn new(node: SharedNodeContainer) -> Self {
|
||||
@@ -386,10 +382,6 @@ where
|
||||
.unwrap_or_else(|| panic!("DynAnyNode Input: expected {} in:\n{}", std::any::type_name::<I>(), std::any::type_name::<N>()));
|
||||
self.node.eval(input).map(|output| Box::new(output) as Any)
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
self.node.serialize()
|
||||
}
|
||||
}
|
||||
impl<I, O, N> DynAnyNode<I, O, N> {
|
||||
pub const fn new(node: N) -> Self {
|
||||
|
||||
@@ -683,7 +683,7 @@ fn create_peniko_gradient_brush(gradient_item: ItemRef<'_, Gradient>, multiplied
|
||||
Some((brush, gradient_to_device))
|
||||
}
|
||||
|
||||
// TODO: Click targets can be removed from the render output, since the vector data is available in the vector modify data from Monitor nodes.
|
||||
// TODO: Click targets can be removed from the render output, since the vector data is available in the vector modify data the editor observes on 'Path' nodes.
|
||||
// This will require that the transform for child layers into that layer space be calculated, or it could be returned from the RenderOutput instead of click targets.
|
||||
#[derive(Debug, Default, Clone, PartialEq, DynAny)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
|
||||
@@ -524,18 +524,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
quote!(#[derive(Debug, Clone)])
|
||||
};
|
||||
|
||||
// Generate serialize method if serialize attribute is specified
|
||||
let serialize_impl = if let Some(serialize_fn) = &parsed.attributes.serialize {
|
||||
let data_field_refs = data_field_names.iter().map(|name| quote!(&self.#name));
|
||||
quote! {
|
||||
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
|
||||
#serialize_fn(#(#data_field_refs),*)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote!()
|
||||
};
|
||||
|
||||
let eval_prelude = quote! {
|
||||
use #core_types::misc::Clampable;
|
||||
|
||||
@@ -647,8 +635,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
let __state = self.slots.resolve(__key, &__runtime, __source, __placeholder, move || async move { #landed_call });
|
||||
__cell.merge(__state)
|
||||
}
|
||||
|
||||
#serialize_impl
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
@@ -662,8 +648,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
};
|
||||
#fold
|
||||
}
|
||||
|
||||
#serialize_impl
|
||||
}
|
||||
};
|
||||
|
||||
@@ -757,8 +741,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
};
|
||||
__cell.run(__kernel)
|
||||
}
|
||||
|
||||
#serialize_impl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -832,8 +814,6 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
};
|
||||
__cell.run(__kernel)
|
||||
}
|
||||
|
||||
#serialize_impl
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ pub fn derive_destructure_impl(item: TokenStream2) -> syn::Result<TokenStream2>
|
||||
}
|
||||
};
|
||||
|
||||
// Memoize lets the node's outputs share one evaluation, and Monitor lets the editor inspect the struct
|
||||
// Memoize lets the node's outputs share one evaluation
|
||||
let registration_module = format_ident!("_{struct_snake_name}_registration");
|
||||
let wasm_registration = format_ident!("__node_registry_{}_{}", NODE_ID.fetch_add(1, Ordering::SeqCst), struct_ident);
|
||||
let registration = quote! {
|
||||
@@ -246,15 +246,15 @@ pub fn derive_destructure_impl(item: TokenStream2) -> syn::Result<TokenStream2>
|
||||
use #gcore::ctor::ctor;
|
||||
|
||||
#[cfg_attr(not(target_family = "wasm"), ctor(unsafe, crate_path = core_types::ctor))]
|
||||
fn register_memoize_and_monitor() {
|
||||
#graphene_core::memo::register_memoize_and_monitor::<#struct_ident>();
|
||||
#graphene_core::memo::register_memoize_and_monitor::<#mapped_ident>();
|
||||
fn register_memoize() {
|
||||
#graphene_core::memo::register_memoize::<#struct_ident>();
|
||||
#graphene_core::memo::register_memoize::<#mapped_ident>();
|
||||
}
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
#[unsafe(no_mangle)]
|
||||
extern "C" fn #wasm_registration() {
|
||||
register_memoize_and_monitor();
|
||||
register_memoize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,8 +65,6 @@ pub(crate) struct NodeFnAttributes {
|
||||
pub(crate) inspector_string: Option<LitStr>,
|
||||
/// whether to `#[cfg]` gate the node implementation, defaults to None
|
||||
pub(crate) cfg: Option<TokenStream2>,
|
||||
/// Custom serialization function path (e.g., "my_module::custom_serialize")
|
||||
pub(crate) serialize: Option<Path>,
|
||||
pub(crate) flags: NodeFlags,
|
||||
/// Fn producing an placeholder value used while node evaluation is pending
|
||||
pub(crate) placeholder: Option<Path>,
|
||||
@@ -441,7 +439,6 @@ impl Parse for NodeFnAttributes {
|
||||
let mut path = None;
|
||||
let mut inspector_string = None;
|
||||
let mut cfg = None;
|
||||
let mut serialize = None;
|
||||
let mut flags = NodeFlags::default();
|
||||
let mut placeholder = None;
|
||||
let mut version = None;
|
||||
@@ -544,20 +541,6 @@ impl Parse for NodeFnAttributes {
|
||||
let meta = meta.require_list()?;
|
||||
cfg = Some(meta.tokens.clone());
|
||||
}
|
||||
// Function name for custom serialization of this node's data. This is only used by the Monitor node.
|
||||
//
|
||||
// Example usage:
|
||||
// #[node_macro::node(..., serialize(my_module::custom_serialize), ...)]
|
||||
"serialize" => {
|
||||
let meta = meta.require_list()?;
|
||||
if serialize.is_some() {
|
||||
return Err(Error::new_spanned(meta, "Multiple 'serialize' attributes are not allowed"));
|
||||
}
|
||||
let parsed_path: Path = meta
|
||||
.parse_args()
|
||||
.map_err(|_| Error::new_spanned(meta, "Expected a valid path for 'serialize', e.g., serialize(my_module::custom_serialize)"))?;
|
||||
serialize = Some(parsed_path);
|
||||
}
|
||||
// Instructs the preprocessor to insert a Memoize node after this node in the generated subnetwork,
|
||||
// caching its output across evaluations with identical inputs.
|
||||
//
|
||||
@@ -621,7 +604,7 @@ impl Parse for NodeFnAttributes {
|
||||
indoc!(
|
||||
r#"
|
||||
Unsupported attribute in `node`.
|
||||
Supported attributes are 'category', 'name', 'icon', 'path', 'skip_impl', 'inspector', 'cfg', 'serialize', 'memoize', 'footprint_invariant', 'forwards_input', 'inject_scope', 'placeholder', 'no_partial', and 'version'.
|
||||
Supported attributes are 'category', 'name', 'icon', 'path', 'skip_impl', 'inspector', 'cfg', 'memoize', 'footprint_invariant', 'forwards_input', 'inject_scope', 'placeholder', 'no_partial', and 'version'.
|
||||
Example usage:
|
||||
#[node_macro::node(..., name("Test Node"), ...)]
|
||||
"#
|
||||
@@ -651,7 +634,6 @@ impl Parse for NodeFnAttributes {
|
||||
path,
|
||||
inspector_string,
|
||||
cfg,
|
||||
serialize,
|
||||
flags,
|
||||
placeholder,
|
||||
version,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use core_types::graphene_hash::CacheHash;
|
||||
use core_types::memo::*;
|
||||
use core_types::registry::{DowncastBothNode, DynAnyNode, NODE_REGISTRY, NodeConstructor, PanicNode, TypeErasedBox};
|
||||
use core_types::{Context, Interrupt, NodeIO, NodeIOTypes, Poll, WasmNotSend, concrete, fn_type};
|
||||
use core_types::{Context, NodeIO, NodeIOTypes, Poll, WasmNotSend, concrete, fn_type};
|
||||
use dyn_any::StaticType;
|
||||
use std::hash::DefaultHasher;
|
||||
use std::hash::Hasher;
|
||||
@@ -36,39 +35,13 @@ fn memoize<I: CacheHash + Clone + Send, T: Clone + WasmNotSend>(input: I, conten
|
||||
state
|
||||
}
|
||||
|
||||
type MonitorValue<I, T> = Arc<Mutex<Option<Arc<IORecord<I, T>>>>>;
|
||||
|
||||
/// The Monitor node is used by the editor to access the data flowing through it.
|
||||
#[node_macro::node(category(""), path(graphene_core::memo), serialize(serialize_monitor), inspector("monitor_inspector"), skip_impl, forwards_input)]
|
||||
fn monitor<I: Clone + 'static + Send + Sync, T: Clone + 'static + Send + Sync>(
|
||||
input: I,
|
||||
content: impl Node<I, Output = T>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[data]
|
||||
io: MonitorValue<I, T>,
|
||||
) -> Result<T, Interrupt> {
|
||||
let output = content.eval(input.clone())?;
|
||||
*io.lock().unwrap() = Some(Arc::new(IORecord { input, output: output.clone() }));
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
fn serialize_monitor<I: Clone + 'static + Send + Sync, T: Clone + 'static + Send + Sync>(io: &MonitorValue<I, T>) -> Option<Arc<dyn std::any::Any + Send + Sync>> {
|
||||
let io = io.lock().unwrap();
|
||||
io.as_ref().map(|output| output.clone() as Arc<dyn std::any::Any + Send + Sync>)
|
||||
}
|
||||
|
||||
/// Registers the Memoize and Monitor implementations for `T`, as `#[derive(node_macro::Destructure)]` does for each multi-output node struct.
|
||||
pub fn register_memoize_and_monitor<T: Clone + Send + Sync + StaticType<Static: Sized> + 'static>() {
|
||||
/// Registers the Memoize implementation for `T`, as `#[derive(node_macro::Destructure)]` does for each multi-output node struct.
|
||||
pub fn register_memoize<T: Clone + Send + Sync + StaticType<Static: Sized> + 'static>() {
|
||||
let memoize_constructor: NodeConstructor = |mut arguments| {
|
||||
let node = MemoizeNode::new(DowncastBothNode::<Context, T>::new(arguments.pop().expect("Not enough arguments provided to construct node")));
|
||||
let any: DynAnyNode<Context, _, _> = DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
};
|
||||
let monitor_constructor: NodeConstructor = |mut arguments| {
|
||||
let node = MonitorNode::new(DowncastBothNode::<Context, T>::new(arguments.pop().expect("Not enough arguments provided to construct node")));
|
||||
let any: DynAnyNode<Context, _, _> = DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
};
|
||||
|
||||
let memoize_types: NodeIOTypes = {
|
||||
let node = MemoizeNode::new(PanicNode::<Context, T>::new());
|
||||
@@ -76,16 +49,9 @@ pub fn register_memoize_and_monitor<T: Clone + Send + Sync + StaticType<Static:
|
||||
node_io.call_argument = concrete!(<Context as StaticType>::Static);
|
||||
node_io
|
||||
};
|
||||
let monitor_types: NodeIOTypes = {
|
||||
let node = MonitorNode::new(PanicNode::<Context, T>::new());
|
||||
let mut node_io = NodeIO::<Context>::to_node_io(&node, vec![fn_type!(Context, T)]);
|
||||
node_io.call_argument = concrete!(<Context as StaticType>::Static);
|
||||
node_io
|
||||
};
|
||||
|
||||
let mut registry = NODE_REGISTRY.lock().unwrap();
|
||||
registry.entry(memoize::IDENTIFIER).or_default().push((memoize_constructor, memoize_types));
|
||||
registry.entry(monitor::IDENTIFIER).or_default().push((monitor_constructor, monitor_types));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1058,12 +1058,12 @@ fn flatten_graphic(_: impl Ctx, content: List<Graphic>, fully_flatten: Item<bool
|
||||
pub fn flatten_vector(_: impl Ctx, content: List<Graphic>) -> List<Vector> {
|
||||
let mut output: List<Vector> = content.clone().into_flattened_list();
|
||||
|
||||
// TODO: Replace this snapshot hack with per-layer metadata driven by each layer's Monitor node.
|
||||
// TODO: Replace this snapshot hack with per-layer metadata driven by observing each layer's content.
|
||||
// TODO: Flattening here erases the upstream `List<Graphic>` hierarchy that editor metadata collection walks
|
||||
// TODO: to populate `upstream_footprints` / `local_transforms` / `click_targets` per child layer. As a workaround
|
||||
// TODO: we stash the pre-flattened list on the output so `List<Vector>::collect_metadata` can recurse into it,
|
||||
// TODO: which conflates render output with editor metadata and forces the pre-compensation dance below.
|
||||
// TODO: The cleaner fix is to drive each layer's metadata from its own Monitor's captured `(Context, List<Graphic>)`,
|
||||
// TODO: The cleaner fix is to drive each layer's metadata from an observation of its `List<Graphic>` content and context,
|
||||
// TODO: at which point this attribute (and the equivalents in Boolean Operation, Solidify Stroke, Combine Paths,
|
||||
// TODO: Morph, Rasterize) become unnecessary.
|
||||
if !output.is_empty() && !is_lone_anonymous_leaf(&content) {
|
||||
|
||||
@@ -315,7 +315,6 @@ impl Preprocessor {
|
||||
call_argument: input_type.clone(),
|
||||
implementation: DocumentNodeImplementation::ProtoNode(id.clone()),
|
||||
visible: true,
|
||||
skip_deduplication: false,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -371,7 +370,6 @@ impl Preprocessor {
|
||||
generated: true,
|
||||
}),
|
||||
visible: true,
|
||||
skip_deduplication: false,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -862,7 +860,7 @@ mod tests {
|
||||
assert_eq!(info.constant_inputs.count_ones(), 1, "{identifier:?} should only require its name to be constant");
|
||||
}
|
||||
|
||||
for identifier in [graphene_core::memo::memoize::IDENTIFIER, graphene_core::memo::monitor::IDENTIFIER, ops::passthrough::IDENTIFIER] {
|
||||
for identifier in [graphene_core::memo::memoize::IDENTIFIER, ops::passthrough::IDENTIFIER] {
|
||||
assert!(compile_metadata(&identifier).forwards_input, "{identifier:?} should forward its input");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,4 +103,3 @@ Since Graphene is fundamentally a programming language, throughout this document
|
||||
<!-- Guide for implementing a node -->
|
||||
<!-- The `Node` trait -->
|
||||
<!-- Generics, type inference, type erasure, and the node registry -->
|
||||
<!-- Monitor nodes -->
|
||||
Reference in new issue
Block a user