Move source_node_id to "editor:layer" and Vector<Upstream> to "editor:merged_layers", backed by a new 'Write Attribute' node (#4061)

* Fix click target propagation with the Rasterize node

* Add the 'Write Attribute' node

* Remove tag_layer in favor of the new Write Attribute node, prune redundant attribute writes

* Replace the Vector<Upstream> type argument with the "editor:merged_layers" attribute
This commit is contained in:
Keavon Chambers
2026-04-28 03:07:23 -07:00
parent 76938eb69a
commit afc2c9178e
27 changed files with 312 additions and 376 deletions

View File

@@ -1,4 +1,3 @@
use core_types::AlphaBlending;
use core_types::table::{Table, TableRow};
use glam::{DAffine2, DVec2};
use parley::GlyphRun;
@@ -10,16 +9,16 @@ use skrifa::{MetadataProvider, OutlineGlyph};
use vector_types::subpath::{ManipulatorGroup, Subpath};
use vector_types::vector::{PointId, Vector};
pub struct PathBuilder<Upstream> {
pub struct PathBuilder {
current_subpath: Subpath<PointId>,
origin: DVec2,
glyph_subpaths: Vec<Subpath<PointId>>,
pub vector_table: Table<Vector<Upstream>>,
pub vector_table: Table<Vector>,
scale: f64,
id: PointId,
}
impl<Upstream: Default + 'static> PathBuilder<Upstream> {
impl PathBuilder {
pub fn new(per_glyph_instances: bool, scale: f64) -> Self {
Self {
current_subpath: Subpath::new(Vec::new(), false),
@@ -52,12 +51,8 @@ impl<Upstream: Default + 'static> PathBuilder<Upstream> {
}
if per_glyph_instances {
self.vector_table.push(
TableRow::new_from_element(Vector::from_subpaths(core::mem::take(&mut self.glyph_subpaths), false))
.with_attribute("transform", DAffine2::from_translation(glyph_offset))
.with_attribute("alpha_blending", AlphaBlending::default())
.with_attribute("source_node_id", None::<core_types::uuid::NodeId>),
);
self.vector_table
.push(TableRow::new_from_element(Vector::from_subpaths(core::mem::take(&mut self.glyph_subpaths), false)).with_attribute("transform", DAffine2::from_translation(glyph_offset)));
} else {
for subpath in self.glyph_subpaths.drain(..) {
// Unwrapping here is ok because `self.vector_table` is initialized with a single `Vector` table element
@@ -120,7 +115,7 @@ impl<Upstream: Default + 'static> PathBuilder<Upstream> {
}
}
pub fn finalize(mut self) -> Table<Vector<Upstream>> {
pub fn finalize(mut self) -> Table<Vector> {
if self.vector_table.is_empty() {
self.vector_table = Table::new_from_element(Vector::default());
}
@@ -128,7 +123,7 @@ impl<Upstream: Default + 'static> PathBuilder<Upstream> {
}
}
impl<Upstream: Default + 'static> OutlinePen for PathBuilder<Upstream> {
impl OutlinePen for PathBuilder {
fn move_to(&mut self, x: f32, y: f32) {
if !self.current_subpath.is_empty() {
self.glyph_subpaths.push(std::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false)));

View File

@@ -87,7 +87,7 @@ impl TextContext {
}
/// Convert text to vector paths using the specified font and typesetting configuration
pub fn to_path<Upstream: Default + 'static>(&mut self, text: &str, font: &Font, font_cache: &FontCache, typesetting: TypesettingConfig, per_glyph_instances: bool) -> Table<Vector<Upstream>> {
pub fn to_path(&mut self, text: &str, font: &Font, font_cache: &FontCache, typesetting: TypesettingConfig, per_glyph_instances: bool) -> Table<Vector> {
let Some(layout) = self.layout_text(text, font, font_cache, typesetting) else {
return Table::new_from_element(Vector::default());
};

View File

@@ -6,7 +6,7 @@ use parley::fontique::Blob;
use std::sync::Arc;
use vector_types::Vector;
pub fn to_path<Upstream: Default + 'static>(text: &str, font: &Font, font_cache: &FontCache, typesetting: TypesettingConfig, per_glyph_instances: bool) -> Table<Vector<Upstream>> {
pub fn to_path(text: &str, font: &Font, font_cache: &FontCache, typesetting: TypesettingConfig, per_glyph_instances: bool) -> Table<Vector> {
TextContext::with_thread_local(|ctx| ctx.to_path(text, font, font_cache, typesetting, per_glyph_instances))
}