mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 03:18:06 +08:00
Imaginate fixes (#1200)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -131,12 +131,14 @@ impl NodeGraphExecutor {
|
||||
imaginate_node_path: Vec<NodeId>,
|
||||
(document, document_id): (&mut DocumentMessageHandler, u64),
|
||||
layer_path: Vec<LayerId>,
|
||||
editor_api: EditorApi<'_>,
|
||||
mut editor_api: EditorApi<'_>,
|
||||
(preferences, persistent_data): (&PreferencesMessageHandler, &PersistentData),
|
||||
) -> Result<Message, String> {
|
||||
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::<bool>(&network, &imaginate_node_path, get("Adapt Input Image"), Cow::Borrowed(&editor_api))?;
|
||||
|
||||
editor_api.image_frame = image;
|
||||
let input_image_frame: Option<ImageFrame<Color>> = if use_base_image {
|
||||
Some(self.compute_input::<ImageFrame<Color>>(&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),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user