Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion document/graph-storage/src/attributes/attr.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions document/graph-storage/src/from_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand Down
11 changes: 1 addition & 10 deletions document/graph-storage/src/tests/round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
),
Expand Down Expand Up @@ -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, .. }) => {
Expand Down Expand Up @@ -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!(
Expand Down
1 change: 0 additions & 1 deletion document/graph-storage/src/to_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions document/migrations/nodes/src/graphene_core/renames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
Keavon marked this conversation as resolved.
Resolved
3 changes: 0 additions & 3 deletions editor/src/messages/portfolio/document/document_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -110,7 +107,6 @@ impl NodeTemplate {
call_argument,
implementation,
visible,
skip_deduplication,
compile_metadata: _,
original_location: _,
} = document_node;
Expand Down Expand Up @@ -161,7 +157,6 @@ impl NodeTemplate {
call_argument,
implementation,
visible,
skip_deduplication,
display_name,
input_metadata,
output_names,
Expand All @@ -179,7 +174,6 @@ impl NodeTemplate {
call_argument,
implementation,
visible,
skip_deduplication,
display_name,
mut input_metadata,
mut output_names,
Expand Down Expand Up @@ -211,7 +205,6 @@ impl NodeTemplate {
call_argument,
implementation,
visible,
skip_deduplication,
compile_metadata: None,
original_location: Default::default(),
};
Expand Down
66 changes: 53 additions & 13 deletions editor/src/messages/portfolio/document_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
})
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
})
Expand Down
11 changes: 9 additions & 2 deletions editor/src/messages/tool/tool_messages/fill_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading
Loading