@@ -24,9 +24,11 @@ use graphene_std::renderer::format_transform_matrix;
2424use graphene_std:: wasm_application_io:: { WasmApplicationIo , WasmEditorApi } ;
2525use interpreted_executor:: dynamic_executor:: { DynamicExecutor , IntrospectError , ResolvedDocumentNodeTypesDelta } ;
2626
27+ use core:: hash;
2728use glam:: { DAffine2 , DVec2 , UVec2 } ;
2829use once_cell:: sync:: Lazy ;
2930use spin:: Mutex ;
31+ use std:: hash:: Hash ;
3032use std:: sync:: mpsc:: { Receiver , Sender } ;
3133use std:: sync:: Arc ;
3234
@@ -52,8 +54,6 @@ pub struct NodeRuntime {
5254 click_targets : HashMap < NodeId , Vec < ClickTarget > > ,
5355 /// Vector data in Path nodes.
5456 vector_modify : HashMap < NodeId , VectorData > ,
55- /// The current upstream transforms for nodes.
56- upstream_transforms : HashMap < NodeId , ( Footprint , DAffine2 ) > ,
5757}
5858
5959/// Messages passed from the editor thread to the node runtime thread.
@@ -85,7 +85,6 @@ pub struct ExecutionResponse {
8585 responses : VecDeque < FrontendMessage > ,
8686 new_click_targets : HashMap < LayerNodeIdentifier , Vec < ClickTarget > > ,
8787 new_vector_modify : HashMap < NodeId , VectorData > ,
88- new_upstream_transforms : HashMap < NodeId , ( Footprint , DAffine2 ) > ,
8988 transform : DAffine2 ,
9089}
9190
@@ -146,7 +145,6 @@ impl NodeRuntime {
146145 thumbnail_renders : Default :: default ( ) ,
147146 click_targets : HashMap :: new ( ) ,
148147 vector_modify : HashMap :: new ( ) ,
149- upstream_transforms : HashMap :: new ( ) ,
150148 }
151149 }
152150
@@ -228,7 +226,6 @@ impl NodeRuntime {
228226 responses,
229227 new_click_targets : self . click_targets . clone ( ) . into_iter ( ) . map ( |( id, targets) | ( LayerNodeIdentifier :: new_unchecked ( id) , targets) ) . collect ( ) ,
230228 new_vector_modify : self . vector_modify . clone ( ) ,
231- new_upstream_transforms : self . upstream_transforms . clone ( ) ,
232229 transform,
233230 } ) ;
234231 }
@@ -310,19 +307,19 @@ impl NodeRuntime {
310307
311308 // If this is `VectorData`, `ImageFrame`, or `GraphicElement` data:
312309 // Update the stored upstream transforms for this layer/node.
313- if let Some ( transform) = {
314- fn try_downcast < T : Transform + ' static > ( value : & dyn std:: any:: Any ) -> Option < ( Footprint , DAffine2 ) > {
315- let io_data = value. downcast_ref :: < IORecord < Footprint , T > > ( ) ?;
316- let transform = io_data. output . transform ( ) ;
317- Some ( ( io_data. input , transform) )
318- }
319- None . or_else ( || try_downcast :: < VectorData > ( introspected_data. as_ref ( ) ) )
320- . or_else ( || try_downcast :: < ImageFrame < Color > > ( introspected_data. as_ref ( ) ) )
321- . or_else ( || try_downcast :: < GraphicElement > ( introspected_data. as_ref ( ) ) )
322- . or_else ( || try_downcast :: < graphene_core:: Artboard > ( introspected_data. as_ref ( ) ) )
323- } {
324- self . upstream_transforms . insert ( parent_network_node_id, transform) ;
325- }
310+ // if let Some(transform) = {
311+ // fn try_downcast<T: Transform + 'static>(value: &dyn std::any::Any) -> Option<(Footprint, DAffine2)> {
312+ // let io_data = value.downcast_ref::<IORecord<Footprint, T>>()?;
313+ // let transform = io_data.output.transform();
314+ // Some((io_data.input, transform))
315+ // }
316+ // None.or_else(|| try_downcast::<VectorData>(introspected_data.as_ref()))
317+ // .or_else(|| try_downcast::<ImageFrame<Color>>(introspected_data.as_ref()))
318+ // .or_else(|| try_downcast::<GraphicElement>(introspected_data.as_ref()))
319+ // .or_else(|| try_downcast::<graphene_core::Artboard>(introspected_data.as_ref()))
320+ // } {
321+ // self.upstream_transforms.insert(parent_network_node_id, transform);
322+ // }
326323 }
327324 }
328325
@@ -537,7 +534,7 @@ impl NodeGraphExecutor {
537534
538535 fn export ( & self , node_graph_output : TaggedValue , export_config : ExportConfig , responses : & mut VecDeque < Message > ) -> Result < ( ) , String > {
539536 let TaggedValue :: RenderOutput ( graphene_std:: wasm_application_io:: RenderOutput :: Svg ( ( svg, _) ) ) = node_graph_output else {
540- return Err ( "Incorrect render type for exportign (expected RenderOutput::Svg)" . to_string ( ) ) ;
537+ return Err ( "Incorrect render type for exporting (expected RenderOutput::Svg)" . to_string ( ) ) ;
541538 } ;
542539
543540 let ExportConfig {
@@ -575,7 +572,6 @@ impl NodeGraphExecutor {
575572 new_click_targets,
576573 responses : existing_responses,
577574 new_vector_modify,
578- new_upstream_transforms,
579575 transform,
580576 } = execution_response;
581577
@@ -585,15 +581,17 @@ impl NodeGraphExecutor {
585581 Ok ( output) => output,
586582 Err ( e) => {
587583 // Clear the click targets while the graph is in an un-renderable state
588- document. network_interface . document_metadata_mut ( ) . update_from_monitor ( HashMap :: new ( ) , HashMap :: new ( ) ) ;
589-
584+ // responses.add(DocumentMessage::UpdateUpstreamTransforms { upstream_transforms: HashMap::new() });
585+ // responses.add(DocumentMessage::UpdateClickTargets { click_targets: HashMap::new() });
586+ document. network_interface . update_click_targets ( HashMap :: new ( ) ) ;
587+ document. network_interface . update_vector_modify ( HashMap :: new ( ) ) ;
590588 return Err ( format ! ( "Node graph evaluation failed:\n {e}" ) ) ;
591589 }
592590 } ;
593591
594592 responses. extend ( existing_responses. into_iter ( ) . map ( Into :: into) ) ;
595- // document.network_interface.document_metadata_mut().update_transforms(new_upstream_transforms );
596- document. network_interface . document_metadata_mut ( ) . update_from_monitor ( new_click_targets , new_vector_modify) ;
593+ document. network_interface . update_click_targets ( new_click_targets ) ;
594+ document. network_interface . update_vector_modify ( new_vector_modify) ;
597595
598596 let execution_context = self . futures . remove ( & execution_id) . ok_or_else ( || "Invalid generation ID" . to_string ( ) ) ?;
599597 if let Some ( export_config) = execution_context. export_config {
@@ -608,7 +606,13 @@ impl NodeGraphExecutor {
608606 let type_delta = match result {
609607 Err ( e) => {
610608 // Clear the click targets while the graph is in an un-renderable state
611- document. network_interface . document_metadata_mut ( ) . update_from_monitor ( HashMap :: new ( ) , HashMap :: new ( ) ) ;
609+
610+ document. network_interface . update_click_targets ( HashMap :: new ( ) ) ;
611+ document. network_interface . update_vector_modify ( HashMap :: new ( ) ) ;
612+
613+ // responses.add(DocumentMessage::UpdateUpstreamTransforms { upstream_transforms: HashMap::new() });
614+ // .add(DocumentMessage::UpdateClickTargets { click_targets: HashMap::new() });
615+
612616 log:: trace!( "{e}" ) ;
613617
614618 responses. add ( NodeGraphMessage :: UpdateTypes {
@@ -664,6 +668,8 @@ impl NodeGraphExecutor {
664668 responses. add ( DocumentMessage :: RenderScrollbars ) ;
665669 responses. add ( DocumentMessage :: RenderRulers ) ;
666670 responses. add ( DocumentMessage :: UpdateUpstreamTransforms { upstream_transforms : footprints } ) ;
671+ // responses.add(DocumentMessage::UpdateClickTargets { click_targets });
672+ // responses.add(DocumentMessage::UpdateVectorModify { vector_modify });
667673 responses. add ( OverlaysMessage :: Draw ) ;
668674 }
669675
0 commit comments