mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user