Implement dynamic table attributes to generalize the graphic-specific Table type (#4050)

* Feature-gate serde derives behind cfg_attr in all runtime node graph type crates

* Refactor Table to move its hard-coded fields into an attributes field

* Encapsulate TableRow/TableRowRef/TableRowMut attribute fields behind accessor methods

* Remove TaggedValue::GraphicUnused

* Refactor Table<T> to use dynamic attributes instead fixed names

* Fix code review soundness concerns

* Add todo work

* Replace row-oriented Table<T> API with column-oriented access

* Fix attribute propagation bugs

---------
This commit is contained in:
Keavon Chambers
2026-04-28 02:10:24 -07:00
parent 324b9e664c
commit 76938eb69a
75 changed files with 2330 additions and 1349 deletions

View File

@@ -1,3 +1,4 @@
use core_types::AlphaBlending;
use core_types::registry::types::Percentage;
use core_types::table::Table;
use core_types::{BlendMode, Color, Ctx};
@@ -17,36 +18,36 @@ impl MultiplyAlpha for Color {
}
impl MultiplyAlpha for Table<Vector> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.opacity *= factor as f32;
}
}
}
impl MultiplyAlpha for Table<Graphic> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.opacity *= factor as f32;
}
}
}
impl MultiplyAlpha for Table<Raster<CPU>> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.opacity *= factor as f32;
}
}
}
impl MultiplyAlpha for Table<Color> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.opacity *= factor as f32;
}
}
}
impl MultiplyAlpha for Table<GradientStops> {
fn multiply_alpha(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.opacity *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.opacity *= factor as f32;
}
}
}
@@ -61,36 +62,36 @@ impl MultiplyFill for Color {
}
impl MultiplyFill for Table<Vector> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.fill *= factor as f32;
}
}
}
impl MultiplyFill for Table<Graphic> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.fill *= factor as f32;
}
}
}
impl MultiplyFill for Table<Raster<CPU>> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.fill *= factor as f32;
}
}
}
impl MultiplyFill for Table<Color> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.fill *= factor as f32;
}
}
}
impl MultiplyFill for Table<GradientStops> {
fn multiply_fill(&mut self, factor: f64) {
for row in self.iter_mut() {
row.alpha_blending.fill *= factor as f32;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.fill *= factor as f32;
}
}
}
@@ -101,36 +102,36 @@ trait SetBlendMode {
impl SetBlendMode for Table<Vector> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.blend_mode = blend_mode;
}
}
}
impl SetBlendMode for Table<Graphic> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.blend_mode = blend_mode;
}
}
}
impl SetBlendMode for Table<Raster<CPU>> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.blend_mode = blend_mode;
}
}
}
impl SetBlendMode for Table<Color> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.blend_mode = blend_mode;
}
}
}
impl SetBlendMode for Table<GradientStops> {
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
for row in self.iter_mut() {
row.alpha_blending.blend_mode = blend_mode;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.blend_mode = blend_mode;
}
}
}
@@ -141,36 +142,36 @@ trait SetClip {
impl SetClip for Table<Vector> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.clip = clip;
}
}
}
impl SetClip for Table<Graphic> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.clip = clip;
}
}
}
impl SetClip for Table<Raster<CPU>> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.clip = clip;
}
}
}
impl SetClip for Table<Color> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.clip = clip;
}
}
}
impl SetClip for Table<GradientStops> {
fn set_clip(&mut self, clip: bool) {
for row in self.iter_mut() {
row.alpha_blending.clip = clip;
for a in self.iter_attribute_values_mut_or_default::<AlphaBlending>("alpha_blending") {
a.clip = clip;
}
}
}