mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Remove all references to legacy layers (#1523)
* Remove visible field from LegacyLayer * Remove LegacyLayer wrapper around LegacyLayerType * Remove FolderLegacyLayer and LayerLegacyLayer wrappers around their data * Remove legacy layers
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
use fern::colors::{Color, ColoredLevelConfig};
|
||||
use std::{error::Error, sync::Arc};
|
||||
|
||||
use document_legacy::{document::Document, layers::layer_info::LegacyLayerType};
|
||||
use futures::executor::block_on;
|
||||
use graph_craft::{
|
||||
concrete,
|
||||
document::*,
|
||||
graphene_compiler::{Compiler, Executor},
|
||||
imaginate_input::ImaginatePreferences,
|
||||
ProtoNodeIdentifier,
|
||||
};
|
||||
use graphene_core::{
|
||||
application_io::{ApplicationIo, NodeGraphUpdateSender},
|
||||
text::FontCache,
|
||||
};
|
||||
use graph_craft::document::*;
|
||||
use graph_craft::graphene_compiler::Executor;
|
||||
use graph_craft::imaginate_input::ImaginatePreferences;
|
||||
use graph_craft::{concrete, ProtoNodeIdentifier};
|
||||
use graphene_core::application_io::{ApplicationIo, NodeGraphUpdateSender};
|
||||
use graphene_core::text::FontCache;
|
||||
use graphene_std::wasm_application_io::{WasmApplicationIo, WasmEditorApi};
|
||||
use interpreted_executor::dynamic_executor::DynamicExecutor;
|
||||
|
||||
use fern::colors::{Color, ColoredLevelConfig};
|
||||
use futures::executor::block_on;
|
||||
use std::{error::Error, sync::Arc};
|
||||
|
||||
struct UpdateLogger {}
|
||||
|
||||
impl NodeGraphUpdateSender for UpdateLogger {
|
||||
@@ -85,18 +79,17 @@ fn init_logging() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn create_executor(document_string: String) -> Result<DynamicExecutor, Box<dyn Error>> {
|
||||
let document: serde_json::Value = serde_json::from_str(&document_string).expect("Failed to parse document");
|
||||
let document = serde_json::from_value::<Document>(document["document_legacy"].clone()).expect("Failed to parse document");
|
||||
let Some(LegacyLayerType::Layer(ref node_graph)) = document.root.iter().find(|layer| matches!(layer.data, LegacyLayerType::Layer(_))).map(|x| &x.data) else {
|
||||
panic!("Failed to extract node graph from document")
|
||||
};
|
||||
let network = &node_graph.network;
|
||||
let wrapped_network = wrap_network_in_scope(network.clone());
|
||||
let compiler = Compiler {};
|
||||
let protograph = compiler.compile_single(wrapped_network)?;
|
||||
let executor = block_on(DynamicExecutor::new(protograph))?;
|
||||
Ok(executor)
|
||||
fn create_executor(_document_string: String) -> Result<DynamicExecutor, Box<dyn Error>> {
|
||||
// let document: serde_json::Value = serde_json::from_str(&document_string).expect("Failed to parse document");
|
||||
// let document = serde_json::from_value::<Document>(document["document_legacy"].clone()).expect("Failed to parse document");
|
||||
// let Some(LegacyLayerType::Layer(ref network)) = document.root.iter().find(|layer| matches!(layer, LegacyLayerType::Layer(_))) else {
|
||||
panic!("Failed to extract node graph from document")
|
||||
// };
|
||||
// let wrapped_network = wrap_network_in_scope(network.clone());
|
||||
// let compiler = Compiler {};
|
||||
// let protograph = compiler.compile_single(wrapped_network)?;
|
||||
// let executor = block_on(DynamicExecutor::new(protograph))?;
|
||||
// Ok(executor)
|
||||
}
|
||||
|
||||
pub fn wrap_network_in_scope(mut network: NodeNetwork) -> NodeNetwork {
|
||||
@@ -193,41 +186,41 @@ fn begin_scope() -> DocumentNode {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
// #[cfg(test)]
|
||||
// mod test {
|
||||
// use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg_attr(not(feature = "wayland"), ignore)]
|
||||
async fn grays_scale() {
|
||||
let document_string = include_str!("../test_files/gray.graphite");
|
||||
let executor = create_executor(document_string.to_string()).unwrap();
|
||||
let editor_api = WasmEditorApi {
|
||||
image_frame: None,
|
||||
font_cache: &FontCache::default(),
|
||||
application_io: &block_on(WasmApplicationIo::new()),
|
||||
node_graph_message_sender: &UpdateLogger {},
|
||||
imaginate_preferences: &ImaginatePreferences::default(),
|
||||
render_config: graphene_core::application_io::RenderConfig::default(),
|
||||
};
|
||||
let result = (&executor).execute(editor_api.clone()).await.unwrap();
|
||||
println!("result: {result:?}");
|
||||
}
|
||||
// #[tokio::test]
|
||||
// #[cfg_attr(not(feature = "wayland"), ignore)]
|
||||
// async fn grays_scale() {
|
||||
// let document_string = include_str!("../test_files/gray.graphite");
|
||||
// let executor = create_executor(document_string.to_string()).unwrap();
|
||||
// let editor_api = WasmEditorApi {
|
||||
// image_frame: None,
|
||||
// font_cache: &FontCache::default(),
|
||||
// application_io: &block_on(WasmApplicationIo::new()),
|
||||
// node_graph_message_sender: &UpdateLogger {},
|
||||
// imaginate_preferences: &ImaginatePreferences::default(),
|
||||
// render_config: graphene_core::application_io::RenderConfig::default(),
|
||||
// };
|
||||
// let result = (&executor).execute(editor_api.clone()).await.unwrap();
|
||||
// println!("result: {result:?}");
|
||||
// }
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg_attr(not(feature = "wayland"), ignore)]
|
||||
async fn hue() {
|
||||
let document_string = include_str!("../test_files/hue.graphite");
|
||||
let executor = create_executor(document_string.to_string()).unwrap();
|
||||
let editor_api = WasmEditorApi {
|
||||
image_frame: None,
|
||||
font_cache: &FontCache::default(),
|
||||
application_io: &block_on(WasmApplicationIo::new()),
|
||||
node_graph_message_sender: &UpdateLogger {},
|
||||
imaginate_preferences: &ImaginatePreferences::default(),
|
||||
render_config: graphene_core::application_io::RenderConfig::default(),
|
||||
};
|
||||
let result = (&executor).execute(editor_api.clone()).await.unwrap();
|
||||
println!("result: {result:?}");
|
||||
}
|
||||
}
|
||||
// #[tokio::test]
|
||||
// #[cfg_attr(not(feature = "wayland"), ignore)]
|
||||
// async fn hue() {
|
||||
// let document_string = include_str!("../test_files/hue.graphite");
|
||||
// let executor = create_executor(document_string.to_string()).unwrap();
|
||||
// let editor_api = WasmEditorApi {
|
||||
// image_frame: None,
|
||||
// font_cache: &FontCache::default(),
|
||||
// application_io: &block_on(WasmApplicationIo::new()),
|
||||
// node_graph_message_sender: &UpdateLogger {},
|
||||
// imaginate_preferences: &ImaginatePreferences::default(),
|
||||
// render_config: graphene_core::application_io::RenderConfig::default(),
|
||||
// };
|
||||
// let result = (&executor).execute(editor_api.clone()).await.unwrap();
|
||||
// println!("result: {result:?}");
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user