Compare commits

..
10 changed files with 7 additions and 104 deletions

No files matched your search

-14
View File
@@ -985,20 +985,6 @@ mod test {
element
}
/// Grab all of the values of the input every time it occurs in the graph.
pub fn grab_all_input<'a, Input: NodeInputDecleration + 'a>(&'a self, runtime: &'a NodeRuntime) -> impl Iterator<Item = Input::Result> + 'a
where
Input::Result: Send + Sync + Clone + 'static,
{
self.protonodes_by_name
.get(&Input::identifier())
.map_or([].as_slice(), |x| x.as_slice())
.iter()
.filter_map(|inputs| inputs.get(Input::INDEX))
.filter_map(|input_monitor_node| runtime.executor.introspect(input_monitor_node).ok())
.filter_map(Instrumented::downcast::<Input>) // Some might not resolve (e.g. generics that don't work properly)
}
/// Grab all of the values of a LEVELED input, which introspects as its
/// whole legacy list rather than as one element. `T` is the introspected
/// element type, which differs from the declared one where a conversion
@@ -337,20 +337,6 @@ impl AttributeDyn {
self.0.len() == 0
}
/// Builds a new attribute matching `target_len` items, taking values from this attribute (wrapping if shorter, truncating if longer).
pub fn cloned_to_length(&self, key: &str, target_len: usize) -> Box<dyn AnyAttribute> {
let mut result = self.0.new_with_defaults(0);
let source_len = self.0.len();
if source_len == 0 {
pad_with_implicit_default(key, &mut result, target_len);
return result;
}
for i in 0..target_len {
let value = self.0.clone_value(i % source_len).expect("source_len > 0");
result.push(value);
}
result
}
}
impl Clone for AttributeDyn {
@@ -784,13 +770,6 @@ impl Attributes {
}
}
/// Gets a mutable reference to the value at the given index, creating the attribute if it doesn't exist or has the wrong type.
fn get_or_insert_default_value<T: Clone + Send + Sync + Default + Debug + PartialEq + CacheHash + 'static>(&mut self, key: &str, index: usize) -> &mut T {
let attribute_position = self.find_or_create_attribute::<T>(key);
let attribute = (*self.attributes[attribute_position].1).as_any_mut().downcast_mut::<Attribute<T>>().unwrap();
&mut attribute.0[index]
}
/// Sets the value at the given index in the attribute for the given key.
/// Creates the attribute with defaults if it doesn't exist.
fn set_value<T: Clone + Send + Sync + Default + Debug + PartialEq + CacheHash + 'static>(&mut self, key: impl Into<String>, index: usize, value: T) {
@@ -1031,14 +1010,6 @@ impl<T> List<T> {
self.attributes.set_value(key, index, value);
}
/// Replaces (or adds) an attribute from a type-erased source. The source is wrapped or truncated to match this list's item count.
pub fn set_attribute_dyn(&mut self, key: impl Into<String>, source: AttributeDyn) {
let key = key.into();
self.attributes.attributes.retain(|(k, _)| k != &key);
let new_attribute = source.cloned_to_length(&key, self.element.len());
self.attributes.attributes.push((key, new_attribute));
}
/// Sets a single type-erased attribute value at the given index, creating the attribute from the value's underlying type if it doesn't exist (padded with defaults to match the list's length).
/// Falls back to default if the value's type doesn't match an existing attribute.
pub fn set_attribute_value_dyn(&mut self, key: impl Into<String>, index: usize, value: AttributeValueDyn) {
@@ -1058,12 +1029,6 @@ impl<T> List<T> {
self.attributes.remove_attribute(key);
}
/// Runs the given closure on a mutable reference to the attribute value at the given item index,
/// creating the attribute with defaults if it doesn't exist, and returns the closure's result.
pub fn with_attribute_mut_or_default<U: Clone + Send + Sync + Default + Debug + PartialEq + CacheHash + 'static, R, F: FnOnce(&mut U) -> R>(&mut self, key: &str, index: usize, f: F) -> R {
f(self.attributes.get_or_insert_default_value::<U>(key, index))
}
/// Returns a debug-formatted display string for the attribute at the given item index and key.
pub fn attribute_display_value(&self, key: &str, index: usize, overrides: fn(&dyn std::any::Any) -> Option<String>) -> Option<String> {
self.attributes.display_value(key, index, overrides)
@@ -136,18 +136,6 @@ impl<'a> RecordBatchMut<'a> {
unsafe { RecordBatch::new(self.scratch.as_ptr().cast(), self.len, self.layout) }
}
/// Lane `lane`'s frame for in-place writes through the layout's offsets.
pub fn lane_ptr(&mut self, lane: usize) -> *mut u8 {
assert!(lane < self.len, "lane {lane} out of bounds for a batch of {}", self.len);
// SAFETY: in-bounds by the assert against the constructor's contract.
unsafe { self.scratch.as_mut_ptr().cast::<u8>().add(lane * self.layout.lane_stride()) }
}
/// Reclaims the raw buffer, e.g. to rebind it under a same-stride output
/// layout for an in-place map.
pub fn into_scratch(self) -> &'a mut [MaybeUninit<u64>] {
self.scratch
}
}
/// One lane's record: its pointer paired with the batch's layout.
@@ -69,18 +69,6 @@ macro_rules! future {
};
}
#[macro_export]
macro_rules! fn_type {
($type:ty) => {
$crate::Type::Fn(Box::new(concrete!(())), Box::new(concrete!($type)))
};
($in_type:ty, $type:ty, alias: $outname:ty) => {
$crate::Type::Fn(Box::new(concrete!($in_type)), Box::new(concrete!($type, $outname)))
};
($in_type:ty, $type:ty) => {
$crate::Type::Fn(Box::new(concrete!($in_type)), Box::new(concrete!($type)))
};
}
#[macro_export]
macro_rules! fn_type_fut {
($type:ty) => {
@@ -584,13 +584,6 @@ impl<'e> Graphic<'e> {
}
}
pub fn as_vector_mut(&mut self) -> Option<&mut Vector> {
match self {
Graphic::Vector(vector) => Some(vector),
_ => None,
}
}
pub fn as_raster(&self) -> Option<&Raster<CPU>> {
match self {
Graphic::RasterCPU(raster) => Some(raster),
@@ -2094,12 +2094,7 @@ fn collect_raster_metadata<S: LaneSource>(source: &S, metadata: &mut RenderMetad
let transform: DAffine2 = source.attr::<Transform>(0);
metadata.local_transforms.insert(element_id, transform);
// If this raster carries a snapshot of upstream graphic content (e.g. it was produced by Rasterize,
// which destructively merges its inputs into pixels), recurse into that snapshot so the editor can
// surface the original child layers' click targets (the same mechanism Boolean Operation uses).
// The snapshot was captured before Rasterize shifted its input transforms to align with the rasterization
// area, so the children are already in the coordinate space matching `footprint` here — we must NOT
// multiply in `transform` (which is the rasterization area, not a layer-stack transform).
// The snapshot's children already match `footprint`, so `transform` (the rasterization area) must not be applied.
if let Some(upstream_nested_layers) = source.attr::<EditorMergedLayers>(0).filter(|layers| !layers.is_empty()) {
upstream_nested_layers.collect_metadata(metadata, footprint, None);
}
+1 -4
View File
@@ -129,10 +129,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
})
.collect();
// Flipped nodes carry their kernel generics as struct parameters: record
// edges no longer bind them through `Output`, so the struct must. A
// ranked input's element generic is carried on any node kind for the
// same reason: the materialized view monomorphizes the kernel per row.
// Flipped kernels and ranked-input element generics must be carried as struct parameters.
let ctx_ident_for_flip = context_param(parsed).map(|ctx| ctx.ident.clone());
let ranked_carries = |ident: &Ident| {
regular_fields.iter().any(|field| match &field.ty {
+1 -7
View File
@@ -1,4 +1,5 @@
//! The intent IR: a node built from its signature, from which lowering derives.
// Fields below the `Node` root are read by the IR's own tests only.
#![allow(dead_code)]
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};
@@ -13,7 +14,6 @@ pub(crate) fn build(parsed: &ParsedNodeFn) -> Node {
let generic_idents: Vec<Ident> = generics.iter().map(|generic| generic.ident.clone()).collect();
let fields: Vec<&ParsedField> = parsed.fields.iter().filter(|field| !field.is_data_field).collect();
Node {
kernel: Kernel { fn_name: parsed.fn_name.clone() },
monomorphizations: monomorphizations(parsed, &fields, &generic_idents),
inputs: inputs(parsed, &fields, &generic_idents),
output: output(parsed, &generic_idents),
@@ -488,7 +488,6 @@ pub(crate) fn lazy_binding(node: &Node, index: usize) -> LazyBinding {
}
pub(crate) struct Node {
pub(crate) kernel: Kernel,
pub(crate) generics: Vec<Generic>,
/// Correlated rows (zipped `#[implementations]`, not crossed); empty = erased.
pub(crate) monomorphizations: Vec<ImplRow>,
@@ -499,11 +498,6 @@ pub(crate) struct Node {
pub(crate) derives: bool,
}
/// The kernel fn the node wraps.
pub(crate) struct Kernel {
pub(crate) fn_name: Ident,
}
pub(crate) struct Generic {
pub(crate) ident: Ident,
pub(crate) bounds: Vec<TypeParamBound>,
+2 -6
View File
@@ -349,12 +349,8 @@ fn mirror_vector_extent(
pub use _mirror_vector_mod::mirror_vector_entries;
/// Returns the path identifying the subgraph (network) that contains this proto node — i.e. the input `node_path`
/// with its own trailing entry dropped. The terminating element of the returned path is the document node whose
/// encapsulated network we live in, so the path doubles as a unique reference to that node at any nesting depth.
/// Used as the value source for stamping the `editor:layer_path` attribute on each item of a layer's output, which lets
/// editor tools (e.g. selection, click target routing) trace data back to its owning layer regardless of whether
/// the layer is at the root document network or nested inside a custom subgraph.
/// `node_path` with its trailing entry dropped: the containing network's path, which is also a unique
/// reference to the owning document node at any nesting depth. Stamped onto `editor:layer_path`.
#[node_macro::node(name("Path of Subgraph"), category(""))]
pub fn path_of_subgraph(_: impl Ctx, node_path: Vec<NodeId>) -> Vec<NodeId> {
let len = node_path.len();
+2 -1
View File
@@ -17,7 +17,7 @@ use core_types::transform::Transform;
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, CacheHash, Color, Ctx, DeriveCtx, ExtractIndex, InjectIndex};
use glam::{DAffine2, DMat2, DVec2};
use graphic_types::graphic::{bake_paint_transforms, has_paint, is_paint_present, paint_graphics, set_paint_attribute_at};
use graphic_types::graphic::{bake_paint_transforms, has_paint, is_paint_present, set_paint_attribute_at};
use graphic_types::markers::{EditorMergedLayers, Fill, Stroke as StrokeAttr};
use graphic_types::raster_types::{CPU, GPU, Raster};
use graphic_types::{ATTR_EDITOR_MERGED_LAYERS, ATTR_FILL, ATTR_STROKE, Graphic, IntoGraphicList};
@@ -3776,6 +3776,7 @@ fn centroid(_: impl Ctx, vector: IList<Vector>, centroid_type: CentroidType) ->
mod test {
use super::*;
use core_types::transform::Footprint;
use graphic_types::graphic::paint_graphics;
use kurbo::{CubicBez, Ellipse, Point, Rect};
use vector_types::vector::algorithms::bezpath_algorithms::{TValue, trim_pathseg};
use vector_types::vector::misc::pathseg_abs_diff_eq;