@@ -7,6 +7,7 @@ use graph_craft::proto::GraphErrors;
77use graph_craft:: wasm_application_io:: EditorPreferences ;
88use graphene_std:: application_io:: { NodeGraphUpdateMessage , RenderConfig } ;
99use graphene_std:: application_io:: { SurfaceFrame , TimingInformation } ;
10+ use graphene_std:: raster:: { CPU , Raster } ;
1011use graphene_std:: renderer:: { RenderMetadata , format_transform_matrix} ;
1112use graphene_std:: text:: FontCache ;
1213use graphene_std:: transform:: Footprint ;
@@ -44,6 +45,7 @@ pub struct CompilationResponse {
4445pub enum NodeGraphUpdate {
4546 ExecutionResponse ( ExecutionResponse ) ,
4647 CompilationResponse ( CompilationResponse ) ,
48+ EyedropperPreview ( Raster < CPU > ) ,
4749 NodeGraphUpdateMessage ( NodeGraphUpdateMessage ) ,
4850}
4951
@@ -59,7 +61,6 @@ pub struct NodeGraphExecutor {
5961
6062#[ derive( Debug , Clone ) ]
6163struct ExecutionContext {
62- render_config : RenderConfig ,
6364 export_config : Option < ExportConfig > ,
6465 document_id : DocumentId ,
6566}
@@ -164,14 +165,7 @@ impl NodeGraphExecutor {
164165 // Execute the node graph
165166 let execution_id = self . queue_execution ( render_config) ;
166167
167- self . futures . push_back ( (
168- execution_id,
169- ExecutionContext {
170- render_config,
171- export_config : None ,
172- document_id,
173- } ,
174- ) ) ;
168+ self . futures . push_back ( ( execution_id, ExecutionContext { export_config : None , document_id } ) ) ;
175169
176170 Ok ( DeferMessage :: SetGraphSubmissionIndex { execution_id } . into ( ) )
177171 }
@@ -194,15 +188,23 @@ impl NodeGraphExecutor {
194188 }
195189
196190 #[ cfg( not( target_family = "wasm" ) ) ]
197- pub ( crate ) fn submit_eyedropper_preview ( & mut self , document_id : DocumentId , transform : DAffine2 , pointer : DVec2 , resolution : UVec2 , time : TimingInformation ) -> Result < Message , String > {
191+ pub ( crate ) fn submit_eyedropper_preview (
192+ & mut self ,
193+ document_id : DocumentId ,
194+ transform : DAffine2 ,
195+ pointer : DVec2 ,
196+ viewport_resolution : UVec2 ,
197+ viewport_scale : f64 ,
198+ time : TimingInformation ,
199+ ) -> Result < Message , String > {
198200 let viewport = Footprint {
199201 transform,
200- resolution,
202+ resolution : viewport_resolution ,
201203 ..Default :: default ( )
202204 } ;
203205 let render_config = RenderConfig {
204206 viewport,
205- scale : 1. ,
207+ scale : viewport_scale ,
206208 time,
207209 pointer,
208210 export_format : graphene_std:: application_io:: ExportFormat :: Raster ,
@@ -215,14 +217,7 @@ impl NodeGraphExecutor {
215217 // Execute the node graph
216218 let execution_id = self . queue_execution ( render_config) ;
217219
218- self . futures . push_back ( (
219- execution_id,
220- ExecutionContext {
221- render_config,
222- export_config : None ,
223- document_id,
224- } ,
225- ) ) ;
220+ self . futures . push_back ( ( execution_id, ExecutionContext { export_config : None , document_id } ) ) ;
226221
227222 Ok ( DeferMessage :: SetGraphSubmissionIndex { execution_id } . into ( ) )
228223 }
@@ -272,7 +267,6 @@ impl NodeGraphExecutor {
272267 self . futures . push_back ( (
273268 execution_id,
274269 ExecutionContext {
275- render_config,
276270 export_config : Some ( export_config) ,
277271 document_id,
278272 } ,
@@ -325,9 +319,6 @@ impl NodeGraphExecutor {
325319 if let Some ( export_config) = execution_context. export_config {
326320 // Special handling for exporting the artwork
327321 self . process_export ( node_graph_output, export_config, responses) ?;
328- } else if execution_context. render_config . for_eyedropper {
329- // Special handling for Eyedropper tool preview
330- self . process_eyedropper_preview ( node_graph_output, responses) ?;
331322 } else {
332323 self . process_node_graph_output ( node_graph_output, responses) ?;
333324 }
@@ -371,6 +362,10 @@ impl NodeGraphExecutor {
371362 } ) ;
372363 responses. add ( NodeGraphMessage :: SendGraph ) ;
373364 }
365+ NodeGraphUpdate :: EyedropperPreview ( raster) => {
366+ let ( data, width, height) = raster. to_flat_u8 ( ) ;
367+ responses. add ( EyedropperToolMessage :: PreviewImage { data, width, height } ) ;
368+ }
374369 }
375370 }
376371
@@ -431,23 +426,6 @@ impl NodeGraphExecutor {
431426 Ok ( ( ) )
432427 }
433428
434- fn process_eyedropper_preview ( & self , node_graph_output : TaggedValue , responses : & mut VecDeque < Message > ) -> Result < ( ) , String > {
435- match node_graph_output {
436- #[ cfg( feature = "gpu" ) ]
437- TaggedValue :: RenderOutput ( RenderOutput {
438- data : RenderOutputType :: Buffer { data, width, height } ,
439- ..
440- } ) => {
441- responses. add ( EyedropperToolMessage :: PreviewImage { data, width, height } ) ;
442- }
443- _ => {
444- // TODO: Support Eyedropper preview in SVG mode on desktop
445- }
446- } ;
447-
448- Ok ( ( ) )
449- }
450-
451429 fn process_export ( & self , node_graph_output : TaggedValue , export_config : ExportConfig , responses : & mut VecDeque < Message > ) -> Result < ( ) , String > {
452430 let ExportConfig {
453431 file_type,
0 commit comments