Integrate into existing font cache

This commit is contained in:
Adam
2025-09-27 17:50:12 -07:00
parent f96a44c4bc
commit e6d6aa6873
6 changed files with 51 additions and 157 deletions

View File

@@ -11,7 +11,6 @@ use graphene_brush::brush_stroke::BrushStroke;
use graphene_core::raster::Image;
use graphene_core::raster_types::{CPU, Raster};
use graphene_core::table::Table;
use graphene_core::text::NewFontCacheWrapper;
use graphene_core::transform::ReferencePoint;
use graphene_core::uuid::NodeId;
use graphene_core::vector::Vector;
@@ -39,9 +38,7 @@ macro_rules! tagged_value {
RenderOutput(RenderOutput),
SurfaceFrame(SurfaceFrame),
#[serde(skip)]
EditorApi(Arc<WasmEditorApi>),
#[serde(skip)]
NewFontCache(NewFontCacheWrapper),
EditorApi(Arc<WasmEditorApi>)
}
// We must manually implement hashing because some values are floats and so do not reproducibly hash (see FakeHash below)
@@ -55,7 +52,6 @@ macro_rules! tagged_value {
Self::RenderOutput(x) => x.hash(state),
Self::SurfaceFrame(x) => x.hash(state),
Self::EditorApi(x) => x.hash(state),
Self::NewFontCache(x) => x.hash(state),
}
}
}
@@ -68,7 +64,6 @@ macro_rules! tagged_value {
Self::RenderOutput(x) => Box::new(x),
Self::SurfaceFrame(x) => Box::new(x),
Self::EditorApi(x) => Box::new(x),
Self::NewFontCache(x) => Box::new(x),
}
}
/// Converts to a Arc<dyn Any + Send + Sync + 'static>
@@ -79,7 +74,6 @@ macro_rules! tagged_value {
Self::RenderOutput(x) => Arc::new(x),
Self::SurfaceFrame(x) => Arc::new(x),
Self::EditorApi(x) => Arc::new(x),
Self::NewFontCache(x) => Arc::new(x),
}
}
/// Creates a graphene_core::Type::Concrete(TypeDescriptor { .. }) with the type of the value inside the tagged value
@@ -89,8 +83,7 @@ macro_rules! tagged_value {
$( Self::$identifier(_) => concrete!($ty), )*
Self::RenderOutput(_) => concrete!(RenderOutput),
Self::SurfaceFrame(_) => concrete!(SurfaceFrame),
Self::EditorApi(_) => concrete!(&WasmEditorApi),
Self::NewFontCache(_) => concrete!(NewFontCacheWrapper),
Self::EditorApi(_) => concrete!(&WasmEditorApi)
}
}
/// Attempts to downcast the dynamic type to a tagged value
@@ -529,14 +522,6 @@ mod fake_hash {
self.1.hash(state)
}
}
impl FakeHash for NewFontCacheWrapper {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
match self.0.lock() {
Ok(inner) => inner.hash.hash(state),
Err(_) => log::error!("Could not lock font cache when hashing"),
}
}
}
}
#[test]