mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
Instance tables refactor part 4: replace ArtboardGroups with multi-row Instances<Artboard> (#2265)
* Clean up dyn_any usages * Migrate ArtboardGroup to ArtboardGroupTable (not yet flattened) * Reorder graphical data imports * Flatten and remove ArtboardGroup in favor of ArtboardGroupTable * Fix test
This commit is contained in:
@@ -734,8 +734,6 @@ impl Adjust<Color> for GradientStops {
|
||||
}
|
||||
impl<P: Pixel> Adjust<P> for ImageFrameTable<P>
|
||||
where
|
||||
P: dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
fn adjust(&mut self, map_fn: impl Fn(&P) -> P) {
|
||||
@@ -1382,8 +1380,6 @@ impl MultiplyAlpha for GraphicGroupTable {
|
||||
}
|
||||
impl<P: Pixel> MultiplyAlpha for ImageFrameTable<P>
|
||||
where
|
||||
P: dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
fn multiply_alpha(&mut self, factor: f64) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
||||
#[cfg_attr(not(target_arch = "spirv"), derive(Debug))]
|
||||
|
||||
@@ -4,8 +4,9 @@ use crate::vector::brush_stroke::BrushStroke;
|
||||
use crate::vector::brush_stroke::BrushStyle;
|
||||
use crate::Color;
|
||||
|
||||
use core::hash::Hash;
|
||||
use dyn_any::DynAny;
|
||||
|
||||
use core::hash::Hash;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
@@ -57,7 +58,7 @@ impl BrushCacheImpl {
|
||||
background = core::mem::take(&mut self.blended_image);
|
||||
|
||||
// Check if the first non-blended stroke is an extension of the last one.
|
||||
let mut first_stroke_texture = ImageFrameTable::empty();
|
||||
let mut first_stroke_texture = ImageFrameTable::one_empty_image();
|
||||
let mut first_stroke_point_skip = 0;
|
||||
let strokes = input[num_blended_strokes..].to_vec();
|
||||
if !strokes.is_empty() && self.prev_input.len() > num_blended_strokes {
|
||||
|
||||
@@ -176,6 +176,7 @@ pub struct ValueMapperNode<C> {
|
||||
lut: Vec<C>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "dyn-any")]
|
||||
unsafe impl<C: StaticTypeSized> StaticType for ValueMapperNode<C> {
|
||||
type Static = ValueMapperNode<C::Static>;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use super::discrete_srgb::float_to_srgb_u8;
|
||||
use super::Color;
|
||||
use crate::{instances::Instances, transform::TransformMut};
|
||||
use crate::{AlphaBlending, GraphicElement};
|
||||
use crate::instances::Instances;
|
||||
use crate::transform::TransformMut;
|
||||
use crate::AlphaBlending;
|
||||
use crate::GraphicElement;
|
||||
use alloc::vec::Vec;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use dyn_any::StaticType;
|
||||
@@ -68,6 +70,7 @@ impl<P: Pixel + Debug> Debug for Image<P> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dyn-any")]
|
||||
unsafe impl<P> StaticType for Image<P>
|
||||
where
|
||||
P: dyn_any::StaticTypeSized + Pixel,
|
||||
@@ -235,6 +238,8 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dyn-any")]
|
||||
unsafe impl<P> StaticType for ImageFrame<P>
|
||||
where
|
||||
P: dyn_any::StaticTypeSized + Pixel,
|
||||
@@ -279,7 +284,7 @@ pub type ImageFrameTable<P> = Instances<Image<P>>;
|
||||
|
||||
/// Construct a 0x0 image frame table. This is useful because ImageFrameTable::default() will return a 1x1 image frame table.
|
||||
impl ImageFrameTable<Color> {
|
||||
pub fn empty() -> Self {
|
||||
pub fn one_empty_image() -> Self {
|
||||
let mut result = Self::new(Image::default());
|
||||
*result.transform_mut() = DAffine2::ZERO;
|
||||
result
|
||||
@@ -302,8 +307,7 @@ impl<P: Debug + Copy + Pixel> Sample for Image<P> {
|
||||
|
||||
impl<P> Sample for ImageFrameTable<P>
|
||||
where
|
||||
P: Debug + Copy + Pixel + dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
P: Debug + Copy + Pixel,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
type Pixel = P;
|
||||
@@ -323,8 +327,7 @@ where
|
||||
|
||||
impl<P> Bitmap for ImageFrameTable<P>
|
||||
where
|
||||
P: Copy + Pixel + dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
P: Copy + Pixel,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
type Pixel = P;
|
||||
@@ -350,8 +353,7 @@ where
|
||||
|
||||
impl<P> BitmapMut for ImageFrameTable<P>
|
||||
where
|
||||
P: Copy + Pixel + dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
P: Copy + Pixel,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel> {
|
||||
|
||||
Reference in New Issue
Block a user