Desktop: Move wrapper to separate crate (#3073)

Move desktop wrapper to separate crate
This commit is contained in:
Timon 2025-08-20 15:41:34 +00:00 committed by GitHub
parent 30e5d66105
commit 2c8913416d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 75 additions and 32 deletions

24
Cargo.lock generated
View File

@ -2083,10 +2083,7 @@ dependencies = [
"dirs",
"futures",
"glam",
"graph-craft",
"graphene-std",
"graphite-editor",
"image",
"graphite-desktop-wrapper",
"include_dir",
"open",
"rfd",
@ -2096,10 +2093,27 @@ dependencies = [
"tracing-subscriber",
"vello",
"wgpu",
"wgpu-executor",
"winit",
]
[[package]]
name = "graphite-desktop-wrapper"
version = "0.1.0"
dependencies = [
"dirs",
"futures",
"graph-craft",
"graphene-std",
"graphite-editor",
"image",
"ron",
"thiserror 2.0.12",
"tracing",
"vello",
"wgpu",
"wgpu-executor",
]
[[package]]
name = "graphite-editor"
version = "0.0.0"

View File

@ -2,6 +2,7 @@
members = [
"editor",
"desktop",
"desktop/wrapper",
"proc-macros",
"frontend/wasm",
"node-graph/gapplication-io",

View File

@ -10,18 +10,11 @@ rust-version = "1.87"
[features]
default = ["gpu"]
gpu = ["graphite-editor/gpu"]
gpu = ["graphite-desktop-wrapper/gpu"]
[dependencies]
# # Local dependencies
graphite-editor = { path = "../editor", features = [
"gpu",
"ron",
"vello",
] }
graphene-std = { workspace = true }
graph-craft = { workspace = true }
wgpu-executor = { workspace = true }
graphite-desktop-wrapper = { path = "wrapper" }
wgpu = { workspace = true }
winit = { workspace = true, features = ["serde"] }
@ -39,4 +32,3 @@ vello = { workspace = true }
derivative = { workspace = true }
rfd = { workspace = true }
open = { workspace = true }
image = { workspace = true }

View File

@ -1,13 +1,9 @@
use crate::CustomEvent;
use crate::WindowSize;
use crate::cef::WindowSize;
use crate::consts::APP_NAME;
use crate::desktop_wrapper::DesktopWrapper;
use crate::desktop_wrapper::NodeGraphExecutionResult;
use crate::desktop_wrapper::WgpuContext;
use crate::desktop_wrapper::messages::DesktopFrontendMessage;
use crate::desktop_wrapper::messages::DesktopWrapperMessage;
use crate::desktop_wrapper::serialize_frontend_messages;
use crate::render::GraphicsState;
use graphite_desktop_wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage};
use graphite_desktop_wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
use rfd::AsyncFileDialog;
use std::sync::Arc;
use std::sync::mpsc::Sender;

View File

@ -1,6 +1,6 @@
use crate::desktop_wrapper::WgpuContext;
use crate::CustomEvent;
use crate::render::FrameBufferRef;
use crate::{CustomEvent, desktop_wrapper::deserialize_editor_message};
use graphite_desktop_wrapper::{WgpuContext, deserialize_editor_message};
use std::sync::mpsc::Receiver;
use std::sync::{Arc, Mutex};
use std::time::Instant;

View File

@ -6,7 +6,7 @@ use winit::event_loop::EventLoop;
pub(crate) mod consts;
mod cef;
use cef::{Setup, WindowSize};
use cef::Setup;
mod render;
@ -15,9 +15,8 @@ use app::WinitApp;
mod dirs;
mod desktop_wrapper;
use desktop_wrapper::messages::DesktopWrapperMessage;
use desktop_wrapper::{DesktopWrapper, NodeGraphExecutionResult};
use graphite_desktop_wrapper::messages::DesktopWrapperMessage;
use graphite_desktop_wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext};
pub(crate) enum CustomEvent {
UiUpdate(wgpu::Texture),
@ -42,7 +41,7 @@ fn main() {
let (window_size_sender, window_size_receiver) = std::sync::mpsc::channel();
let wgpu_context = futures::executor::block_on(desktop_wrapper::WgpuContext::new()).unwrap();
let wgpu_context = futures::executor::block_on(WgpuContext::new()).unwrap();
let cef_context = match cef_context.init(cef::CefHandler::new(window_size_receiver, event_loop.create_proxy(), wgpu_context.clone())) {
Ok(c) => c,
Err(cef::InitError::AlreadyRunning) => {

View File

@ -1,9 +1,7 @@
use graphene_std::Color;
use std::sync::Arc;
use wgpu_executor::WgpuExecutor;
use winit::window::Window;
use crate::desktop_wrapper::WgpuContext;
use graphite_desktop_wrapper::{Color, WgpuContext, WgpuExecutor};
#[derive(derivative::Derivative)]
#[derivative(Debug)]

View File

@ -0,0 +1,33 @@
[package]
name = "graphite-desktop-wrapper"
version = "0.1.0"
description = "Graphite Desktop Wrapper"
authors = ["Graphite Authors <contact@graphite.rs>"]
license = "Apache-2.0"
repository = ""
edition = "2024"
rust-version = "1.87"
[features]
default = ["gpu"]
gpu = ["graphite-editor/gpu"]
[dependencies]
# Local dependencies
graphite-editor = { path = "../../editor", features = [
"gpu",
"ron",
"vello",
] }
graphene-std = { workspace = true }
graph-craft = { workspace = true }
wgpu-executor = { workspace = true }
wgpu = { workspace = true }
thiserror = { workspace = true }
futures = { workspace = true }
tracing = { workspace = true }
dirs = { workspace = true }
ron = { workspace = true}
vello = { workspace = true }
image = { workspace = true }

View File

@ -2,7 +2,11 @@ use graph_craft::wasm_application_io::WasmApplicationIo;
use graphite_editor::application::Editor;
use graphite_editor::messages::prelude::{FrontendMessage, Message};
// TODO: Remove usage of this reexport in desktop create and remove this line
pub use graphene_std::Color;
pub use wgpu_executor::Context as WgpuContext;
pub use wgpu_executor::WgpuExecutor;
pub mod messages;
use messages::{DesktopFrontendMessage, DesktopWrapperMessage};
@ -43,6 +47,12 @@ impl DesktopWrapper {
}
}
impl Default for DesktopWrapper {
fn default() -> Self {
Self::new()
}
}
pub enum NodeGraphExecutionResult {
HasRun(Option<wgpu::Texture>),
NotRun,