mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-31 02:07:21 +00:00
Extract gapplication_io
from gcore
(#2742)
move `gcore::application_io` into the new crate `gapplication-io`, remove features `wasm` and `wgpu` from `gcore`
This commit is contained in:
parent
ae88f4a3de
commit
0e8eb481bf
18 changed files with 84 additions and 44 deletions
|
@ -4,6 +4,7 @@ use crate::wasm_application_io::WasmEditorApi;
|
|||
use dyn_any::DynAny;
|
||||
pub use dyn_any::StaticType;
|
||||
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
|
||||
use graphene_application_io::SurfaceFrame;
|
||||
use graphene_core::raster::brush_cache::BrushCache;
|
||||
use graphene_core::raster::{BlendMode, LuminanceCalculation};
|
||||
use graphene_core::raster_types::CPU;
|
||||
|
@ -30,7 +31,7 @@ macro_rules! tagged_value {
|
|||
None,
|
||||
$( $(#[$meta] ) *$identifier( $ty ), )*
|
||||
RenderOutput(RenderOutput),
|
||||
SurfaceFrame(graphene_core::SurfaceFrame),
|
||||
SurfaceFrame(SurfaceFrame),
|
||||
#[serde(skip)]
|
||||
EditorApi(Arc<WasmEditorApi>)
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ macro_rules! tagged_value {
|
|||
Self::None => concrete!(()),
|
||||
$( Self::$identifier(_) => concrete!($ty), )*
|
||||
Self::RenderOutput(_) => concrete!(RenderOutput),
|
||||
Self::SurfaceFrame(_) => concrete!(graphene_core::SurfaceFrame),
|
||||
Self::SurfaceFrame(_) => concrete!(SurfaceFrame),
|
||||
Self::EditorApi(_) => concrete!(&WasmEditorApi)
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ macro_rules! tagged_value {
|
|||
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
|
||||
$( x if x == TypeId::of::<$ty>() => Ok(TaggedValue::$identifier(*downcast(input).unwrap())), )*
|
||||
x if x == TypeId::of::<RenderOutput>() => Ok(TaggedValue::RenderOutput(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<graphene_core::SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(*downcast(input).unwrap())),
|
||||
|
||||
|
||||
_ => Err(format!("Cannot convert {:?} to TaggedValue", DynAny::type_name(input.as_ref()))),
|
||||
|
@ -103,7 +104,7 @@ macro_rules! tagged_value {
|
|||
x if x == TypeId::of::<()>() => Ok(TaggedValue::None),
|
||||
$( x if x == TypeId::of::<$ty>() => Ok(TaggedValue::$identifier(<$ty as Clone>::clone(input.downcast_ref().unwrap()))), )*
|
||||
x if x == TypeId::of::<RenderOutput>() => Ok(TaggedValue::RenderOutput(RenderOutput::clone(input.downcast_ref().unwrap()))),
|
||||
x if x == TypeId::of::<graphene_core::SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(graphene_core::SurfaceFrame::clone(input.downcast_ref().unwrap()))),
|
||||
x if x == TypeId::of::<SurfaceFrame>() => Ok(TaggedValue::SurfaceFrame(SurfaceFrame::clone(input.downcast_ref().unwrap()))),
|
||||
_ => Err(format!("Cannot convert {:?} to TaggedValue",std::any::type_name_of_val(input))),
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +431,7 @@ pub struct RenderOutput {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, dyn_any::DynAny, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub enum RenderOutputType {
|
||||
CanvasFrame(graphene_core::SurfaceFrame),
|
||||
CanvasFrame(SurfaceFrame),
|
||||
Svg(String),
|
||||
Image(Vec<u8>),
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use dyn_any::StaticType;
|
||||
use graphene_core::application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
|
||||
use graphene_application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use js_sys::{Object, Reflect};
|
||||
use std::collections::HashMap;
|
||||
|
@ -168,7 +168,7 @@ impl<'a> From<&'a WasmApplicationIo> for &'a WgpuExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
pub type WasmEditorApi = graphene_core::application_io::EditorApi<WasmApplicationIo>;
|
||||
pub type WasmEditorApi = graphene_application_io::EditorApi<WasmApplicationIo>;
|
||||
|
||||
impl ApplicationIo for WasmApplicationIo {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
@ -208,7 +208,7 @@ impl ApplicationIo for WasmApplicationIo {
|
|||
// Use Reflect API to set property
|
||||
Reflect::set(&canvases, &js_key, &js_value)?;
|
||||
Ok::<_, JsValue>(SurfaceHandle {
|
||||
window_id: graphene_core::SurfaceId(id),
|
||||
window_id: SurfaceId(id),
|
||||
surface: canvas,
|
||||
})
|
||||
};
|
||||
|
@ -313,7 +313,7 @@ impl ApplicationIo for WasmApplicationIo {
|
|||
#[cfg(feature = "wgpu")]
|
||||
pub type WasmSurfaceHandle = SurfaceHandle<wgpu_executor::Window>;
|
||||
#[cfg(feature = "wgpu")]
|
||||
pub type WasmSurfaceHandleFrame = graphene_core::application_io::SurfaceHandleFrame<wgpu_executor::Window>;
|
||||
pub type WasmSurfaceHandleFrame = graphene_application_io::SurfaceHandleFrame<wgpu_executor::Window>;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, specta::Type, serde::Serialize, serde::Deserialize)]
|
||||
pub struct EditorPreferences {
|
||||
|
@ -321,7 +321,7 @@ pub struct EditorPreferences {
|
|||
pub use_vello: bool,
|
||||
}
|
||||
|
||||
impl graphene_core::application_io::GetEditorPreferences for EditorPreferences {
|
||||
impl graphene_application_io::GetEditorPreferences for EditorPreferences {
|
||||
// fn hostname(&self) -> &str {
|
||||
// &self.imaginate_hostname
|
||||
// }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue