diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index fa3729ee..a26206d6 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -981,7 +981,7 @@ impl DocumentMessageHandler { // Check if we use the "Input Frame" node. // TODO: Remove once rasterization is moved into a node. let input_frame_node_id = node_network.nodes.iter().find(|(_, node)| node.name == "Input Frame").map(|(&id, _)| id); - let input_frame_connected_to_graph_output = input_frame_node_id.map_or(false, |target_node_id| node_network.connected_to_output(target_node_id, true)); + let input_frame_connected_to_graph_output = input_frame_node_id.map_or(false, |target_node_id| node_network.connected_to_output(target_node_id, imaginate_node_path.is_none())); // If the Input Frame node is connected upstream, rasterize the artwork below this layer by calling into JS let response = if input_frame_connected_to_graph_output { diff --git a/editor/src/node_graph_executor.rs b/editor/src/node_graph_executor.rs index e7d8d0f4..4f6dc9b6 100644 --- a/editor/src/node_graph_executor.rs +++ b/editor/src/node_graph_executor.rs @@ -131,12 +131,14 @@ impl NodeGraphExecutor { imaginate_node_path: Vec, (document, document_id): (&mut DocumentMessageHandler, u64), layer_path: Vec, - editor_api: EditorApi<'_>, + mut editor_api: EditorApi<'_>, (preferences, persistent_data): (&PreferencesMessageHandler, &PersistentData), ) -> Result { use crate::messages::portfolio::document::node_graph::IMAGINATE_NODE; use graph_craft::imaginate_input::*; + let image = editor_api.image_frame.take(); + let get = |name: &str| IMAGINATE_NODE.inputs.iter().position(|input| input.name == name).unwrap_or_else(|| panic!("Input {name} not found")); // Get the node graph layer @@ -166,6 +168,7 @@ impl NodeGraphExecutor { }; let use_base_image = self.compute_input::(&network, &imaginate_node_path, get("Adapt Input Image"), Cow::Borrowed(&editor_api))?; + editor_api.image_frame = image; let input_image_frame: Option> = if use_base_image { Some(self.compute_input::>(&network, &imaginate_node_path, get("Input Image"), Cow::Borrowed(&editor_api))?) } else { @@ -257,7 +260,7 @@ impl NodeGraphExecutor { let transform = DAffine2::IDENTITY; let image_frame = ImageFrame { image, transform }; let editor_api = EditorApi { - image_frame: Some(&image_frame), + image_frame: Some(image_frame), font_cache: Some(&persistent_data.1.font_cache), }; diff --git a/node-graph/gcore/src/raster/image.rs b/node-graph/gcore/src/raster/image.rs index d5d04416..a0fcbc9b 100644 --- a/node-graph/gcore/src/raster/image.rs +++ b/node-graph/gcore/src/raster/image.rs @@ -245,7 +245,7 @@ impl ImageFrame

{ pub const fn empty() -> Self { Self { image: Image::empty(), - transform: DAffine2::ZERO, + transform: DAffine2::IDENTITY, } } @@ -281,7 +281,7 @@ use crate::text::FontCache; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EditorApi<'a> { #[cfg_attr(feature = "serde", serde(skip))] - pub image_frame: Option<&'a ImageFrame>, + pub image_frame: Option>, #[cfg_attr(feature = "serde", serde(skip))] pub font_cache: Option<&'a FontCache>, } @@ -306,8 +306,8 @@ pub struct ExtractImageFrame; impl<'a: 'input, 'input> Node<'input, EditorApi<'a>> for ExtractImageFrame { type Output = ImageFrame; - fn eval(&'input self, editor_api: EditorApi<'a>) -> Self::Output { - editor_api.image_frame.cloned().unwrap_or(ImageFrame::empty()) + fn eval(&'input self, mut editor_api: EditorApi<'a>) -> Self::Output { + editor_api.image_frame.take().unwrap_or(ImageFrame::empty()) } }