Skip to content

Commit 0e8eb48

Browse files
authored
Extract gapplication_io from gcore (#2742)
move `gcore::application_io` into the new crate `gapplication-io`, remove features `wasm` and `wgpu` from `gcore`
1 parent ae88f4a commit 0e8eb48

File tree

18 files changed

+84
-44
lines changed

18 files changed

+84
-44
lines changed

Cargo.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"proc-macros",
55
"frontend/wasm",
66
"frontend/src-tauri",
7+
"node-graph/gapplication-io",
78
"node-graph/gcore",
89
"node-graph/gstd",
910
"node-graph/graph-craft",
@@ -35,6 +36,7 @@ bezier-rs = { path = "libraries/bezier-rs", features = ["dyn-any", "serde"] }
3536
dyn-any = { path = "libraries/dyn-any", features = ["derive", "glam", "reqwest", "log-bad-types", "rc"] }
3637
math-parser = { path = "libraries/math-parser" }
3738
path-bool = { path = "libraries/path-bool" }
39+
graphene-application-io = { path = "node-graph/gapplication-io" }
3840
graphene-core = { path = "node-graph/gcore" }
3941
graph-craft = { path = "node-graph/graph-craft" }
4042
graphene-std = { path = "node-graph/gstd" }

frontend/wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ editor = { path = "../../editor", package = "graphite-editor", features = [
2929
# Workspace dependencies
3030
graph-craft = { workspace = true }
3131
log = { workspace = true }
32-
graphene-core = { workspace = true, features = ["wasm"] }
32+
graphene-core = { workspace = true }
3333
serde = { workspace = true }
3434
wasm-bindgen = { workspace = true }
3535
serde-wasm-bindgen = { workspace = true }

node-graph/gapplication-io/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "graphene-application-io"
3+
version = "0.1.0"
4+
edition = "2024"
5+
description = "graphene application io interface"
6+
authors = ["Graphite Authors <contact@graphite.rs>"]
7+
license = "MIT OR Apache-2.0"
8+
9+
[features]
10+
wasm = ["dep:web-sys"]
11+
wgpu = ["dep:wgpu"]
12+
13+
[dependencies]
14+
# Local dependencies
15+
dyn-any = { workspace = true }
16+
graphene-core = { workspace = true }
17+
18+
# Workspace dependencies
19+
glam = { workspace = true }
20+
serde = { workspace = true }
21+
log = { workspace = true }
22+
23+
# Optional workspace dependencies
24+
web-sys = { workspace = true, optional = true }
25+
wgpu = { workspace = true, optional = true }

node-graph/gcore/src/application_io.rs renamed to node-graph/gapplication-io/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::text::FontCache;
2-
use crate::transform::Footprint;
3-
use crate::vector::style::ViewMode;
41
use dyn_any::{DynAny, StaticType, StaticTypeSized};
52
use glam::{DAffine2, UVec2};
3+
use graphene_core::text::FontCache;
4+
use graphene_core::transform::Footprint;
5+
use graphene_core::vector::style::ViewMode;
66
use std::fmt::Debug;
77
use std::future::Future;
88
use std::hash::{Hash, Hasher};
@@ -131,6 +131,11 @@ unsafe impl<T: 'static> StaticType for SurfaceHandleFrame<T> {
131131
type Static = SurfaceHandleFrame<T>;
132132
}
133133

134+
#[cfg(feature = "wasm")]
135+
pub type WasmSurfaceHandle = SurfaceHandle<web_sys::HtmlCanvasElement>;
136+
#[cfg(feature = "wasm")]
137+
pub type WasmSurfaceHandleFrame = SurfaceHandleFrame<web_sys::HtmlCanvasElement>;
138+
134139
// TODO: think about how to automatically clean up memory
135140
/*
136141
impl<'a, Surface> Drop for SurfaceHandle<'a, Surface> {

node-graph/gcore/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ authors = ["Graphite Authors <contact@graphite.rs>"]
77
license = "MIT OR Apache-2.0"
88

99
[features]
10-
default = ["serde", "wasm"]
10+
default = ["serde"]
1111
nightly = []
1212
type_id_logging = []
13-
wasm = ["web-sys"]
1413
wgpu = ["dep:wgpu"]
1514
vello = ["dep:vello", "bezier-rs/kurbo", "wgpu"]
1615
dealloc_nodes = []
@@ -47,7 +46,6 @@ base64 = { workspace = true }
4746
serde = { workspace = true, optional = true }
4847
vello = { workspace = true, optional = true }
4948
wgpu = { workspace = true, optional = true }
50-
web-sys = { workspace = true, optional = true }
5149

5250
[dev-dependencies]
5351
# Workspace dependencies

node-graph/gcore/src/graphic_element/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl Default for SvgRender {
299299

300300
#[derive(Clone, Debug, Default)]
301301
pub struct RenderContext {
302-
#[cfg(feature = "wgpu")]
302+
#[cfg(feature = "vello")]
303303
pub resource_overrides: HashMap<u64, std::sync::Arc<wgpu::Texture>>,
304304
}
305305

node-graph/gcore/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ mod graphic_element;
2828
pub use graphic_element::*;
2929
pub mod vector;
3030

31-
pub mod application_io;
32-
3331
pub mod registry;
3432

3533
pub use context::*;
@@ -140,12 +138,6 @@ impl<'i, I, O: 'i> Node<'i, I> for Pin<&'i (dyn NodeIO<'i, I, Output = O> + 'i)>
140138
}
141139
}
142140

143-
pub use crate::application_io::{SurfaceFrame, SurfaceId};
144-
#[cfg(feature = "wasm")]
145-
pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasElement>;
146-
#[cfg(feature = "wasm")]
147-
pub type WasmSurfaceHandleFrame = application_io::SurfaceHandleFrame<web_sys::HtmlCanvasElement>;
148-
149141
pub trait InputAccessorSource<'a, T>: InputAccessorSourceIdentifier + std::fmt::Debug {
150142
fn get_input(&'a self, index: usize) -> Option<&'a T>;
151143
fn set_input(&'a mut self, index: usize, value: T);

node-graph/graph-craft/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ loading = ["serde_json"]
1616
# Local dependencies
1717
dyn-any = { workspace = true }
1818
graphene-core = { workspace = true }
19+
graphene-application-io = { workspace = true }
1920

2021
# Workspace dependencies
2122
log = { workspace = true }

node-graph/graph-craft/src/document/value.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::wasm_application_io::WasmEditorApi;
44
use dyn_any::DynAny;
55
pub use dyn_any::StaticType;
66
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
7+
use graphene_application_io::SurfaceFrame;
78
use graphene_core::raster::brush_cache::BrushCache;
89
use graphene_core::raster::{BlendMode, LuminanceCalculation};
910
use graphene_core::raster_types::CPU;
@@ -30,7 +31,7 @@ macro_rules! tagged_value {
3031
None,
3132
$( $(#[$meta] ) *$identifier( $ty ), )*
3233
RenderOutput(RenderOutput),
33-
SurfaceFrame(graphene_core::SurfaceFrame),
34+
SurfaceFrame(SurfaceFrame),
3435
#[serde(skip)]
3536
EditorApi(Arc<WasmEditorApi>)
3637
}
@@ -76,7 +77,7 @@ macro_rules! tagged_value {
7677
Self::None => concrete!(()),
7778
$( Self::$identifier(_) => concrete!($ty), )*
7879
Self::RenderOutput(_) => concrete!(RenderOutput),
79-
Self::SurfaceFrame(_) => concrete!(graphene_core::SurfaceFrame),
80+
Self::SurfaceFrame(_) => concrete!(SurfaceFrame),
8081
Self::EditorApi(_) => concrete!(&WasmEditorApi)
8182
}
8283
}
@@ -89,7 +90,7 @@ macro_rules! tagged_value {
8990
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
9091
$( x if x == TypeId::of::<$ty>() => Ok(TaggedValue::$identifier(*downcast(input).unwrap())), )*
9192
x if x == TypeId::of::<RenderOutput>() => Ok(TaggedValue::RenderOutput(*downcast(input).unwrap())),
92-
x if x == TypeId::of::<graphene_core::SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(*downcast(input).unwrap())),
93+
x if x == TypeId::of::<SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(*downcast(input).unwrap())),
9394

9495

9596
_ => Err(format!("Cannot convert {:?} to TaggedValue", DynAny::type_name(input.as_ref()))),
@@ -103,7 +104,7 @@ macro_rules! tagged_value {
103104
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
104105
$( x if x == TypeId::of::<$ty>() => Ok(TaggedValue::$identifier(<$ty as Clone>::clone(input.downcast_ref().unwrap()))), )*
105106
x if x == TypeId::of::<RenderOutput>() => Ok(TaggedValue::RenderOutput(RenderOutput::clone(input.downcast_ref().unwrap()))),
106-
x if x == TypeId::of::<graphene_core::SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(graphene_core::SurfaceFrame::clone(input.downcast_ref().unwrap()))),
107+
x if x == TypeId::of::<SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(SurfaceFrame::clone(input.downcast_ref().unwrap()))),
107108
_ => Err(format!("Cannot convert {:?} to TaggedValue",std::any::type_name_of_val(input))),
108109
}
109110
}
@@ -430,7 +431,7 @@ pub struct RenderOutput {
430431

431432
#[derive(Debug, Clone, PartialEq, dyn_any::DynAny, Hash, serde::Serialize, serde::Deserialize)]
432433
pub enum RenderOutputType {
433-
CanvasFrame(graphene_core::SurfaceFrame),
434+
CanvasFrame(SurfaceFrame),
434435
Svg(String),
435436
Image(Vec<u8>),
436437
}

0 commit comments

Comments
 (0)