mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-31 18:27:20 +00:00
Use target family insted of target arch (#2975)
* Replace cfg target_arch wasm32 with target_family wasm * Fix warnings in test builds from previous pr
This commit is contained in:
parent
1e3c3da3fe
commit
67123f55dc
18 changed files with 106 additions and 96 deletions
|
@ -13,7 +13,7 @@ use graphene_std::raster::Image;
|
||||||
use graphene_std::raster::color::Color;
|
use graphene_std::raster::color::Color;
|
||||||
use graphene_std::text::{Font, TextAlign};
|
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;
|
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
|
||||||
|
|
||||||
#[impl_message(Message, Frontend)]
|
#[impl_message(Message, Frontend)]
|
||||||
|
@ -322,7 +322,7 @@ pub enum FrontendMessage {
|
||||||
UpdateViewportHolePunch {
|
UpdateViewportHolePunch {
|
||||||
active: bool,
|
active: bool,
|
||||||
},
|
},
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
RenderOverlays(
|
RenderOverlays(
|
||||||
#[serde(skip, default = "OverlayContext::default")]
|
#[serde(skip, default = "OverlayContext::default")]
|
||||||
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
||||||
|
|
|
@ -591,7 +591,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
||||||
description: Cow::Borrowed("Creates a new canvas object."),
|
description: Cow::Borrowed("Creates a new canvas object."),
|
||||||
properties: None,
|
properties: None,
|
||||||
},
|
},
|
||||||
#[cfg(all(feature = "gpu", target_arch = "wasm32"))]
|
#[cfg(all(feature = "gpu", target_family = "wasm"))]
|
||||||
DocumentNodeDefinition {
|
DocumentNodeDefinition {
|
||||||
identifier: "Rasterize",
|
identifier: "Rasterize",
|
||||||
category: "Raster",
|
category: "Raster",
|
||||||
|
|
|
@ -2,7 +2,7 @@ pub mod grid_overlays;
|
||||||
mod overlays_message;
|
mod overlays_message;
|
||||||
mod overlays_message_handler;
|
mod overlays_message_handler;
|
||||||
pub mod utility_functions;
|
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;
|
pub mod utility_types;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
|
|
@ -11,20 +11,24 @@ pub struct OverlaysMessageContext<'a> {
|
||||||
#[derive(Debug, Clone, Default, ExtractField)]
|
#[derive(Debug, Clone, Default, ExtractField)]
|
||||||
pub struct OverlaysMessageHandler {
|
pub struct OverlaysMessageHandler {
|
||||||
pub overlay_providers: HashSet<OverlayProvider>,
|
pub overlay_providers: HashSet<OverlayProvider>,
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
canvas: Option<web_sys::HtmlCanvasElement>,
|
canvas: Option<web_sys::HtmlCanvasElement>,
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
context: Option<web_sys::CanvasRenderingContext2d>,
|
context: Option<web_sys::CanvasRenderingContext2d>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[message_handler_data]
|
#[message_handler_data]
|
||||||
impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMessageHandler {
|
impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMessageHandler {
|
||||||
fn process_message(&mut self, message: OverlaysMessage, responses: &mut VecDeque<Message>, context: OverlaysMessageContext) {
|
fn process_message(&mut self, message: OverlaysMessage, responses: &mut VecDeque<Message>, context: OverlaysMessageContext) {
|
||||||
let OverlaysMessageContext { visibility_settings, ipp, .. } = context;
|
let OverlaysMessageContext {
|
||||||
let device_pixel_ratio = context.device_pixel_ratio;
|
visibility_settings,
|
||||||
|
ipp,
|
||||||
|
device_pixel_ratio,
|
||||||
|
..
|
||||||
|
} = context;
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
OverlaysMessage::Draw => {
|
OverlaysMessage::Draw => {
|
||||||
use super::utility_functions::overlay_canvas_element;
|
use super::utility_functions::overlay_canvas_element;
|
||||||
use super::utility_types::OverlayContext;
|
use super::utility_types::OverlayContext;
|
||||||
|
@ -68,11 +72,10 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(all(not(target_family = "wasm"), not(test)))]
|
||||||
OverlaysMessage::Draw => {}
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), not(test)))]
|
|
||||||
OverlaysMessage::Draw => {
|
OverlaysMessage::Draw => {
|
||||||
use super::utility_types::OverlayContext;
|
use super::utility_types::OverlayContext;
|
||||||
|
|
||||||
let size = ipp.viewport_bounds.size();
|
let size = ipp.viewport_bounds.size();
|
||||||
|
|
||||||
let overlay_context = OverlayContext::new(size, device_pixel_ratio, visibility_settings);
|
let overlay_context = OverlayContext::new(size, device_pixel_ratio, visibility_settings);
|
||||||
|
@ -86,6 +89,13 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageContext<'_>> for OverlaysMes
|
||||||
}
|
}
|
||||||
responses.add(FrontendMessage::RenderOverlays(overlay_context));
|
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) => {
|
OverlaysMessage::AddProvider(message) => {
|
||||||
self.overlay_providers.insert(message);
|
self.overlay_providers.insert(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1424,13 +1424,13 @@ impl NodeNetworkInterface {
|
||||||
.any(|id| id == potentially_upstream_node)
|
.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> {
|
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");
|
warn!("Failed to find width of {node_id:#?} in network_path {network_path:?} due to non-wasm arch");
|
||||||
Some(0.)
|
Some(0.)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option<f64> {
|
fn text_width(&self, node_id: &NodeId, network_path: &[NodeId]) -> Option<f64> {
|
||||||
let document = web_sys::window().unwrap().document().unwrap();
|
let document = web_sys::window().unwrap().document().unwrap();
|
||||||
let div = match document.create_element("div") {
|
let div = match document.create_element("div") {
|
||||||
|
|
|
@ -962,7 +962,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||||
responses.add(FrontendMessage::UpdateOpenDocumentsList { open_documents });
|
responses.add(FrontendMessage::UpdateOpenDocumentsList { open_documents });
|
||||||
}
|
}
|
||||||
PortfolioMessage::UpdateVelloPreference => {
|
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(FrontendMessage::UpdateViewportHolePunch { active });
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||||
self.persistent_data.use_vello = preferences.use_vello;
|
self.persistent_data.use_vello = preferences.use_vello;
|
||||||
|
|
|
@ -134,9 +134,9 @@ impl NodeRuntime {
|
||||||
pub async fn run(&mut self) -> Option<ImageTexture> {
|
pub async fn run(&mut self) -> Option<ImageTexture> {
|
||||||
if self.editor_api.application_io.is_none() {
|
if self.editor_api.application_io.is_none() {
|
||||||
self.editor_api = WasmEditorApi {
|
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()),
|
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()),
|
application_io: Some(WasmApplicationIo::new_offscreen().await.into()),
|
||||||
font_cache: self.editor_api.font_cache.clone(),
|
font_cache: self.editor_api.font_cache.clone(),
|
||||||
node_graph_message_sender: Box::new(self.sender.clone()),
|
node_graph_message_sender: Box::new(self.sender.clone()),
|
||||||
|
|
|
@ -363,31 +363,31 @@ fn simple_downcast_panic() {
|
||||||
assert_eq!(*downcast::<u32>(x).expect("attempted to perform invalid downcast"), 3_u32);
|
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 {}
|
pub trait WasmNotSend: Send {}
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
pub trait WasmNotSend {}
|
pub trait WasmNotSend {}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
impl<T: Send> WasmNotSend for T {}
|
impl<T: Send> WasmNotSend for T {}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
impl<T> WasmNotSend for T {}
|
impl<T> WasmNotSend for T {}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
pub trait WasmNotSync: Sync {}
|
pub trait WasmNotSync: Sync {}
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
pub trait WasmNotSync {}
|
pub trait WasmNotSync {}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
impl<T: Sync> WasmNotSync for T {}
|
impl<T: Sync> WasmNotSync for T {}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
impl<T> WasmNotSync for T {}
|
impl<T> WasmNotSync for T {}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
pub type DynFuture<'n, T> = Pin<Box<dyn core::future::Future<Output = T> + 'n + Send>>;
|
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")]
|
#[cfg(feature = "alloc")]
|
||||||
pub type DynFuture<'n, T> = Pin<Box<dyn core::future::Future<Output = T> + 'n>>;
|
pub type DynFuture<'n, T> = Pin<Box<dyn core::future::Future<Output = T> + 'n>>;
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub trait Size {
|
||||||
fn size(&self) -> UVec2;
|
fn size(&self) -> UVec2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
impl Size for web_sys::HtmlCanvasElement {
|
impl Size for web_sys::HtmlCanvasElement {
|
||||||
fn size(&self) -> UVec2 {
|
fn size(&self) -> UVec2 {
|
||||||
UVec2::new(self.width(), self.height())
|
UVec2::new(self.width(), self.height())
|
||||||
|
@ -115,9 +115,9 @@ pub struct SurfaceHandle<Surface> {
|
||||||
pub surface: Surface,
|
pub surface: Surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(target_arch = "wasm32")]
|
// #[cfg(target_family = "wasm")]
|
||||||
// unsafe impl<T: dyn_any::WasmNotSend> Send for SurfaceHandle<T> {}
|
// 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> {}
|
// unsafe impl<T: dyn_any::WasmNotSync> Sync for SurfaceHandle<T> {}
|
||||||
|
|
||||||
impl<S: Size> Size for SurfaceHandle<S> {
|
impl<S: Size> Size for SurfaceHandle<S> {
|
||||||
|
@ -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>>>>;
|
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 type ResourceFuture = Pin<Box<dyn Future<Output = Result<Arc<[u8]>, ApplicationError>> + Send>>;
|
||||||
|
|
||||||
pub trait ApplicationIo {
|
pub trait ApplicationIo {
|
||||||
|
|
|
@ -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()));
|
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>>;
|
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 DynFuture<'n, T> = Pin<Box<dyn std::future::Future<Output = T> + 'n>>;
|
||||||
pub type LocalFuture<'n, T> = Pin<Box<dyn 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>;
|
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 Any<'n> = Box<dyn DynAny<'n> + 'n>;
|
||||||
pub type FutureAny<'n> = DynFuture<'n, Any<'n>>;
|
pub type FutureAny<'n> = DynFuture<'n, Any<'n>>;
|
||||||
// TODO: is this safe? This is assumed to be send+sync.
|
// 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;
|
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 TypeErasedNode<'n> = dyn for<'i> NodeIO<'i, Any<'i>, Output = FutureAny<'i>> + 'n;
|
||||||
pub type TypeErasedPinnedRef<'n> = Pin<&'n TypeErasedNode<'n>>;
|
pub type TypeErasedPinnedRef<'n> = Pin<&'n TypeErasedNode<'n>>;
|
||||||
pub type TypeErasedRef<'n> = &'n TypeErasedNode<'n>;
|
pub type TypeErasedRef<'n> = &'n TypeErasedNode<'n>;
|
||||||
|
|
|
@ -38,7 +38,7 @@ tokio = { workspace = true, optional = true }
|
||||||
serde_json = { workspace = true, optional = true }
|
serde_json = { workspace = true, optional = true }
|
||||||
|
|
||||||
# Workspace dependencies
|
# Workspace dependencies
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
web-sys = { workspace = true, features = [
|
web-sys = { workspace = true, features = [
|
||||||
"Navigator",
|
"Navigator",
|
||||||
"Gpu",
|
"Gpu",
|
||||||
|
@ -46,7 +46,7 @@ web-sys = { workspace = true, features = [
|
||||||
js-sys = { workspace = true }
|
js-sys = { workspace = true }
|
||||||
wasm-bindgen = { workspace = true }
|
wasm-bindgen = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
winit = { workspace = true }
|
winit = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub struct DocumentNode {
|
||||||
/// In the root network, it is resolved when evaluating the borrow tree.
|
/// 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)
|
/// 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).
|
/// 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 inputs: Vec<NodeInput>,
|
||||||
/// Manual composition is the methodology by which most nodes are implemented, involving a call argument and upstream inputs.
|
/// 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.
|
/// By contrast, automatic composition is an alternative way to handle the composition of nodes as they execute in the graph.
|
||||||
|
@ -552,7 +552,7 @@ pub struct OldDocumentNode {
|
||||||
///
|
///
|
||||||
/// In the root network, it is resolved when evaluating the borrow tree.
|
/// 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).
|
/// 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 inputs: Vec<NodeInput>,
|
||||||
pub manual_composition: Option<Type>,
|
pub manual_composition: Option<Type>,
|
||||||
// TODO: Remove once this references its definition instead (see above TODO).
|
// TODO: Remove once this references its definition instead (see above TODO).
|
||||||
|
@ -657,7 +657,7 @@ pub struct NodeNetwork {
|
||||||
/// The list of data outputs that are exported from this network to the parent network.
|
/// 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.
|
/// 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
|
// 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>,
|
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.
|
// 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>,
|
// pub import_types: Vec<Type>,
|
||||||
|
|
|
@ -186,13 +186,13 @@ tagged_value! {
|
||||||
// GRAPHICAL DATA TYPES
|
// GRAPHICAL DATA TYPES
|
||||||
// ====================
|
// ====================
|
||||||
GraphicElement(graphene_core::GraphicElement),
|
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),
|
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>),
|
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),
|
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),
|
ArtboardGroup(graphene_core::ArtboardGroupTable),
|
||||||
// ============
|
// ============
|
||||||
// STRUCT TYPES
|
// STRUCT TYPES
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
use dyn_any::StaticType;
|
use dyn_any::StaticType;
|
||||||
use graphene_application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
|
use graphene_application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use js_sys::{Object, Reflect};
|
use js_sys::{Object, Reflect};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use std::sync::atomic::AtomicU64;
|
use std::sync::atomic::AtomicU64;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use wasm_bindgen::JsValue;
|
use wasm_bindgen::JsValue;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use web_sys::HtmlCanvasElement;
|
use web_sys::HtmlCanvasElement;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use web_sys::window;
|
use web_sys::window;
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
use wgpu_executor::WgpuExecutor;
|
use wgpu_executor::WgpuExecutor;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct WindowWrapper {
|
struct WindowWrapper {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
window: SurfaceHandle<HtmlCanvasElement>,
|
window: SurfaceHandle<HtmlCanvasElement>,
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
window: SurfaceHandle<Arc<winit::window::Window>>,
|
window: SurfaceHandle<Arc<winit::window::Window>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
impl Drop for WindowWrapper {
|
impl Drop for WindowWrapper {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let window = window().expect("should have a window in this context");
|
let window = window().expect("should have a window in this context");
|
||||||
|
@ -52,14 +52,14 @@ impl Drop for WindowWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
unsafe impl Sync for WindowWrapper {}
|
unsafe impl Sync for WindowWrapper {}
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
unsafe impl Send for WindowWrapper {}
|
unsafe impl Send for WindowWrapper {}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct WasmApplicationIo {
|
pub struct WasmApplicationIo {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
ids: AtomicU64,
|
ids: AtomicU64,
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
pub(crate) gpu_executor: Option<WgpuExecutor>,
|
pub(crate) gpu_executor: Option<WgpuExecutor>,
|
||||||
|
@ -79,7 +79,7 @@ pub fn wgpu_available() -> Option<bool> {
|
||||||
|
|
||||||
impl WasmApplicationIo {
|
impl WasmApplicationIo {
|
||||||
pub async fn new() -> Self {
|
pub async fn new() -> Self {
|
||||||
#[cfg(all(feature = "wgpu", target_arch = "wasm32"))]
|
#[cfg(all(feature = "wgpu", target_family = "wasm"))]
|
||||||
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
|
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
|
||||||
let request_adapter = || {
|
let request_adapter = || {
|
||||||
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).ok()?;
|
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).ok()?;
|
||||||
|
@ -95,7 +95,7 @@ impl WasmApplicationIo {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(feature = "wgpu", not(target_arch = "wasm32")))]
|
#[cfg(all(feature = "wgpu", not(target_family = "wasm")))]
|
||||||
let executor = WgpuExecutor::new().await;
|
let executor = WgpuExecutor::new().await;
|
||||||
|
|
||||||
#[cfg(not(feature = "wgpu"))]
|
#[cfg(not(feature = "wgpu"))]
|
||||||
|
@ -105,7 +105,7 @@ impl WasmApplicationIo {
|
||||||
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
|
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
|
||||||
|
|
||||||
let mut io = Self {
|
let mut io = Self {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
ids: AtomicU64::new(0),
|
ids: AtomicU64::new(0),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
gpu_executor: executor,
|
gpu_executor: executor,
|
||||||
|
@ -130,7 +130,7 @@ impl WasmApplicationIo {
|
||||||
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
|
WGPU_AVAILABLE.store(wgpu_available as i8, Ordering::SeqCst);
|
||||||
|
|
||||||
let mut io = Self {
|
let mut io = Self {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
ids: AtomicU64::new(0),
|
ids: AtomicU64::new(0),
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
gpu_executor: executor,
|
gpu_executor: executor,
|
||||||
|
@ -142,7 +142,7 @@ impl WasmApplicationIo {
|
||||||
|
|
||||||
io
|
io
|
||||||
}
|
}
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "wgpu"))]
|
#[cfg(all(not(target_family = "wasm"), feature = "wgpu"))]
|
||||||
pub fn new_with_context(context: wgpu_executor::Context) -> Self {
|
pub fn new_with_context(context: wgpu_executor::Context) -> Self {
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
let executor = WgpuExecutor::with_context(context);
|
let executor = WgpuExecutor::with_context(context);
|
||||||
|
@ -184,16 +184,16 @@ impl<'a> From<&'a WasmApplicationIo> for &'a WgpuExecutor {
|
||||||
pub type WasmEditorApi = graphene_application_io::EditorApi<WasmApplicationIo>;
|
pub type WasmEditorApi = graphene_application_io::EditorApi<WasmApplicationIo>;
|
||||||
|
|
||||||
impl ApplicationIo for WasmApplicationIo {
|
impl ApplicationIo for WasmApplicationIo {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
type Surface = HtmlCanvasElement;
|
type Surface = HtmlCanvasElement;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
type Surface = Arc<winit::window::Window>;
|
type Surface = Arc<winit::window::Window>;
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
type Executor = WgpuExecutor;
|
type Executor = WgpuExecutor;
|
||||||
#[cfg(not(feature = "wgpu"))]
|
#[cfg(not(feature = "wgpu"))]
|
||||||
type Executor = ();
|
type Executor = ();
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
fn create_window(&self) -> SurfaceHandle<Self::Surface> {
|
fn create_window(&self) -> SurfaceHandle<Self::Surface> {
|
||||||
let wrapper = || {
|
let wrapper = || {
|
||||||
let document = window().expect("should have a window in this context").document().expect("window should have a document");
|
let document = window().expect("should have a window in this context").document().expect("window should have a document");
|
||||||
|
@ -228,7 +228,7 @@ impl ApplicationIo for WasmApplicationIo {
|
||||||
|
|
||||||
wrapper().expect("should be able to set canvas in global scope")
|
wrapper().expect("should be able to set canvas in global scope")
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
fn create_window(&self) -> SurfaceHandle<Self::Surface> {
|
fn create_window(&self) -> SurfaceHandle<Self::Surface> {
|
||||||
todo!("winit api changed, calling create_window on EventLoop is deprecated");
|
todo!("winit api changed, calling create_window on EventLoop is deprecated");
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ impl ApplicationIo for WasmApplicationIo {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
fn destroy_window(&self, surface_id: SurfaceId) {
|
fn destroy_window(&self, surface_id: SurfaceId) {
|
||||||
let window = window().expect("should have a window in this context");
|
let window = window().expect("should have a window in this context");
|
||||||
let window = Object::from(window);
|
let window = Object::from(window);
|
||||||
|
@ -277,7 +277,7 @@ impl ApplicationIo for WasmApplicationIo {
|
||||||
wrapper().expect("should be able to set canvas in global scope")
|
wrapper().expect("should be able to set canvas in global scope")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
fn destroy_window(&self, _surface_id: SurfaceId) {}
|
fn destroy_window(&self, _surface_id: SurfaceId) {}
|
||||||
|
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
|
@ -346,9 +346,9 @@ impl graphene_application_io::GetEditorPreferences for EditorPreferences {
|
||||||
impl Default for EditorPreferences {
|
impl Default for EditorPreferences {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use_vello: false,
|
use_vello: false,
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
use_vello: true,
|
use_vello: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ use graph_craft::document::value::RenderOutput;
|
||||||
pub use graph_craft::document::value::RenderOutputType;
|
pub use graph_craft::document::value::RenderOutputType;
|
||||||
pub use graph_craft::wasm_application_io::*;
|
pub use graph_craft::wasm_application_io::*;
|
||||||
use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig};
|
use graphene_application_io::{ApplicationIo, ExportFormat, RenderConfig};
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use graphene_core::instances::Instances;
|
use graphene_core::instances::Instances;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use graphene_core::math::bbox::Bbox;
|
use graphene_core::math::bbox::Bbox;
|
||||||
use graphene_core::raster::image::Image;
|
use graphene_core::raster::image::Image;
|
||||||
use graphene_core::raster_types::{CPU, Raster, RasterDataTable};
|
use graphene_core::raster_types::{CPU, Raster, RasterDataTable};
|
||||||
|
@ -14,14 +14,14 @@ use graphene_core::{Color, Context, Ctx, ExtractFootprint, GraphicGroupTable, Ow
|
||||||
use graphene_svg_renderer::RenderMetadata;
|
use graphene_svg_renderer::RenderMetadata;
|
||||||
use graphene_svg_renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
|
use graphene_svg_renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use glam::DAffine2;
|
use glam::DAffine2;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
||||||
|
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
|
@ -32,7 +32,7 @@ async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<W
|
||||||
|
|
||||||
#[node_macro::node(category("Web Request"))]
|
#[node_macro::node(category("Web Request"))]
|
||||||
async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, discard_result: bool) -> String {
|
async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, discard_result: bool) -> String {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
{
|
{
|
||||||
if discard_result {
|
if discard_result {
|
||||||
wasm_bindgen_futures::spawn_local(async move {
|
wasm_bindgen_futures::spawn_local(async move {
|
||||||
|
@ -41,7 +41,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc
|
||||||
return String::new();
|
return String::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
{
|
{
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
if discard_result {
|
if discard_result {
|
||||||
|
@ -62,7 +62,7 @@ async fn get_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, disc
|
||||||
|
|
||||||
#[node_macro::node(category("Web Request"))]
|
#[node_macro::node(category("Web Request"))]
|
||||||
async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, body: Vec<u8>, discard_result: bool) -> String {
|
async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, body: Vec<u8>, discard_result: bool) -> String {
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
{
|
{
|
||||||
if discard_result {
|
if discard_result {
|
||||||
wasm_bindgen_futures::spawn_local(async move {
|
wasm_bindgen_futures::spawn_local(async move {
|
||||||
|
@ -71,7 +71,7 @@ async fn post_request(_: impl Ctx, _primary: (), #[name("URL")] url: String, bod
|
||||||
return String::new();
|
return String::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
{
|
{
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
if discard_result {
|
if discard_result {
|
||||||
|
@ -165,7 +165,7 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "vello")]
|
#[cfg(feature = "vello")]
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
|
#[cfg_attr(not(target_family = "wasm"), allow(dead_code))]
|
||||||
async fn render_canvas(
|
async fn render_canvas(
|
||||||
render_config: RenderConfig,
|
render_config: RenderConfig,
|
||||||
data: impl GraphicElementRendered,
|
data: impl GraphicElementRendered,
|
||||||
|
@ -216,7 +216,7 @@ async fn render_canvas(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
async fn rasterize<T: WasmNotSend + 'n>(
|
async fn rasterize<T: WasmNotSend + 'n>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
|
@ -326,13 +326,13 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
|
||||||
let data = data.eval(ctx.clone()).await;
|
let data = data.eval(ctx.clone()).await;
|
||||||
let editor_api = editor_api.eval(None).await;
|
let editor_api = editor_api.eval(None).await;
|
||||||
|
|
||||||
#[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))]
|
#[cfg(all(feature = "vello", not(test), target_family = "wasm"))]
|
||||||
let _surface_handle = _surface_handle.eval(None).await;
|
let _surface_handle = _surface_handle.eval(None).await;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
let _surface_handle: Option<wgpu_executor::WgpuSurface> = None;
|
let _surface_handle: Option<wgpu_executor::WgpuSurface> = None;
|
||||||
|
|
||||||
let use_vello = editor_api.editor_preferences.use_vello();
|
let use_vello = editor_api.editor_preferences.use_vello();
|
||||||
#[cfg(all(feature = "vello", not(test), target_arch = "wasm32"))]
|
#[cfg(all(feature = "vello", not(test), target_family = "wasm"))]
|
||||||
let use_vello = use_vello && _surface_handle.is_some();
|
let use_vello = use_vello && _surface_handle.is_some();
|
||||||
|
|
||||||
let mut metadata = RenderMetadata::default();
|
let mut metadata = RenderMetadata::default();
|
||||||
|
|
|
@ -406,7 +406,7 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStre
|
||||||
|
|
||||||
#register_node_impl
|
#register_node_impl
|
||||||
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), ctor)]
|
#[cfg_attr(not(target_family = "wasm"), ctor)]
|
||||||
fn register_metadata() {
|
fn register_metadata() {
|
||||||
let metadata = NodeMetadata {
|
let metadata = NodeMetadata {
|
||||||
display_name: #display_name,
|
display_name: #display_name,
|
||||||
|
@ -618,7 +618,7 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), ctor)]
|
#[cfg_attr(not(target_family = "wasm"), ctor)]
|
||||||
fn register_node() {
|
fn register_node() {
|
||||||
let mut registry = NODE_REGISTRY.lock().unwrap();
|
let mut registry = NODE_REGISTRY.lock().unwrap();
|
||||||
registry.insert(
|
registry.insert(
|
||||||
|
@ -628,7 +628,7 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
extern "C" fn #registry_name() {
|
extern "C" fn #registry_name() {
|
||||||
register_node();
|
register_node();
|
||||||
|
|
|
@ -33,9 +33,9 @@ impl Context {
|
||||||
.request_device(&wgpu::DeviceDescriptor {
|
.request_device(&wgpu::DeviceDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
// #[cfg(not(feature = "passthrough"))]
|
// #[cfg(not(feature = "passthrough"))]
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
required_features: wgpu::Features::empty(),
|
required_features: wgpu::Features::empty(),
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
required_features: wgpu::Features::PUSH_CONSTANTS,
|
required_features: wgpu::Features::PUSH_CONSTANTS,
|
||||||
// Currently disabled because not all backend support passthrough.
|
// Currently disabled because not all backend support passthrough.
|
||||||
// TODO: reenable only when vulkan adapter is available
|
// TODO: reenable only when vulkan adapter is available
|
||||||
|
|
|
@ -46,9 +46,9 @@ pub struct TargetTexture {
|
||||||
size: UVec2,
|
size: UVec2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
pub type Window = web_sys::HtmlCanvasElement;
|
pub type Window = web_sys::HtmlCanvasElement;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
pub type Window = Arc<winit::window::Window>;
|
pub type Window = Arc<winit::window::Window>;
|
||||||
|
|
||||||
unsafe impl StaticType for Surface {
|
unsafe impl StaticType for Surface {
|
||||||
|
@ -186,12 +186,12 @@ impl WgpuExecutor {
|
||||||
Ok(texture)
|
Ok(texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_family = "wasm")]
|
||||||
pub fn create_surface(&self, canvas: graphene_application_io::WasmSurfaceHandle) -> Result<SurfaceHandle<Surface>> {
|
pub fn create_surface(&self, canvas: graphene_application_io::WasmSurfaceHandle) -> Result<SurfaceHandle<Surface>> {
|
||||||
let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas.surface))?;
|
let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas.surface))?;
|
||||||
self.create_surface_inner(surface, canvas.window_id)
|
self.create_surface_inner(surface, canvas.window_id)
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
pub fn create_surface(&self, window: SurfaceHandle<Window>) -> Result<SurfaceHandle<Surface>> {
|
pub fn create_surface(&self, window: SurfaceHandle<Window>) -> Result<SurfaceHandle<Surface>> {
|
||||||
let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Window(Box::new(window.surface)))?;
|
let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Window(Box::new(window.surface)))?;
|
||||||
self.create_surface_inner(surface, window.window_id)
|
self.create_surface_inner(surface, window.window_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue