mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Treat a single-lane leveled value as invariant under the addressed lane
This commit is contained in:
@@ -304,6 +304,28 @@ macro_rules! tagged_value {
|
||||
}
|
||||
}
|
||||
|
||||
/// The lane count of the level [`Self::to_edge`] serves, or `None` for a
|
||||
/// scalar. At most one lane serves the same record at every index, so
|
||||
/// the addressed lane cannot reach the value.
|
||||
pub fn lane_count(&self) -> Option<usize> {
|
||||
match self {
|
||||
Self::TypeDefault(td) => {
|
||||
let name = td.name.as_ref();
|
||||
if name == std::any::type_name::<List<Graphic>>() { return Some(0); }
|
||||
if name == std::any::type_name::<List<Artboard>>() { return Some(0); }
|
||||
if name == std::any::type_name::<List<Raster<CPU>>>() { return Some(0); }
|
||||
if name == std::any::type_name::<List<Vector>>() { return Some(1); }
|
||||
if name == std::any::type_name::<List<String>>() { return Some(0); }
|
||||
None
|
||||
}
|
||||
Self::F64Array(values) => Some(values.len()),
|
||||
Self::Color(color) => Some(color.iter().count()),
|
||||
Self::Gradient(_) => Some(1),
|
||||
Self::BrushStrokes(strokes) => Some(strokes.len()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Materializes the value as [`Self::to_dynany`] does, wrapped in a `ClonedNode` edge typed by [`Self::ty`].
|
||||
pub fn to_edge(self) -> Result<EdgeHandle, String> {
|
||||
match self {
|
||||
|
||||
@@ -556,8 +556,10 @@ impl ProtoNetwork {
|
||||
// We pretend like we have already placed context modification nodes after ourselves because value nodes don't need to be cached
|
||||
ConstructionArgs::Value(value) => {
|
||||
let mut deps = own_deps;
|
||||
// A leveled value serves its lanes by the innermost index.
|
||||
if value.value_layout().is_some_and(|layout| layout.depth > 0) {
|
||||
// A leveled value serves its lanes by the innermost index, unless
|
||||
// it holds at most one lane to serve.
|
||||
let leveled = value.value_layout().is_some_and(|layout| layout.depth > 0);
|
||||
if leveled && value.lane_count().is_none_or(|lanes| lanes > 1) {
|
||||
deps |= core_types::context::ContextFeatures::INDEX;
|
||||
deps.index_levels |= core_types::context::IndexLevels::innermost();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user