From 39ce55ab61cca19bf9fb3cc666ce6209e16836f6 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 5 Sep 2026 12:17:06 +0000 Subject: [PATCH] Convert rasterize to an async record source with an owned merged-layers write --- .../node_graph/document_node_definitions.rs | 1 + node-graph/node-macro/src/codegen.rs | 8 ++++--- .../nodes/gstd/src/platform_application_io.rs | 22 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index 8b9497a4ee..b8391b8f4f 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -1038,6 +1038,7 @@ fn document_node_definitions() -> HashMap *list_levels > 0 && type_contains_ident(ty, ident), + regular_fields.iter().enumerate().any(|(index, field)| match &field.ty { + ParsedFieldType::Regular(RegularParsedField { ty, list_levels, .. }) => (*list_levels > 0 || (record_io && index > 0)) && type_contains_ident(ty, ident), _ => false, }) }; diff --git a/node-graph/nodes/gstd/src/platform_application_io.rs b/node-graph/nodes/gstd/src/platform_application_io.rs index 3f06a0cc13..0fb37a04d0 100644 --- a/node-graph/nodes/gstd/src/platform_application_io.rs +++ b/node-graph/nodes/gstd/src/platform_application_io.rs @@ -5,7 +5,9 @@ use canvas_utils::{Canvas, CanvasHandle}; use core_types::color::SRGBA8; use core_types::gpoll::GPoll; #[cfg(target_family = "wasm")] -use core_types::list::{Item, List}; +use core_types::attribute::{Attr, OwnedAttr, Transform}; +#[cfg(target_family = "wasm")] +use core_types::list::List; #[cfg(target_family = "wasm")] use core_types::math::bbox::Bbox; @@ -21,10 +23,10 @@ pub use graph_craft::document::value::RenderOutputType; #[cfg(target_family = "wasm")] pub use graphene_canvas_utils as canvas_utils; #[cfg(target_family = "wasm")] -use graphic_types::ATTR_EDITOR_MERGED_LAYERS; -#[cfg(target_family = "wasm")] use graphic_types::Graphic; #[cfg(target_family = "wasm")] +use graphic_types::markers::EditorMergedLayers; +#[cfg(target_family = "wasm")] use graphic_types::IntoGraphicList; #[cfg(target_family = "wasm")] use graphic_types::Vector; @@ -204,6 +206,7 @@ fn create_canvas(_: impl Ctx) -> CanvasHandle { #[node_macro::node(category(""))] async fn rasterize( _: impl Ctx, + _: (), #[implementations( List, List>, @@ -214,7 +217,7 @@ async fn rasterize( mut data: List, footprint: Footprint, mut canvas: CanvasHandle, -) -> List> +) -> (Raster, Attr, OwnedAttr) where List: Render + Clone + graphic_types::IntoGraphicList, { @@ -222,12 +225,15 @@ where if footprint.transform.matrix2.determinant() == 0. { log::trace!("Invalid footprint received for rasterization"); - return List::new(); + // A zero-size raster renders as nothing, matching the legacy empty list + return (Raster::new_cpu(Image::default()), Attr(DAffine2::IDENTITY), OwnedAttr::new(None)); } // Snapshot the input as a List so the renderer can recurse into the original child layers // when collecting metadata, exposing their click targets to editor tools (same mechanism as Boolean Operation). + // The copy is owned before the first await: the input's arena content dies with the spawning evaluation. let upstream_graphic_list = data.clone().into_graphic_list(); + let merged_layers = OwnedAttr::new(Some(&upstream_graphic_list)); let mut render = SvgRender::new(); let aabb = Bbox::from_transform(footprint.transform).to_axis_aligned_bbox(); @@ -264,11 +270,7 @@ where let rasterized = context.get_image_data(0, 0, resolution.x as i32, resolution.y as i32).unwrap(); let image = Image::from_image_data(&rasterized.data().0, resolution.x as u32, resolution.y as u32); - List::new_from_item( - Item::new_from_element(Raster::new_cpu(image)) - .with_attribute(ATTR_TRANSFORM, footprint.transform) - .with_attribute(ATTR_EDITOR_MERGED_LAYERS, Some(upstream_graphic_list)), - ) + (Raster::new_cpu(image), Attr(footprint.transform), merged_layers) } #[node_macro::node(category(""), inject_scope)]