mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 02:28:11 +08:00
Define data types for ID-based resource handling (#4168)
* Add resource lib * rename ResourceSource to ResourceInput * Rename ResourceInput -> DataSource and improve API * Review --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::dispatcher::Dispatcher;
|
||||
use crate::messages::prelude::*;
|
||||
use graph_craft::application_io::{PlatformApplicationIo, ResourceStorage};
|
||||
use graph_craft::application_io::PlatformApplicationIo;
|
||||
use graph_craft::application_io::resource::ResourceStorage;
|
||||
pub use graphene_std::uuid::*;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::messages::portfolio::utility_types::PanelType;
|
||||
use crate::messages::preferences::preferences_message_handler::PreferencesMessageContext;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::messages::tool::common_functionality::utility_functions::make_path_editable_is_allowed;
|
||||
use graph_craft::application_io::ResourceStorage;
|
||||
use graph_craft::application_io::resource::ResourceStorage;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Dispatcher {
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use graph_craft::application_io::ResourceHash;
|
||||
use graph_craft::application_io::resource::ResourceHash;
|
||||
|
||||
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
use crate::messages::portfolio::utility_types::WorkspacePanelLayout;
|
||||
|
||||
@@ -30,7 +30,8 @@ use crate::messages::tool::tool_messages::tool_prelude::Key;
|
||||
use crate::messages::tool::utility_types::ToolType;
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
use glam::{DAffine2, DVec2};
|
||||
use graph_craft::application_io::{ResourceHash, wgpu_available};
|
||||
use graph_craft::application_io::resource::ResourceHash;
|
||||
use graph_craft::application_io::wgpu_available;
|
||||
use graph_craft::descriptor;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
||||
|
||||
@@ -300,7 +300,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
.default_node_template();
|
||||
|
||||
let png_bytes: std::sync::Arc<[u8]> = image.to_png().into();
|
||||
let hash = graphene_std::application_io::ResourceHash::from(png_bytes.as_ref());
|
||||
let hash = graphene_std::application_io::resource::ResourceHash::from(png_bytes.as_ref());
|
||||
self.responses.add(ResourceMessage::Store { data: png_bytes });
|
||||
|
||||
let image_node = resolve_proto_node_type(graphene_std::raster_nodes::std_nodes::image::IDENTIFIER)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose::STANDARD as BASE64;
|
||||
use graph_craft::application_io::{Resource, ResourceHash};
|
||||
use graph_craft::application_io::resource::{Resource, ResourceHash};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::messages::tool::tool_messages::tool_prelude::NumberInputMode;
|
||||
use deserialization::deserialize_node_persistent_metadata;
|
||||
use glam::{DAffine2, DVec2, IVec2};
|
||||
use graph_craft::Type;
|
||||
use graph_craft::application_io::ResourceHash;
|
||||
use graph_craft::application_io::resource::ResourceHash;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, OldDocumentNodeImplementation, OldNodeNetwork};
|
||||
use graphene_std::ContextDependencies;
|
||||
|
||||
@@ -1597,7 +1597,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
|
||||
});
|
||||
|
||||
if let Some(image) = image {
|
||||
let hash = document.embedded_resources.store(graphene_std::application_io::Resource::new(image.to_png()));
|
||||
let hash = document.embedded_resources.store(graphene_std::application_io::resource::Resource::new(image.to_png()));
|
||||
|
||||
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
|
||||
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::messages::tool::utility_types::{HintData, ToolType};
|
||||
use crate::messages::viewport::ToPhysical;
|
||||
use crate::node_graph_executor::{ExportConfig, NodeGraphExecutor};
|
||||
use glam::{DAffine2, DVec2};
|
||||
use graph_craft::application_io::ResourceHash;
|
||||
use graph_craft::application_io::resource::ResourceHash;
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_std::Color;
|
||||
use graphene_std::raster_types::Image;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::messages::prelude::*;
|
||||
use graph_craft::application_io::ResourceHash;
|
||||
use graph_craft::application_io::resource::ResourceHash;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[impl_message(Message, Resource)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::messages::prelude::*;
|
||||
use graph_craft::application_io::{LoadResource, ResourceFuture, ResourceHash, ResourceStorage};
|
||||
use graph_craft::application_io::resource::{LoadResource, ResourceFuture, ResourceHash, ResourceStorage};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -48,7 +48,7 @@ impl Default for ResourceMessageHandler {
|
||||
#[cfg(test)]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
storage: Some(Arc::new(RwLock::new(Box::new(graph_craft::application_io::HashMapResourceStorage::new())))),
|
||||
storage: Some(Arc::new(RwLock::new(Box::new(graph_craft::application_io::resource::HashMapResourceStorage::new())))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user