Run cargo fmt

This commit is contained in:
Dennis Kobert
2026-08-29 18:40:02 +00:00
parent 97bc10e4c3
commit a955d6b458
16 changed files with 164 additions and 111 deletions
+1 -4
View File
@@ -503,10 +503,7 @@ impl NodeRuntime {
// SAFETY: the batch is resident for the read. // SAFETY: the batch is resident for the read.
let item = unsafe { GroupItem::from_resident(batch) }; let item = unsafe { GroupItem::from_resident(batch) };
let bounds = graphene_std::renderer::graphic_list_bounding_box(&RunView::<Graphic>::new(&item)?, DAffine2::IDENTITY); let bounds = graphene_std::renderer::graphic_list_bounding_box(&RunView::<Graphic>::new(&item)?, DAffine2::IDENTITY);
let group = Graphic::Group(Group { let group = Graphic::Group(Group { row: None, content: item });
row: None,
content: item,
});
Self::render_thumbnail(thumbnail_renders, parent_network_node_id, &group, bounds, responses) Self::render_thumbnail(thumbnail_renders, parent_network_node_id, &group, bounds, responses)
} }
Some(()) Some(())
@@ -167,11 +167,7 @@ impl DynamicExecutor {
/// introspection window. The monitor stores only the context; the value is /// introspection window. The monitor stores only the context; the value is
/// recreated against current source data, so a read right after an /// recreated against current source data, so a read right after an
/// execution serves out of the warm memo entries. /// execution serves out of the warm memo entries.
pub fn introspect_with<R>( pub fn introspect_with<R>(&self, node_path: &[NodeId], read: impl FnOnce(&core_types::record::Layout, core_types::node::RecordBatch<'_>, &Arena) -> Option<R>) -> Result<R, IntrospectError> {
&self,
node_path: &[NodeId],
read: impl FnOnce(&core_types::record::Layout, core_types::node::RecordBatch<'_>, &Arena) -> Option<R>,
) -> Result<R, IntrospectError> {
let serialized = self.tree.introspect(node_path)?; let serialized = self.tree.introspect(node_path)?;
let Some(snapshot) = serialized.downcast_ref::<core_types::context::CtxSnapshot>() else { let Some(snapshot) = serialized.downcast_ref::<core_types::context::CtxSnapshot>() else {
return Err(IntrospectError::NoData); return Err(IntrospectError::NoData);
+22 -9
View File
@@ -1507,11 +1507,7 @@ impl SourcePlan {
.filter(|field| source.offset_of(field.name, field.level).is_none()) .filter(|field| source.offset_of(field.name, field.level).is_none())
.map(|field| (field.offset, default_fill_bytes(field.name, field.size))) .map(|field| (field.offset, default_fill_bytes(field.name, field.size)))
.collect(); .collect();
Some(SourcePlan { Some(SourcePlan { moves, fills, source: source.clone() })
moves,
fills,
source: source.clone(),
})
} }
/// # Safety /// # Safety
@@ -1887,7 +1883,12 @@ impl ServedRecord {
/// markers. Panics unless the field is declared at `T` and byte-carried; /// markers. Panics unless the field is declared at `T` and byte-carried;
/// a parked field reads through replay, not the captured bytes. /// a parked field reads through replay, not the captured bytes.
pub fn field<T: Copy + 'static>(&self, name: &str, level: u8) -> T { pub fn field<T: Copy + 'static>(&self, name: &str, level: u8) -> T {
let field = self.layout.fields.iter().find(|field| field.name == name && field.level == level).expect("the layout carries the read field"); let field = self
.layout
.fields
.iter()
.find(|field| field.name == name && field.level == level)
.expect("the layout carries the read field");
assert_eq!(field.type_id, std::any::TypeId::of::<T>(), "the field was declared at this value type"); assert_eq!(field.type_id, std::any::TypeId::of::<T>(), "the field was declared at this value type");
assert!(field.repark.is_none(), "a parked field reads through replay, not the captured bytes"); assert!(field.repark.is_none(), "a parked field reads through replay, not the captured bytes");
// SAFETY: the captured bytes image a record of this layout and the // SAFETY: the captured bytes image a record of this layout and the
@@ -2076,7 +2077,11 @@ impl<'e> RunBuilder<'e> {
/// Starts the next lane: moves its element in and default-fills its /// Starts the next lane: moves its element in and default-fills its
/// fields. Returns the lane index; `None` reports arena exhaustion. /// fields. Returns the lane index; `None` reports arena exhaustion.
pub fn push<T: Send + Sync + dyn_any::StaticTypeSized>(&mut self, element: T) -> Option<usize> { pub fn push<T: Send + Sync + dyn_any::StaticTypeSized>(&mut self, element: T) -> Option<usize> {
assert_eq!(std::any::TypeId::of::<T::Static>(), self.layout.element.type_id, "the pushed element must match the layout's element type"); assert_eq!(
std::any::TypeId::of::<T::Static>(),
self.layout.element.type_id,
"the pushed element must match the layout's element type"
);
assert!(self.pushed < self.len, "the builder holds exactly its declared lane count"); assert!(self.pushed < self.len, "the builder holds exactly its declared lane count");
let lane = self.pushed; let lane = self.pushed;
let stride = self.layout.lane_stride(); let stride = self.layout.lane_stride();
@@ -2106,7 +2111,12 @@ impl<'e> RunBuilder<'e> {
A::Value<'static>: 'static, A::Value<'static>: 'static,
{ {
assert!(lane < self.pushed, "attributes write onto pushed lanes"); assert!(lane < self.pushed, "attributes write onto pushed lanes");
let field = self.layout.fields.iter().find(|field| field.name == A::NAME && field.level == 0).expect("the layout carries the written marker"); let field = self
.layout
.fields
.iter()
.find(|field| field.name == A::NAME && field.level == 0)
.expect("the layout carries the written marker");
let offset = field.offset; let offset = field.offset;
assert_eq!(field.type_id, std::any::TypeId::of::<A::Value<'static>>(), "the field was declared at the marker's value type"); assert_eq!(field.type_id, std::any::TypeId::of::<A::Value<'static>>(), "the field was declared at the marker's value type");
// SAFETY: the offset comes from the builder's own layout and the value // SAFETY: the offset comes from the builder's own layout and the value
@@ -2445,7 +2455,10 @@ impl<'a, T: dyn_any::StaticTypeSized> crate::lane::LaneSource for RunView<'a, T>
impl<T: crate::render_complexity::RenderComplexity + dyn_any::StaticTypeSized> crate::render_complexity::RenderComplexity for RunView<'_, T> { impl<T: crate::render_complexity::RenderComplexity + dyn_any::StaticTypeSized> crate::render_complexity::RenderComplexity for RunView<'_, T> {
fn render_complexity(&self) -> usize { fn render_complexity(&self) -> usize {
use crate::lane::LaneSource; use crate::lane::LaneSource;
(0..self.lane_count()).filter_map(|lane| self.element(lane)).map(crate::render_complexity::RenderComplexity::render_complexity).sum() (0..self.lane_count())
.filter_map(|lane| self.element(lane))
.map(crate::render_complexity::RenderComplexity::render_complexity)
.sum()
} }
} }
@@ -33,13 +33,7 @@ where
LevelStatus::Batch(batch, finality) => { LevelStatus::Batch(batch, finality) => {
// SAFETY: a materialized batch's frames are arena-resident. // SAFETY: a materialized batch's frames are arena-resident.
let item = unsafe { GroupItem::from_resident(batch) }; let item = unsafe { GroupItem::from_resident(batch) };
LevelGroup::Group( LevelGroup::Group(Group { row: None, content: item }, finality)
Group {
row: None,
content: item,
},
finality,
)
} }
LevelStatus::Pending => LevelGroup::Pending, LevelStatus::Pending => LevelGroup::Pending,
LevelStatus::Error(error) => LevelGroup::Error(error), LevelStatus::Error(error) => LevelGroup::Error(error),
@@ -80,10 +74,7 @@ pub fn batch_to_legacy(layout: &core_types::record::Layout, batch: core_types::n
run_to_legacy_list::<T>(item).map(|list| Box::new(list) as Box<dyn std::any::Any + Send + Sync>) run_to_legacy_list::<T>(item).map(|list| Box::new(list) as Box<dyn std::any::Any + Send + Sync>)
} }
if item.typed_lanes::<Graphic>().is_some() { if item.typed_lanes::<Graphic>().is_some() {
let group = Group { let group = Group { row: None, content: item };
row: None,
content: item,
};
return Some(Box::new(group_to_legacy_list(&group))); return Some(Box::new(group_to_legacy_list(&group)));
} }
fn typed_artboards(item: &GroupItem) -> Option<Box<dyn std::any::Any + Send + Sync>> { fn typed_artboards(item: &GroupItem) -> Option<Box<dyn std::any::Any + Send + Sync>> {
@@ -999,13 +999,7 @@ impl VectorRow<'_> {
} }
} }
fn walk_rows_of_run( fn walk_rows_of_run(item: &core_types::record::GroupItem, scale: FlattenScale, layer_path: Option<&[NodeId]>, paint: LanePaint<'_>, visit: &mut dyn FnMut(VectorRow<'_>) -> RowStep) -> RowStep {
item: &core_types::record::GroupItem,
scale: FlattenScale,
layer_path: Option<&[NodeId]>,
paint: LanePaint<'_>,
visit: &mut dyn FnMut(VectorRow<'_>) -> RowStep,
) -> RowStep {
let Some(run) = core_types::record::RunView::<Vector>::new(item) else { let Some(run) = core_types::record::RunView::<Vector>::new(item) else {
return RowStep::Continue; return RowStep::Continue;
}; };
@@ -1548,10 +1542,7 @@ mod run_tests {
let mut builder = RunBuilder::new(&source, element_write_hashed::<Vector>(), &[FieldWrite::of::<Fill>(0)], 1).unwrap(); let mut builder = RunBuilder::new(&source, element_write_hashed::<Vector>(), &[FieldWrite::of::<Fill>(0)], 1).unwrap();
let lane = builder.push(vector.clone()).unwrap(); let lane = builder.push(vector.clone()).unwrap();
builder.attr::<Fill>(lane, Some(&paint)); builder.attr::<Fill>(lane, Some(&paint));
let group = core_types::record::Group { let group = core_types::record::Group { row: None, content: builder.finish() };
row: None,
content: builder.finish(),
};
let expected = group_to_legacy_list(&group); let expected = group_to_legacy_list(&group);
let owned = map_groups_to_owned(&Graphic::Group(group)); let owned = map_groups_to_owned(&Graphic::Group(group));
drop(source); drop(source);
@@ -1568,17 +1559,11 @@ mod run_tests {
let source = core_types::arena::Arena::new(1 << 16).unwrap(); let source = core_types::arena::Arena::new(1 << 16).unwrap();
let mut builder = RunBuilder::new(&source, element_write_hashed::<Vector>(), &[], 1).unwrap(); let mut builder = RunBuilder::new(&source, element_write_hashed::<Vector>(), &[], 1).unwrap();
builder.push(vector.clone()).unwrap(); builder.push(vector.clone()).unwrap();
let nested = Graphic::Group(core_types::record::Group { let nested = Graphic::Group(core_types::record::Group { row: None, content: builder.finish() });
row: None,
content: builder.finish(),
});
let mut builder = RunBuilder::new(&source, element_write_hashed::<Graphic>(), &[], 1).unwrap(); let mut builder = RunBuilder::new(&source, element_write_hashed::<Graphic>(), &[], 1).unwrap();
builder.push(nested).unwrap(); builder.push(nested).unwrap();
let group = core_types::record::Group { let group = core_types::record::Group { row: None, content: builder.finish() };
row: None,
content: builder.finish(),
};
let expected = group_to_legacy_list(&group); let expected = group_to_legacy_list(&group);
let owned = map_groups_to_owned(&Graphic::Group(group)); let owned = map_groups_to_owned(&Graphic::Group(group));
drop(source); drop(source);
@@ -1592,10 +1577,7 @@ mod run_tests {
fn native_group_paint<'a>(vector: &Vector, arena: &'a core_types::arena::Arena) -> List<Graphic<'a>> { fn native_group_paint<'a>(vector: &Vector, arena: &'a core_types::arena::Arena) -> List<Graphic<'a>> {
let mut builder = RunBuilder::new(arena, element_write_hashed::<Vector>(), &[], 1).unwrap(); let mut builder = RunBuilder::new(arena, element_write_hashed::<Vector>(), &[], 1).unwrap();
builder.push(vector.clone()).unwrap(); builder.push(vector.clone()).unwrap();
List::new_from_element(Graphic::Group(core_types::record::Group { List::new_from_element(Graphic::Group(core_types::record::Group { row: None, content: builder.finish() }))
row: None,
content: builder.finish(),
}))
} }
#[test] #[test]
@@ -1716,10 +1698,7 @@ mod run_tests {
let mut top = List::new(); let mut top = List::new();
top.push(Item::new_from_element(Graphic::Graphic(painted))); top.push(Item::new_from_element(Graphic::Graphic(painted)));
top.push(Item::new_from_element(Graphic::Graphic(nested))); top.push(Item::new_from_element(Graphic::Graphic(nested)));
top.push(Item::new_from_element(Graphic::Group(core_types::record::Group { top.push(Item::new_from_element(Graphic::Group(core_types::record::Group { row: None, content: inner_item })));
row: None,
content: inner_item,
})));
top.push(Item::new_from_element(Graphic::Color(Color::BLACK))); top.push(Item::new_from_element(Graphic::Color(Color::BLACK)));
top.push(Item::new_from_element(Graphic::Vector(unit_square_at(DVec2::new(6., 0.))))); top.push(Item::new_from_element(Graphic::Vector(unit_square_at(DVec2::new(6., 0.)))));
top.set_attribute(core_types::ATTR_TRANSFORM, 0, DAffine2::from_translation(DVec2::new(5., 5.))); top.set_attribute(core_types::ATTR_TRANSFORM, 0, DAffine2::from_translation(DVec2::new(5., 5.)));
@@ -1743,14 +1722,26 @@ mod run_tests {
let native = flatten_vector_rows(GraphicLevel::Legacy(&top)); let native = flatten_vector_rows(GraphicLevel::Legacy(&top));
assert_eq!(native.len(), legacy.len()); assert_eq!(native.len(), legacy.len());
for row in 0..native.len() { for row in 0..native.len() {
assert_eq!(native.attribute::<DAffine2>(core_types::ATTR_TRANSFORM, row), legacy.attribute::<DAffine2>(core_types::ATTR_TRANSFORM, row), "transform, row {row}"); assert_eq!(
assert_eq!(native.attribute::<f64>(core_types::ATTR_OPACITY, row), legacy.attribute::<f64>(core_types::ATTR_OPACITY, row), "opacity, row {row}"); native.attribute::<DAffine2>(core_types::ATTR_TRANSFORM, row),
legacy.attribute::<DAffine2>(core_types::ATTR_TRANSFORM, row),
"transform, row {row}"
);
assert_eq!(
native.attribute::<f64>(core_types::ATTR_OPACITY, row),
legacy.attribute::<f64>(core_types::ATTR_OPACITY, row),
"opacity, row {row}"
);
assert_eq!( assert_eq!(
native.attribute::<Vec<core_types::uuid::NodeId>>(core_types::ATTR_EDITOR_LAYER_PATH, row), native.attribute::<Vec<core_types::uuid::NodeId>>(core_types::ATTR_EDITOR_LAYER_PATH, row),
legacy.attribute::<Vec<core_types::uuid::NodeId>>(core_types::ATTR_EDITOR_LAYER_PATH, row), legacy.attribute::<Vec<core_types::uuid::NodeId>>(core_types::ATTR_EDITOR_LAYER_PATH, row),
"layer path, row {row}" "layer path, row {row}"
); );
assert_eq!(native.attribute::<Option<List<Graphic>>>(ATTR_FILL, row), legacy.attribute::<Option<List<Graphic>>>(ATTR_FILL, row), "fill, row {row}"); assert_eq!(
native.attribute::<Option<List<Graphic>>>(ATTR_FILL, row),
legacy.attribute::<Option<List<Graphic>>>(ATTR_FILL, row),
"fill, row {row}"
);
} }
assert_eq!(native, legacy); assert_eq!(native, legacy);
} }
+18 -6
View File
@@ -11,10 +11,10 @@ use core_types::bounds::RenderBoundingBox;
use core_types::color::Color; use core_types::color::Color;
use core_types::color::SRGBA8; use core_types::color::SRGBA8;
use core_types::lane::LaneSource; use core_types::lane::LaneSource;
use core_types::list::{Item, List};
use core_types::lane::{LeafLane, Single}; use core_types::lane::{LeafLane, Single};
use core_types::record::{Group, RunView}; use core_types::list::{Item, List};
use core_types::math::quad::Quad; use core_types::math::quad::Quad;
use core_types::record::{Group, RunView};
use core_types::render_complexity::RenderComplexity; use core_types::render_complexity::RenderComplexity;
use core_types::transform::Footprint; use core_types::transform::Footprint;
use core_types::uuid::{NodeId, generate_uuid}; use core_types::uuid::{NodeId, generate_uuid};
@@ -1043,7 +1043,14 @@ fn render_graphic_vello<'e, S: LaneSource<Element = Graphic<'e>>>(source: &S, sc
render_graphic_vello_with(source, PaintReach::NONE, scene, transform, context, render_params) render_graphic_vello_with(source, PaintReach::NONE, scene, transform, context, render_params)
} }
fn render_graphic_vello_with<'a, 'e, S: LaneSource<Element = Graphic<'e>>>(source: &'a S, inherited: PaintReach<'a>, scene: &mut Scene, transform: DAffine2, context: &mut RenderContext, render_params: &RenderParams) { fn render_graphic_vello_with<'a, 'e, S: LaneSource<Element = Graphic<'e>>>(
source: &'a S,
inherited: PaintReach<'a>,
scene: &mut Scene,
transform: DAffine2,
context: &mut RenderContext,
render_params: &RenderParams,
) {
let paint_columns = PaintColumns::new(source); let paint_columns = PaintColumns::new(source);
let mut mask_element_and_transform = None; let mut mask_element_and_transform = None;
@@ -1127,7 +1134,13 @@ fn collect_graphic_metadata<'e, S: LaneSource<Element = Graphic<'e>>>(source: &S
collect_graphic_metadata_with(source, PaintReach::NONE, metadata, footprint, element_id) collect_graphic_metadata_with(source, PaintReach::NONE, metadata, footprint, element_id)
} }
fn collect_graphic_metadata_with<'a, 'e, S: LaneSource<Element = Graphic<'e>>>(source: &'a S, inherited: PaintReach<'a>, metadata: &mut RenderMetadata, footprint: Footprint, element_id: Option<NodeId>) { fn collect_graphic_metadata_with<'a, 'e, S: LaneSource<Element = Graphic<'e>>>(
source: &'a S,
inherited: PaintReach<'a>,
metadata: &mut RenderMetadata,
footprint: Footprint,
element_id: Option<NodeId>,
) {
let paint_columns = PaintColumns::new(source); let paint_columns = PaintColumns::new(source);
for index in 0..source.lane_count() { for index in 0..source.lane_count() {
let item_transform: DAffine2 = source.attr::<Transform>(index); let item_transform: DAffine2 = source.attr::<Transform>(index);
@@ -1520,8 +1533,7 @@ fn render_vector_vello<S: LaneSource<Element = Vector>>(source: &S, scene: &mut
// the function ignores the arg for Center align) and the `SrcIn`/`SrcOut` aligned-stroke branch further down. // the function ignores the arg for Center align) and the `SrcIn`/`SrcOut` aligned-stroke branch further down.
let stroke = element.stroke.as_ref(); let stroke = element.stroke.as_ref();
let stroke_fully_transparent = stroke_graphic_list.is_none_or(|l| l.element(0).is_none_or(|g| g.is_fully_transparent())); let stroke_fully_transparent = stroke_graphic_list.is_none_or(|l| l.element(0).is_none_or(|g| g.is_fully_transparent()));
let can_draw_aligned_stroke = let can_draw_aligned_stroke = !stroke_fully_transparent && stroke.is_some_and(|s| s.has_renderable_stroke() && s.align.is_not_centered()) && element.stroke_bezier_paths().all(|p| p.closed());
!stroke_fully_transparent && stroke.is_some_and(|s| s.has_renderable_stroke() && s.align.is_not_centered()) && element.stroke_bezier_paths().all(|p| p.closed());
let opacity = (opacity_attr * if render_params.for_mask { 1. } else { opacity_fill_attr }) as f32; let opacity = (opacity_attr * if render_params.for_mask { 1. } else { opacity_fill_attr }) as f32;
if opacity < 1. || blend_mode_attr != BlendMode::default() { if opacity < 1. || blend_mode_attr != BlendMode::default() {
+38 -9
View File
@@ -848,7 +848,12 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
// never binds the context's arena; the kernel keeps its own bound. // never binds the context's arena; the kernel keeps its own bound.
let extracts_arena = |bound: &TypeParamBound| matches!(bound, TypeParamBound::Trait(trait_bound) if trait_bound.path.segments.last().is_some_and(|segment| segment.ident == "ExtractArena")); let extracts_arena = |bound: &TypeParamBound| matches!(bound, TypeParamBound::Trait(trait_bound) if trait_bound.path.segments.last().is_some_and(|segment| segment.ident == "ExtractArena"));
let mut impl_ctx_bounds: Vec<TokenStream2> = match ctx_param { let mut impl_ctx_bounds: Vec<TokenStream2> = match ctx_param {
Some(ctx_param) => ctx_param.bounds.iter().filter(|bound| !matches!(bound, TypeParamBound::Lifetime(_)) && !extracts_arena(bound)).map(|bound| quote!(#bound)).collect(), Some(ctx_param) => ctx_param
.bounds
.iter()
.filter(|bound| !matches!(bound, TypeParamBound::Lifetime(_)) && !extracts_arena(bound))
.map(|bound| quote!(#bound))
.collect(),
None => Vec::new(), None => Vec::new(),
}; };
if ctx_param.is_none() { if ctx_param.is_none() {
@@ -2325,22 +2330,34 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
reading_secondary_indices(&regular_fields, skips_carrier) reading_secondary_indices(&regular_fields, skips_carrier)
.into_iter() .into_iter()
.filter_map(|index| match &regular_fields[index].ty { .filter_map(|index| match &regular_fields[index].ty {
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) }), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::clone::Clone)
}),
_ => None, _ => None,
}), }),
); );
if let Some(ty) = carrier_read_ty { if let Some(ty) = carrier_read_ty {
bounds.push({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) }); bounds.push({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::clone::Clone)
});
} }
// The element store parks droppable elements in the arena. // The element store parks droppable elements in the arena.
if let Some(ty) = element_write { if let Some(ty) = element_write {
bounds.push({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::marker::Send + ::core::marker::Sync + #core_types::StaticTypeSized + 'static) }); bounds.push({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::marker::Send + ::core::marker::Sync + #core_types::StaticTypeSized + 'static)
});
} }
} }
// A routing node's value elements copy out of their records. // A routing node's value elements copy out of their records.
if let Some(generic) = &routing_generic { if let Some(generic) = &routing_generic {
bounds.extend(routing_value_indices(&regular_fields, generic).into_iter().filter_map(|index| match &regular_fields[index].ty { bounds.extend(routing_value_indices(&regular_fields, generic).into_iter().filter_map(|index| match &regular_fields[index].ty {
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) }), ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::clone::Clone)
}),
_ => None, _ => None,
})); }));
} }
@@ -2350,7 +2367,10 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
ParsedFieldType::Regular(RegularParsedField { ty, .. }) ParsedFieldType::Regular(RegularParsedField { ty, .. })
if !node.inputs[index].subject && matches!(ir::value_binding(&node, index), ValueBinding::Plain | ValueBinding::ReadingSecondary | ValueBinding::RecordElement) => if !node.inputs[index].subject && matches!(ir::value_binding(&node, index), ValueBinding::Plain | ValueBinding::ReadingSecondary | ValueBinding::RecordElement) =>
{ {
Some({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) }) Some({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::clone::Clone)
})
} }
_ => None, _ => None,
})); }));
@@ -2370,9 +2390,18 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
.filter(|(index, _)| ir::materialized_levels(&node, *index) == 0) .filter(|(index, _)| ir::materialized_levels(&node, *index) == 0)
.filter_map(|(_, field)| match &field.ty { .filter_map(|(_, field)| match &field.ty {
// The conditional arena-park moves a lend element once. // The conditional arena-park moves a lend element once.
ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => Some({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::marker::Send + ::core::marker::Sync + 'static) }), ParsedFieldType::Regular(RegularParsedField { ty, lend: Some(_), .. }) => Some({
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({ let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static"); quote!(#ty: ::core::clone::Clone) }), let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
ParsedFieldType::Node(NodeParsedField { output_type, .. }) => Some({ let output_type = &crate::codegen::classify::substitute_lifetimes(output_type, "'static"); quote!(#output_type: ::core::clone::Clone) }), quote!(#ty: ::core::marker::Send + ::core::marker::Sync + 'static)
}),
ParsedFieldType::Regular(RegularParsedField { ty, .. }) => Some({
let ty = &crate::codegen::classify::substitute_lifetimes(ty, "'static");
quote!(#ty: ::core::clone::Clone)
}),
ParsedFieldType::Node(NodeParsedField { output_type, .. }) => Some({
let output_type = &crate::codegen::classify::substitute_lifetimes(output_type, "'static");
quote!(#output_type: ::core::clone::Clone)
}),
}) })
.collect(); .collect();
let out = crate::codegen::classify::substitute_lifetimes(&slot_value_type(&parsed.output_type), "'static"); let out = crate::codegen::classify::substitute_lifetimes(&slot_value_type(&parsed.output_type), "'static");
+1 -1
View File
@@ -1,6 +1,6 @@
use super::*; use super::*;
use proc_macro2::TokenStream as TokenStream2;
use proc_macro_error2::emit_error; use proc_macro_error2::emit_error;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote}; use quote::{format_ident, quote};
use syn::spanned::Spanned; use syn::spanned::Spanned;
use syn::{GenericParam, Ident, Type}; use syn::{GenericParam, Ident, Type};
+1 -3
View File
@@ -1,9 +1,7 @@
//! The intent IR: a node built from its signature, from which lowering derives. //! The intent IR: a node built from its signature, from which lowering derives.
#![allow(dead_code)] #![allow(dead_code)]
use crate::codegen::classify::{ use crate::codegen::classify::{Dialect, RoutingIo, bare_ident, context_param, dialect, flip_carrier, generic_assignment, generic_extractable, is_served, record_shape, routing_io, slot_value_type};
Dialect, RoutingIo, bare_ident, context_param, dialect, flip_carrier, generic_assignment, generic_extractable, is_served, record_shape, routing_io, slot_value_type,
};
use crate::codegen::entries::implementation_rows; use crate::codegen::entries::implementation_rows;
use crate::parsing::{AttributeRead, NodeParsedField, ParsedField, ParsedFieldType, ParsedNodeFn, RecordWrites, RegularParsedField, record_writes}; use crate::parsing::{AttributeRead, NodeParsedField, ParsedField, ParsedFieldType, ParsedNodeFn, RecordWrites, RegularParsedField, record_writes};
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;
+35 -7
View File
@@ -691,7 +691,11 @@ mod tests {
let leveled = repeat_opacity_layout(&base); let leveled = repeat_opacity_layout(&base);
let frames = frames_for(&[&base, &leveled]); let frames = frames_for(&[&base, &leveled]);
let node = install(RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(8u32), &base), repeat_opacity_layout_meta(), &[Some(&base)]); let node = install(
RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(8u32), &base),
repeat_opacity_layout_meta(),
&[Some(&base)],
);
assert_eq!(Node::<ContextImpl>::layout(&node), &leveled); assert_eq!(Node::<ContextImpl>::layout(&node), &leveled);
let GPoll::Final(served) = core_types::record::capture(&node, &indexed, &frames) else { let GPoll::Final(served) = core_types::record::capture(&node, &indexed, &frames) else {
panic!("expected a final record"); panic!("expected a final record");
@@ -710,7 +714,11 @@ mod tests {
let base = f64_layout(&[]); let base = f64_layout(&[]);
let frames = frames_for(&[&base]); let frames = frames_for(&[&base]);
let node = install(RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base), repeat_opacity_layout_meta(), &[Some(&base)]); let node = install(
RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base),
repeat_opacity_layout_meta(),
&[Some(&base)],
);
// The pushed level (0, the only level) reports the copy count. // The pushed level (0, the only level) reports the copy count.
assert_eq!(node.extent_at(&ctx, 0, &frames), core_types::gpoll::GPoll::Final(core_types::gpoll::Extent::Exactly(3))); assert_eq!(node.extent_at(&ctx, 0, &frames), core_types::gpoll::GPoll::Final(core_types::gpoll::Extent::Exactly(3)));
} }
@@ -852,7 +860,11 @@ mod tests {
let (reverse_edge, reverse_layout) = lifted_value(false); let (reverse_edge, reverse_layout) = lifted_value(false);
let frames = frames_for(&[&base, &leveled_content, &count_layout, &reverse_layout]); let frames = frames_for(&[&base, &leveled_content, &count_layout, &reverse_layout]);
let content = install(RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base), repeat_opacity_layout_meta(), &[Some(&base)]); let content = install(
RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base),
repeat_opacity_layout_meta(),
&[Some(&base)],
);
let meta = core_types::record::LayoutMeta { let meta = core_types::record::LayoutMeta {
sources: vec![0], sources: vec![0],
reads: vec![], reads: vec![],
@@ -1434,7 +1446,11 @@ mod tests {
.map(|&(element, x)| (element, DAffine2::from_translation(glam::DVec2::new(x, 0.)))) .map(|&(element, x)| (element, DAffine2::from_translation(glam::DVec2::new(x, 0.))))
.collect(), .collect(),
}; };
let node = install(MirrorNode::new(RecordSource::new(content, &layout, &layout), ValueSource::new(true)), mirror_layout_meta(), &[Some(&layout)]); let node = install(
MirrorNode::new(RecordSource::new(content, &layout, &layout), ValueSource::new(true)),
mirror_layout_meta(),
&[Some(&layout)],
);
let out = Node::<ContextImpl>::layout(&node).clone(); let out = Node::<ContextImpl>::layout(&node).clone();
let head = ctx.index_head(); let head = ctx.index_head();
let scoped = ctx.promoted(&head, 0); let scoped = ctx.promoted(&head, 0);
@@ -1612,7 +1628,11 @@ mod tests {
let out = f64_layout(&[]); let out = f64_layout(&[]);
let frames = frames_for(&[&base, &leveled_content, &count_layout, &reverse_layout, &out]); let frames = frames_for(&[&base, &leveled_content, &count_layout, &reverse_layout, &out]);
let content = install(RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base), repeat_opacity_layout_meta(), &[Some(&base)]); let content = install(
RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base),
repeat_opacity_layout_meta(),
&[Some(&base)],
);
let meta = core_types::record::LayoutMeta { let meta = core_types::record::LayoutMeta {
sources: vec![0], sources: vec![0],
reads: vec![], reads: vec![],
@@ -1821,7 +1841,11 @@ mod tests {
let out = f64_layout(&[]); let out = f64_layout(&[]);
let frames = frames_for(&[&base, &leveled, &out]); let frames = frames_for(&[&base, &leveled, &out]);
let repeat = install(RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base), repeat_opacity_layout_meta(), &[Some(&base)]); let repeat = install(
RepeatOpacityNode::new(bare_source(&base, 7.), ValueSource::new(3u32), &base),
repeat_opacity_layout_meta(),
&[Some(&base)],
);
let node = install_flip(SumNode::new(repeat, &leveled), &out); let node = install_flip(SumNode::new(repeat, &leveled), &out);
assert_eq!(Node::<ContextImpl>::layout(&node).depth, 0, "the reducer collapsed the rank level"); assert_eq!(Node::<ContextImpl>::layout(&node).depth, 0, "the reducer collapsed the rank level");
@@ -2066,7 +2090,11 @@ mod tests {
let layout = source_opacity_layout(); let layout = source_opacity_layout();
let frames = frames_for(&[&layout]); let frames = frames_for(&[&layout]);
let node = install(SourceOpacityNode::new(ValueSource::new(()), ValueSource::new(3.), ValueSource::new(0.25)), source_opacity_layout_meta(), &[]); let node = install(
SourceOpacityNode::new(ValueSource::new(()), ValueSource::new(3.), ValueSource::new(0.25)),
source_opacity_layout_meta(),
&[],
);
assert_eq!(Node::<ContextImpl>::layout(&node), &layout); assert_eq!(Node::<ContextImpl>::layout(&node), &layout);
let GPoll::Final(served) = core_types::record::capture(&node, &ctx, &frames) else { let GPoll::Final(served) = core_types::record::capture(&node, &ctx, &frames) else {
panic!("expected a final record"); panic!("expected a final record");
+1 -4
View File
@@ -36,10 +36,7 @@ pub fn create_artboard<'e>(
clip: bool, clip: bool,
) -> (Artboard<'e>, Attr<Location>, Attr<Dimensions>, Attr<Background>, Attr<Clip>) { ) -> (Artboard<'e>, Attr<Location>, Attr<Dimensions>, Attr<Background>, Attr<Clip>) {
let item = content.as_group_item(); let item = content.as_group_item();
let content = core_types::list::List::new_from_element(Graphic::Group(core_types::record::Group { let content = core_types::list::List::new_from_element(Graphic::Group(core_types::record::Group { row: None, content: item }));
row: None,
content: item,
}));
// Normalize so `location` is the top-left corner and `dimensions` are positive (allowing negative input // Normalize so `location` is the top-left corner and `dimensions` are positive (allowing negative input
// dimensions to represent dragging from the opposite corner). Compute the corner using the raw signed // dimensions to represent dragging from the opposite corner). Compute the corner using the raw signed
+2 -8
View File
@@ -461,10 +461,7 @@ pub fn wrap_graphic<'e, T: Clone + Send + Sync + core_types::CacheHash + 'static
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] content: IList<T>, #[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] content: IList<T>,
) -> Result<IList<Graphic<'e>>, Interrupt> { ) -> Result<IList<Graphic<'e>>, Interrupt> {
let item = content.as_group_item(); let item = content.as_group_item();
Ok(Graphic::Group(core_types::record::Group { Ok(Graphic::Group(core_types::record::Group { row: None, content: item }))
row: None,
content: item,
}))
} }
/// The collected group is the level's single lane. /// The collected group is the level's single lane.
@@ -530,10 +527,7 @@ pub fn to_graphic_typed<'e, T: Clone + Send + Sync + core_types::CacheHash + 'st
#[implementations(Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] content: IList<T>, #[implementations(Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] content: IList<T>,
) -> Result<IList<Graphic<'e>>, Interrupt> { ) -> Result<IList<Graphic<'e>>, Interrupt> {
let item = content.as_group_item(); let item = content.as_group_item();
Ok(Graphic::Group(core_types::record::Group { Ok(Graphic::Group(core_types::record::Group { row: None, content: item }))
row: None,
content: item,
}))
} }
/// An unconnected content input carries the unit, which renders as nothing like /// An unconnected content input carries the unit, which renders as nothing like
+1 -4
View File
@@ -103,10 +103,7 @@ fn flatten_extent(content: ListIn<'_, Graphic>, fully_flatten: ValueIn<'_, bool>
#[node_macro::node(category("Test"), extent(wrap_extent))] #[node_macro::node(category("Test"), extent(wrap_extent))]
fn wrap<'e>(_: impl Ctx, content: IList<Graphic<'e>>) -> Result<IList<Graphic<'e>>, Interrupt> { fn wrap<'e>(_: impl Ctx, content: IList<Graphic<'e>>) -> Result<IList<Graphic<'e>>, Interrupt> {
let item = content.as_group_item(); let item = content.as_group_item();
Ok(Graphic::Group(core_types::record::Group { Ok(Graphic::Group(core_types::record::Group { row: None, content: item }))
row: None,
content: item,
}))
} }
/// The collected group is the level's single lane. /// The collected group is the level's single lane.
+7 -8
View File
@@ -4,9 +4,9 @@ use core_types::uuid::NodeId;
use core_types::{ATTR_BLEND_MODE, ATTR_CLIPPING_MASK, ATTR_EDITOR_LAYER_PATH, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_TRANSFORM, BlendMode, Color, Ctx}; use core_types::{ATTR_BLEND_MODE, ATTR_CLIPPING_MASK, ATTR_EDITOR_LAYER_PATH, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_TRANSFORM, BlendMode, Color, Ctx};
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
use graphic_types::graphic::{GraphicLevel, PaintColumns, PaintReach, bake_paint_transforms, is_paint_present, set_paint_attribute, set_paint_attribute_at}; use graphic_types::graphic::{GraphicLevel, PaintColumns, PaintReach, bake_paint_transforms, is_paint_present, set_paint_attribute, set_paint_attribute_at};
use graphic_types::markers::{EditorMergedLayers, Fill, Stroke};
use graphic_types::raster_types::{CPU, GPU, Raster}; use graphic_types::raster_types::{CPU, GPU, Raster};
use graphic_types::vector_types::GradientStops; use graphic_types::vector_types::GradientStops;
use graphic_types::markers::{EditorMergedLayers, Fill, Stroke};
use graphic_types::vector_types::gradient::{GradientSpreadMethod, GradientType}; use graphic_types::vector_types::gradient::{GradientSpreadMethod, GradientType};
use graphic_types::vector_types::subpath::{ManipulatorGroup, Subpath}; use graphic_types::vector_types::subpath::{ManipulatorGroup, Subpath};
use graphic_types::vector_types::vector::PointId; use graphic_types::vector_types::vector::PointId;
@@ -128,9 +128,7 @@ fn boolean_operation<'e>(
> { > {
let item = content.as_group_item(); let item = content.as_group_item();
let flattened = flatten_vector_run(GraphicLevel::Run(&item), DAffine2::IDENTITY, PaintReach::NONE); let flattened = flatten_vector_run(GraphicLevel::Run(&item), DAffine2::IDENTITY, PaintReach::NONE);
let snapshot = graphic_types::graphic::run_to_list::<Graphic>(&item) let snapshot = graphic_types::graphic::run_to_list::<Graphic>(&item).expect("the run holds the row's element type").into_graphic_list();
.expect("the run holds the row's element type")
.into_graphic_list();
boolean_core(ctx.arena(), flattened, snapshot, operation) boolean_core(ctx.arena(), flattened, snapshot, operation)
} }
@@ -157,9 +155,7 @@ fn boolean_operation_vector<'e>(
> { > {
let item = content.as_group_item(); let item = content.as_group_item();
let flattened = graphic_types::graphic::run_to_list::<Vector>(&item).expect("the run holds vector lanes"); let flattened = graphic_types::graphic::run_to_list::<Vector>(&item).expect("the run holds vector lanes");
let snapshot = graphic_types::graphic::run_to_list::<Vector>(&item) let snapshot = graphic_types::graphic::run_to_list::<Vector>(&item).expect("the run holds the row's element type").into_graphic_list();
.expect("the run holds the row's element type")
.into_graphic_list();
boolean_core(ctx.arena(), flattened, snapshot, operation) boolean_core(ctx.arena(), flattened, snapshot, operation)
} }
@@ -445,7 +441,10 @@ fn flatten_group(out: &mut List<Vector>, group: &core_types::record::Group, comp
} else if let Some(image) = graphic_types::graphic::run_to_list::<Raster<GPU>>(item) { } else if let Some(image) = graphic_types::graphic::run_to_list::<Raster<GPU>>(item) {
push_rows(out, raster_stand_in_rows(&image, composed)); push_rows(out, raster_stand_in_rows(&image, composed));
} else if let Some(color) = graphic_types::graphic::run_to_list::<Color>(item) { } else if let Some(color) = graphic_types::graphic::run_to_list::<Color>(item) {
push_rows(out, (0..color.len()).filter_map(|i| Some(color_paint_row(*color.element(i)?, color.clone_item_attributes(i)))).collect()); push_rows(
out,
(0..color.len()).filter_map(|i| Some(color_paint_row(*color.element(i)?, color.clone_item_attributes(i)))).collect(),
);
} else if let Some(gradient) = graphic_types::graphic::run_to_list::<GradientStops>(item) { } else if let Some(gradient) = graphic_types::graphic::run_to_list::<GradientStops>(item) {
push_rows( push_rows(
out, out,
+7 -1
View File
@@ -360,7 +360,13 @@ mod test {
transform: local, transform: local,
}; };
let mut node = RepeatRadialNode::new(RecordSource::new(content, &layout, &layout), ValueSource::new(90.0f64), ValueSource::new(2.0f64), ValueSource::new(4u32), &layout); let mut node = RepeatRadialNode::new(
RecordSource::new(content, &layout, &layout),
ValueSource::new(90.0f64),
ValueSource::new(2.0f64),
ValueSource::new(4u32),
&layout,
);
Node::<ContextImpl>::set_layout(&mut node, repeat_radial_layout_meta().resolve(&[Some(&layout)])); Node::<ContextImpl>::set_layout(&mut node, repeat_radial_layout_meta().resolve(&[Some(&layout)]));
assert_eq!(node.extent_at(&ctx, 0, &frames.reborrow()), GPoll::Final(Extent::Exactly(4))); assert_eq!(node.extent_at(&ctx, 0, &frames.reborrow()), GPoll::Final(Extent::Exactly(4)));
+6 -1
View File
@@ -1660,7 +1660,12 @@ fn solidify_stroke_vector<'e>(
Interrupt, Interrupt,
> { > {
let wrapper = wrap_vector_level(content); let wrapper = wrap_vector_level(content);
solidify_native_lane(ctx.arena(), graphic_types::graphic::GraphicLevel::Legacy(&wrapper), || legacy_graphic_list_of(content), ctx.index() as usize) solidify_native_lane(
ctx.arena(),
graphic_types::graphic::GraphicLevel::Legacy(&wrapper),
|| legacy_graphic_list_of(content),
ctx.index() as usize,
)
} }
fn solidify_stroke_vector_extent(content: ListIn<'_, Vector>, level: LevelIn) -> GPoll<Extent> { fn solidify_stroke_vector_extent(content: ListIn<'_, Vector>, level: LevelIn) -> GPoll<Extent> {