Skip to content
Merged
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
4 changes: 2 additions & 2 deletions editor/src/messages/frontend/frontend_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use graphene_std::raster::Image;
use graphene_std::raster::color::Color;
use graphene_std::text::{Font, TextAlign};

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;

#[impl_message(Message, Frontend)]
Expand Down Expand Up @@ -322,7 +322,7 @@ pub enum FrontendMessage {
UpdateViewportHolePunch {
active: bool,
},
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
RenderOverlays(
#[serde(skip, default = "OverlayContext::default")]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
description: Cow::Borrowed("Creates a new canvas object."),
properties: None,
},
#[cfg(all(feature = "gpu", target_arch = "wasm32"))]
#[cfg(all(feature = "gpu", target_family = "wasm"))]
DocumentNodeDefinition {
identifier: "Rasterize",
category: "Raster",
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/portfolio/document/overlays/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod grid_overlays;
mod overlays_message;
mod overlays_message_handler;
pub mod utility_functions;
#[cfg_attr(not(target_arch = "wasm32"), path = "utility_types_vello.rs")]
#[cfg_attr(not(target_family = "wasm"), path = "utility_types_vello.rs")]
pub mod utility_types;

#[doc(inline)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ pub struct OverlaysMessageContext<'a> {
#[derive(Debug, Clone, Default, ExtractField)]
pub struct OverlaysMessageHandler {
pub overlay_providers: HashSet<OverlayProvider>,
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
canvas: Option<web_sys::HtmlCanvasElement>,
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
context: Option<web_sys::CanvasRenderingContext2d>,
}

#[message_handler_data]
impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMessageHandler {
fn process_message(&mut self, message: OverlaysMessage, responses: &mut VecDeque<Message>, context: OverlaysMessageContext) {
let OverlaysMessageContext { visibility_settings, ipp, .. } = context;
let device_pixel_ratio = context.device_pixel_ratio;
let OverlaysMessageContext {
visibility_settings,
ipp,
device_pixel_ratio,
..
} = context;

match message {
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
OverlaysMessage::Draw => {
use super::utility_functions::overlay_canvas_element;
use super::utility_types::OverlayContext;
Expand Down Expand Up @@ -68,11 +72,10 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMes
}
}
}
#[cfg(test)]
OverlaysMessage::Draw => {}
#[cfg(all(not(target_arch = "wasm32"), not(test)))]
#[cfg(all(not(target_family = "wasm"), not(test)))]
OverlaysMessage::Draw => {
use super::utility_types::OverlayContext;

let size = ipp.viewport_bounds.size();

let overlay_context = OverlayContext::new(size, device_pixel_ratio, visibility_settings);
Expand All @@ -86,6 +89,13 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMes
}
responses.add(FrontendMessage::RenderOverlays(overlay_context));
}
#[cfg(all(not(target_family = "wasm"), test))]
OverlaysMessage::Draw => {
// Removes unused warnings in test builds
drop(responses);
drop(context);
drop(super::utility_types::OverlayContext::new(ipp.viewport_bounds.size(), device_pixel_ratio, visibility_settings));
}
OverlaysMessage::AddProvider(message) => {
self.overlay_providers.insert(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1424,13 +1424,13 @@ impl NodeNetworkInterface {
.any(|id| id == potentially_upstream_node)
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option<f64> {
warn!("Failed to find width of {node_id:#?} in network_path {network_path:?} due to non-wasm arch");
Some(0.)
}

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option<f64> {
let document = web_sys::window().unwrap().document().unwrap();
let div = match document.create_element("div") {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/portfolio/portfolio_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
responses.add(FrontendMessage::UpdateOpenDocumentsList { open_documents });
}
PortfolioMessage::UpdateVelloPreference => {
let active = if cfg!(target_arch = "wasm32") { false } else { preferences.use_vello };
let active = if cfg!(target_family = "wasm") { false } else { preferences.use_vello };
responses.add(FrontendMessage::UpdateViewportHolePunch { active });
responses.add(NodeGraphMessage::RunDocumentGraph);
self.persistent_data.use_vello = preferences.use_vello;
Expand Down
4 changes: 2 additions & 2 deletions editor/src/node_graph_executor/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ impl NodeRuntime {
pub async fn run(&mut self) -> Option<ImageTexture> {
if self.editor_api.application_io.is_none() {
self.editor_api = WasmEditorApi {
#[cfg(all(not(test), target_arch = "wasm32"))]
#[cfg(all(not(test), target_family = "wasm"))]
application_io: Some(WasmApplicationIo::new().await.into()),
#[cfg(any(test, not(target_arch = "wasm32")))]
#[cfg(any(test, not(target_family = "wasm")))]
application_io: Some(WasmApplicationIo::new_offscreen().await.into()),
font_cache: self.editor_api.font_cache.clone(),
node_graph_message_sender: Box::new(self.sender.clone()),
Expand Down
20 changes: 10 additions & 10 deletions libraries/dyn-any/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,31 @@ fn simple_downcast_panic() {
assert_eq!(*downcast::<u32>(x).expect("attempted to perform invalid downcast"), 3_u32);
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub trait WasmNotSend: Send {}
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub trait WasmNotSend {}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
impl<T: Send> WasmNotSend for T {}

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
impl<T> WasmNotSend for T {}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub trait WasmNotSync: Sync {}
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub trait WasmNotSync {}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
impl<T: Sync> WasmNotSync for T {}

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
impl<T> WasmNotSync for T {}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
#[cfg(feature = "alloc")]
pub type DynFuture<'n, T> = Pin<Box<dyn core::future::Future<Output = T> + 'n + Send>>;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
#[cfg(feature = "alloc")]
pub type DynFuture<'n, T> = Pin<Box<dyn core::future::Future<Output = T> + 'n>>;
10 changes: 5 additions & 5 deletions node-graph/gapplication-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait Size {
fn size(&self) -> UVec2;
}

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
impl Size for web_sys::HtmlCanvasElement {
fn size(&self) -> UVec2 {
UVec2::new(self.width(), self.height())
Expand Down Expand Up @@ -115,9 +115,9 @@ pub struct SurfaceHandle<Surface> {
pub surface: Surface,
}

// #[cfg(target_arch = "wasm32")]
// #[cfg(target_family = "wasm")]
// unsafe impl<T: dyn_any::WasmNotSend> Send for SurfaceHandle<T> {}
// #[cfg(target_arch = "wasm32")]
// #[cfg(target_family = "wasm")]
// unsafe impl<T: dyn_any::WasmNotSync> Sync for SurfaceHandle<T> {}

impl<S: Size> Size for SurfaceHandle<S> {
Expand Down Expand Up @@ -153,9 +153,9 @@ impl<'a, Surface> Drop for SurfaceHandle<'a, Surface> {
}
}*/

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub type ResourceFuture = Pin<Box<dyn Future<Output = Result<Arc<[u8]>, ApplicationError>>>>;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub type ResourceFuture = Pin<Box<dyn Future<Output = Result<Arc<[u8]>, ApplicationError>> + Send>>;

pub trait ApplicationIo {
Expand Down
12 changes: 6 additions & 6 deletions node-graph/gcore/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ pub static NODE_REGISTRY: NodeRegistry = LazyLock::new(|| Mutex::new(HashMap::ne

pub static NODE_METADATA: LazyLock<Mutex<HashMap<ProtoNodeIdentifier, NodeMetadata>>> = LazyLock::new(|| Mutex::new(HashMap::new()));

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub type DynFuture<'n, T> = Pin<Box<dyn Future<Output = T> + 'n + Send>>;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub type DynFuture<'n, T> = Pin<Box<dyn std::future::Future<Output = T> + 'n>>;
pub type LocalFuture<'n, T> = Pin<Box<dyn Future<Output = T> + 'n>>;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub type Any<'n> = Box<dyn DynAny<'n> + 'n + Send>;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub type Any<'n> = Box<dyn DynAny<'n> + 'n>;
pub type FutureAny<'n> = DynFuture<'n, Any<'n>>;
// TODO: is this safe? This is assumed to be send+sync.
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_family = "wasm"))]
pub type TypeErasedNode<'n> = dyn for<'i> NodeIO<'i, Any<'i>, Output = FutureAny<'i>> + 'n + Send + Sync;
#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
pub type TypeErasedNode<'n> = dyn for<'i> NodeIO<'i, Any<'i>, Output = FutureAny<'i>> + 'n;
pub type TypeErasedPinnedRef<'n> = Pin<&'n TypeErasedNode<'n>>;
pub type TypeErasedRef<'n> = &'n TypeErasedNode<'n>;
Expand Down
4 changes: 2 additions & 2 deletions node-graph/graph-craft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ tokio = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }

# Workspace dependencies
[target.'cfg(target_arch = "wasm32")'.dependencies]
[target.'cfg(target_family = "wasm")'.dependencies]
web-sys = { workspace = true, features = [
"Navigator",
"Gpu",
] }
js-sys = { workspace = true }
wasm-bindgen = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
[target.'cfg(not(target_family = "wasm"))'.dependencies]
winit = { workspace = true }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions node-graph/graph-craft/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct DocumentNode {
/// In the root network, it is resolved when evaluating the borrow tree.
/// Ensure the click target in the encapsulating network is updated when the inputs cause the node shape to change (currently only when exposing/hiding an input)
/// by using network.update_click_target(node_id).
#[cfg_attr(target_arch = "wasm32", serde(alias = "outputs"))]
#[cfg_attr(target_family = "wasm", serde(alias = "outputs"))]
pub inputs: Vec<NodeInput>,
/// Manual composition is the methodology by which most nodes are implemented, involving a call argument and upstream inputs.
/// By contrast, automatic composition is an alternative way to handle the composition of nodes as they execute in the graph.
Expand Down Expand Up @@ -552,7 +552,7 @@ pub struct OldDocumentNode {
///
/// In the root network, it is resolved when evaluating the borrow tree.
/// Ensure the click target in the encapsulating network is updated when the inputs cause the node shape to change (currently only when exposing/hiding an input) by using network.update_click_target(node_id).
#[cfg_attr(target_arch = "wasm32", serde(alias = "outputs"))]
#[cfg_attr(target_family = "wasm", serde(alias = "outputs"))]
pub inputs: Vec<NodeInput>,
pub manual_composition: Option<Type>,
// TODO: Remove once this references its definition instead (see above TODO).
Expand Down Expand Up @@ -657,7 +657,7 @@ pub struct NodeNetwork {
/// The list of data outputs that are exported from this network to the parent network.
/// Each export is a reference to a node within this network, paired with its output index, that is the source of the network's exported data.
// TODO: Eventually remove this alias document upgrade code
#[cfg_attr(target_arch = "wasm32", serde(alias = "outputs", deserialize_with = "deserialize_exports"))]
#[cfg_attr(target_family = "wasm", serde(alias = "outputs", deserialize_with = "deserialize_exports"))]
pub exports: Vec<NodeInput>,
// TODO: Instead of storing import types in each NodeInput::Network connection, the types are stored here. This is similar to how types need to be defined for parameters when creating a function in Rust.
// pub import_types: Vec<Type>,
Expand Down
8 changes: 4 additions & 4 deletions node-graph/graph-craft/src/document/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ tagged_value! {
// GRAPHICAL DATA TYPES
// ====================
GraphicElement(graphene_core::GraphicElement),
#[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code
#[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code
VectorData(graphene_core::vector::VectorDataTable),
#[cfg_attr(target_arch = "wasm32", serde(alias = "ImageFrame", deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code
#[cfg_attr(target_family = "wasm", serde(alias = "ImageFrame", deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code
RasterData(graphene_core::raster_types::RasterDataTable<CPU>),
#[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::graphic_element::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code
#[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::graphic_element::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code
GraphicGroup(graphene_core::GraphicGroupTable),
#[cfg_attr(target_arch = "wasm32", serde(deserialize_with = "graphene_core::graphic_element::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code
#[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::graphic_element::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code
ArtboardGroup(graphene_core::ArtboardGroupTable),
// ============
// STRUCT TYPES
Expand Down
Loading
Loading