Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ graphite-proc-macros = { path = "proc-macros" }
graphite-editor = { path = "editor" }
graphene-canvas-utils = { path = "node-graph/libraries/canvas-utils" }
ipsum = { path = "libraries/ipsum" }
graphene-cache = { path = "node-graph/libraries/graphene-cache" }

# Workspace dependencies
rustc-hash = "2.0"
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/brush_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ fn new_brush_layer(document: &DocumentMessageHandler, responses: &mut VecDeque<M

let brush_node = resolve_proto_node_type(active_brush::IDENTIFIER)
.expect("Brush node does not exist")
.node_template_input_override([None, Some(NodeInput::value(TaggedValue::BrushCache(Default::default()), false))]);
.node_template_input_override([None, Some(NodeInput::value(TaggedValue::CacheHandle(Default::default()), false))]);

let id = NodeId::new();
responses.add(GraphOperationMessage::NewCustomLayer {
Expand Down
1 change: 1 addition & 0 deletions node-graph/graph-craft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ graphene-hash = { workspace = true }
core-types = { workspace = true, features = ["serde"] }
brush-nodes = { workspace = true, features = ["serde"] }
graphene-core = { workspace = true, features = ["serde"] }
graphene-cache = { workspace = true, features = ["serde"] }
graphene-application-io = { workspace = true, features = ["serde"] }
rendering = { workspace = true, features = ["serde"] }
raster-nodes = { workspace = true, features = ["serde"] }
Expand Down
23 changes: 13 additions & 10 deletions node-graph/graph-craft/src/document/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::DocumentNode;
use crate::application_io::PlatformEditorApi;
use crate::application_io::resource::Resource;
use crate::proto::{Any as DAny, FutureAny};
use brush_nodes::{BrushCache, Stroke};
use brush_nodes::Stroke;
use core_types::color::SRGBA8;
use core_types::list::{Item, List, NodeIdPath};
use core_types::transfer_curve::TransferCurve;
Expand All @@ -13,6 +13,7 @@ pub use dyn_any::StaticType;
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphene_application_io::resource::ResourceHash;
use graphene_application_io::resource::ResourceId;
use graphene_cache::CacheHandle;
use graphic_types::raster_types::{CPU, Image, Raster};
use graphic_types::vector_types::vector::misc::BoxCorners;
use graphic_types::vector_types::vector::style::DashPattern;
Expand Down Expand Up @@ -97,7 +98,9 @@ macro_rules! tagged_value {
#[serde(alias = "Gradient", alias = "GradientTable", alias = "GradientPositions", alias = "GradientStops")]
GradientRamp(GradientRamp),
Strokes(Vec<Stroke>),
BrushCache(BrushCache),
/// Type-erased handle to a lazily initialized [`graphene_cache::Cache`].
#[serde(alias = "BrushCache")]
CacheHandle(CacheHandle),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -142,7 +145,7 @@ macro_rules! tagged_value {
Self::TransferCurve(points) => points.cache_hash(state),
Self::GradientRamp(ramp) => ramp.cache_hash(state),
Self::Strokes(strokes) => strokes.cache_hash(state),
Self::BrushCache(cache) => cache.cache_hash(state),
Self::CacheHandle(cache) => cache.cache_hash(state),
// =======================
// NON-SERIALIZED VARIANTS
// =======================
Expand Down Expand Up @@ -210,7 +213,7 @@ macro_rules! tagged_value {
let list: List<Stroke> = strokes.into_iter().map(core_types::list::Item::new_from_element).collect();
Box::new(list)
}
Self::BrushCache(cache) => Box::new(Item::new_from_element(cache)),
Self::CacheHandle(cache) => Box::new(Item::new_from_element(cache)),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -278,7 +281,7 @@ macro_rules! tagged_value {
let list: List<Stroke> = strokes.into_iter().map(core_types::list::Item::new_from_element).collect();
Arc::new(list)
}
Self::BrushCache(cache) => Arc::new(Item::new_from_element(cache)),
Self::CacheHandle(cache) => Arc::new(Item::new_from_element(cache)),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -309,7 +312,7 @@ macro_rules! tagged_value {
Self::TransferCurve(_) => item!(TransferCurve),
Self::GradientRamp(_) => item!(Gradient),
Self::Strokes(_) => list!(Stroke),
Self::BrushCache(_) => item!(BrushCache),
Self::CacheHandle(_) => item!(CacheHandle),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -351,7 +354,7 @@ macro_rules! tagged_value {
x if x == TypeId::of::<Gradient>() => Ok(TaggedValue::GradientRamp(GradientRamp::from(*downcast::<Gradient>(input).unwrap()))),
x if x == TypeId::of::<Item<Gradient>>() => Ok(TaggedValue::GradientRamp(GradientRamp::from(&*downcast::<Item<Gradient>>(input).unwrap()))),
x if x == TypeId::of::<List<Stroke>>() => Ok(TaggedValue::Strokes(downcast::<List<Stroke>>(input).unwrap().into_iter().map(Item::into_element).collect())),
x if x == TypeId::of::<Item<BrushCache>>() => Ok(TaggedValue::BrushCache(downcast::<Item<BrushCache>>(input).unwrap().into_element())),
x if x == TypeId::of::<Item<CacheHandle>>() => Ok(TaggedValue::CacheHandle(downcast::<Item<CacheHandle>>(input).unwrap().into_element())),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -387,7 +390,7 @@ macro_rules! tagged_value {
x if x == TypeId::of::<Gradient>() => Ok(TaggedValue::GradientRamp(GradientRamp::from(input.downcast_ref::<Gradient>().unwrap()))),
x if x == TypeId::of::<Item<Gradient>>() => Ok(TaggedValue::GradientRamp(GradientRamp::from(input.downcast_ref::<Item<Gradient>>().unwrap()))),
x if x == TypeId::of::<List<Stroke>>() => Ok(TaggedValue::Strokes(input.downcast_ref::<List<Stroke>>().unwrap().iter_element_values().cloned().collect())),
x if x == TypeId::of::<Item<BrushCache>>() => Ok(TaggedValue::BrushCache(input.downcast_ref::<Item<BrushCache>>().unwrap().element().clone())),
x if x == TypeId::of::<Item<CacheHandle>>() => Ok(TaggedValue::CacheHandle(input.downcast_ref::<Item<CacheHandle>>().unwrap().element().clone())),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down Expand Up @@ -417,7 +420,7 @@ macro_rules! tagged_value {
if name == std::any::type_name::<TransferCurve>() { return Some(TaggedValue::TransferCurve(TransferCurve::default().points().to_vec())) }
$( if name == std::any::type_name::<$ty>() { return Some(TaggedValue::$identifier(Default::default())) } )*
if name == std::any::type_name::<List<Stroke>>() { return Some(TaggedValue::Strokes(Vec::new())) }
if name == std::any::type_name::<BrushCache>() { return Some(TaggedValue::BrushCache(Default::default())) }
if name == std::any::type_name::<CacheHandle>() { return Some(TaggedValue::CacheHandle(Default::default())) }
// Unranked types without a variant route through `TypeDefault`, with `to_dynany`/`to_any` constructing the actual default at execution time
macro_rules! check_bare {
($type_default:ty) => {
Expand Down Expand Up @@ -475,7 +478,7 @@ macro_rules! tagged_value {
Self::TransferCurve(points) => format!("TransferCurve({points:?})"),
Self::GradientRamp(ramp) => format!("GradientRamp({ramp:?})"),
Self::Strokes(strokes) => format!("Strokes({strokes:?})"),
Self::BrushCache(cache) => format!("{cache:?}"),
Self::CacheHandle(cache) => format!("{cache:?}"),
// =======================
// AUTO-GENERATED VARIANTS
// =======================
Expand Down
Loading
Loading