mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 05:28:12 +08:00
Decouple node graph execution (#1209)
* Decouple node graph execution from the main loop * Trigger document Render + Layer updates after the graph evaluation
This commit is contained in:
@@ -137,8 +137,8 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
reverse_index,
|
||||
} => responses.add(MoveSelectedLayersTo {
|
||||
folder_path: folder_path.clone(),
|
||||
insert_index: insert_index.clone(),
|
||||
reverse_index: reverse_index.clone(),
|
||||
insert_index: *insert_index,
|
||||
reverse_index: *reverse_index,
|
||||
}),
|
||||
DocumentResponse::CreatedLayer { path, is_selected } => {
|
||||
if self.layer_metadata.contains_key(path) {
|
||||
|
||||
+9
-8
@@ -1,21 +1,19 @@
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::utility_types::ImaginateServerStatus;
|
||||
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::layers::layer_info::LayerDataTypeDiscriminant;
|
||||
use document_legacy::Operation;
|
||||
use glam::DVec2;
|
||||
use graph_craft::concrete;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, NodeId, NodeInput};
|
||||
use graph_craft::{concrete, imaginate_input::*};
|
||||
use graphene_core::raster::{BlendMode, Color, ImageFrame, LuminanceCalculation, RedGreenBlue, RelativeAbsolute, SelectiveColorChoice};
|
||||
use graphene_core::text::Font;
|
||||
use graphene_core::vector::style::{FillType, GradientType, LineCap, LineJoin};
|
||||
use graphene_core::EditorApi;
|
||||
|
||||
use graphene_core::{Cow, Type, TypeDescriptor};
|
||||
|
||||
use super::document_node_types::NodePropertiesContext;
|
||||
use super::{FrontendGraphDataType, IMAGINATE_NODE};
|
||||
use super::FrontendGraphDataType;
|
||||
|
||||
pub fn string_properties(text: impl Into<String>) -> Vec<LayoutGroup> {
|
||||
let widget = WidgetHolder::text_widget(text);
|
||||
@@ -731,7 +729,7 @@ pub fn adjust_selective_color_properties(document_node: &DocumentNode, node_id:
|
||||
.into_iter()
|
||||
.map(|section| {
|
||||
section
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|choice| DropdownEntryData::new(choice.to_string()).on_update(update_value(move |_| TaggedValue::SelectiveColorChoice(*choice), node_id, colors_index)))
|
||||
.collect()
|
||||
})
|
||||
@@ -956,7 +954,8 @@ pub fn node_section_font(document_node: &DocumentNode, node_id: NodeId, _context
|
||||
result
|
||||
}
|
||||
|
||||
pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
pub fn imaginate_properties(_document_node: &DocumentNode, _node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
/*
|
||||
let imaginate_node = [context.nested_path, &[node_id]].concat();
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
|
||||
@@ -1513,6 +1512,8 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
layout.extend_from_slice(&[improve_faces, tiling]);
|
||||
|
||||
layout
|
||||
*/
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn unknown_node_properties(document_node: &DocumentNode) -> Vec<LayoutGroup> {
|
||||
|
||||
@@ -22,7 +22,7 @@ use graph_craft::document::{NodeId, NodeInput};
|
||||
use graphene_core::raster::Image;
|
||||
use graphene_core::text::Font;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PortfolioMessageHandler {
|
||||
menu_bar_message_handler: MenuBarMessageHandler,
|
||||
documents: HashMap<u64, DocumentMessageHandler>,
|
||||
@@ -215,6 +215,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
}
|
||||
|
||||
self.persistent_data.font_cache.insert(font, preview_url, data, is_default);
|
||||
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
|
||||
}
|
||||
PortfolioMessage::ImaginateCheckServerStatus => {
|
||||
self.persistent_data.imaginate_server_status = ImaginateServerStatus::Checking;
|
||||
@@ -456,7 +457,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
||||
size,
|
||||
imaginate_node_path,
|
||||
} => {
|
||||
let result = self.executor.evaluate_node_graph(
|
||||
let result = self.executor.submit_node_graph_evaluation(
|
||||
(document_id, &mut self.documents),
|
||||
layer_path,
|
||||
(input_image_data, size),
|
||||
@@ -690,4 +691,10 @@ impl PortfolioMessageHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn poll_node_graph_evaluation(&mut self, responses: &mut VecDeque<Message>) {
|
||||
self.executor.poll_node_graph_evaluation(responses).unwrap_or_else(|e| {
|
||||
log::error!("Error while evaluating node graph: {}", e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ impl OverlayRenderer {
|
||||
// Eventually will get replaced with am immediate mode renderer for overlays
|
||||
}
|
||||
}
|
||||
responses.add(OverlaysMessage::Rerender);
|
||||
}
|
||||
|
||||
pub fn clear_subpath_overlays(&mut self, document: &Document, layer_path: Vec<LayerId>, responses: &mut VecDeque<Message>) {
|
||||
|
||||
@@ -219,7 +219,7 @@ impl ShapeState {
|
||||
let Ok(layer) = document.layer(layer_path) else { continue };
|
||||
let Some(vector_data) = layer.as_vector_data() else { continue };
|
||||
|
||||
let opposing_handle_lengths = opposing_handle_lengths.as_ref().map(|lengths| lengths.get(layer_path)).flatten();
|
||||
let opposing_handle_lengths = opposing_handle_lengths.as_ref().and_then(|lengths| lengths.get(layer_path));
|
||||
|
||||
let transform = document.multiply_transforms(layer_path).unwrap_or(glam::DAffine2::IDENTITY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user