Fix BrushCache serailization (#1358)

This commit is contained in:
Dennis Kobert
2023-08-04 11:34:54 -07:00
committed by GitHub
parent a267582b4c
commit 94a0f8282e
2 changed files with 3 additions and 3 deletions
+2 -1
View File
@@ -23,7 +23,7 @@ struct BrushCacheImpl {
last_stroke_texture: ImageFrame<Color>, last_stroke_texture: ImageFrame<Color>,
// A cache for brush textures. // A cache for brush textures.
#[serde(skip)] #[cfg_attr(feature = "serde", serde(skip))]
brush_texture_cache: HashMap<BrushStyle, Image<Color>>, brush_texture_cache: HashMap<BrushStyle, Image<Color>>,
} }
@@ -99,6 +99,7 @@ pub struct BrushPlan {
pub first_stroke_point_skip: usize, pub first_stroke_point_skip: usize,
} }
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, DynAny, Default)] #[derive(Debug, DynAny, Default)]
pub struct BrushCache { pub struct BrushCache {
inner: Arc<Mutex<BrushCacheImpl>>, inner: Arc<Mutex<BrushCacheImpl>>,
+1 -2
View File
@@ -55,7 +55,6 @@ pub enum TaggedValue {
ManipulatorGroupIds(Vec<graphene_core::uuid::ManipulatorGroupId>), ManipulatorGroupIds(Vec<graphene_core::uuid::ManipulatorGroupId>),
Font(graphene_core::text::Font), Font(graphene_core::text::Font),
BrushStrokes(Vec<graphene_core::vector::brush_stroke::BrushStroke>), BrushStrokes(Vec<graphene_core::vector::brush_stroke::BrushStroke>),
#[cfg_attr(feature = "serde", serde(skip))]
BrushCache(BrushCache), BrushCache(BrushCache),
Segments(Vec<graphene_core::raster::ImageFrame<Color>>), Segments(Vec<graphene_core::raster::ImageFrame<Color>>),
DocumentNode(DocumentNode), DocumentNode(DocumentNode),
@@ -294,7 +293,7 @@ impl<'a> TaggedValue {
x if x == TypeId::of::<Vec<graphene_core::uuid::ManipulatorGroupId>>() => Ok(TaggedValue::ManipulatorGroupIds(*downcast(input).unwrap())), x if x == TypeId::of::<Vec<graphene_core::uuid::ManipulatorGroupId>>() => Ok(TaggedValue::ManipulatorGroupIds(*downcast(input).unwrap())),
x if x == TypeId::of::<graphene_core::text::Font>() => Ok(TaggedValue::Font(*downcast(input).unwrap())), x if x == TypeId::of::<graphene_core::text::Font>() => Ok(TaggedValue::Font(*downcast(input).unwrap())),
x if x == TypeId::of::<Vec<graphene_core::vector::brush_stroke::BrushStroke>>() => Ok(TaggedValue::BrushStrokes(*downcast(input).unwrap())), x if x == TypeId::of::<Vec<graphene_core::vector::brush_stroke::BrushStroke>>() => Ok(TaggedValue::BrushStrokes(*downcast(input).unwrap())),
x if x == TypeId::of::<Vec<BrushCache>>() => Ok(TaggedValue::BrushCache(*downcast(input).unwrap())), x if x == TypeId::of::<BrushCache>() => Ok(TaggedValue::BrushCache(*downcast(input).unwrap())),
x if x == TypeId::of::<graphene_core::raster::IndexNode<Vec<graphene_core::raster::ImageFrame<Color>>>>() => Ok(TaggedValue::Segments(*downcast(input).unwrap())), x if x == TypeId::of::<graphene_core::raster::IndexNode<Vec<graphene_core::raster::ImageFrame<Color>>>>() => Ok(TaggedValue::Segments(*downcast(input).unwrap())),
x if x == TypeId::of::<crate::document::DocumentNode>() => Ok(TaggedValue::DocumentNode(*downcast(input).unwrap())), x if x == TypeId::of::<crate::document::DocumentNode>() => Ok(TaggedValue::DocumentNode(*downcast(input).unwrap())),
x if x == TypeId::of::<graphene_core::GraphicGroup>() => Ok(TaggedValue::GraphicGroup(*downcast(input).unwrap())), x if x == TypeId::of::<graphene_core::GraphicGroup>() => Ok(TaggedValue::GraphicGroup(*downcast(input).unwrap())),