Bridge legacy seams and convert the transform family

This commit is contained in:
Dennis Kobert
2026-08-22 14:25:31 +00:00
parent 217f32eb88
commit fb71ea426d
14 changed files with 227 additions and 157 deletions
+36 -2
View File
@@ -581,15 +581,49 @@ fn wrap_graphic_extent(_content: ListIn<'_, Graphic>, _level: LevelIn) -> GPoll<
GPoll::Final(Extent::Exactly(1))
}
/// Converts the level's elements into `Graphic` elements. A `Graphic` level passes through unchanged.
/// Converts the level's elements into `Graphic` elements. A `Graphic` level passes through
/// unchanged. The legacy list rows accept an unconverted producer's list value as one element.
#[node_macro::node(category("General"))]
pub fn to_graphic<T: Into<Graphic> + Clone + Send + Sync + core_types::CacheHash + 'static>(
_: impl Ctx,
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] content: T,
#[implementations(
Graphic,
Vector,
Raster<CPU>,
Raster<GPU>,
Color,
GradientStops,
String,
List<Graphic>,
List<Vector>,
List<Raster<CPU>>,
List<Raster<GPU>>,
List<Color>,
List<GradientStops>,
List<String>,
)]
content: T,
) -> Graphic {
content.into()
}
/// The transitional level bridge: the wire's records as the legacy list an
/// unconverted consumer expects, attributes copied through their erased
/// reads. Registered under the legacy convert identifiers; the rows die with
/// the last legacy consumer.
#[node_macro::node(category(""))]
pub fn level_to_list<T: Clone + Send + Sync + CacheHash + 'static>(
_: impl Ctx + ExtractIndex + InjectIndex + Copy,
#[implementations(Graphic, Vector, Raster<CPU>, Raster<GPU>, Color, GradientStops, String)] value: IList<T>,
_converter: (),
) -> List<T> {
// SAFETY: a materialized input's frames are arena-resident.
let item = unsafe { core_types::record::GroupItem::from_resident(value.batch()) };
graphic_types::graphic::run_to_render_list::<T>(&item).expect("the run holds the row's element type")
}
pub use _level_to_list_mod::level_to_list_entries;
/// Removes a level of nesting from a `Graphic[]`, or all nesting if "Fully Flatten" is enabled.
#[node_macro::node(category("General"), extent(flatten_graphic_extent))]
pub fn flatten_graphic(ctx: impl Ctx + ExtractIndex + InjectIndex + Copy, content: IList<Graphic>, fully_flatten: bool) -> Result<IList<(Graphic, Attr<TransformAttr>)>, Interrupt> {