mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Instance tables refactor part 4: replace ArtboardGroups with multi-row Instances<Artboard> (#2265)
* Clean up dyn_any usages * Migrate ArtboardGroup to ArtboardGroupTable (not yet flattened) * Reorder graphical data imports * Flatten and remove ArtboardGroup in favor of ArtboardGroupTable * Fix test
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
use dyn_any::StaticType;
|
||||
pub use graph_craft::proto::{Any, NodeContainer, TypeErasedBox, TypeErasedNode};
|
||||
use graph_craft::proto::{DynFuture, FutureAny, SharedNodeContainer};
|
||||
pub use graphene_core::registry::{DowncastBothNode, DynAnyNode, FutureWrapperNode, PanicNode};
|
||||
use graphene_core::NodeIO;
|
||||
use graphene_core::WasmNotSend;
|
||||
pub use graphene_core::{generic, ops, Node};
|
||||
|
||||
use dyn_any::StaticType;
|
||||
|
||||
pub use graphene_core::registry::{DowncastBothNode, DynAnyNode, FutureWrapperNode, PanicNode};
|
||||
|
||||
pub trait IntoTypeErasedNode<'n> {
|
||||
fn into_type_erased(self) -> TypeErasedBox<'n>;
|
||||
}
|
||||
|
||||
@@ -90,8 +90,7 @@ fn brush_stamp_generator(diameter: f64, color: Color, hardness: f64, flow: f64)
|
||||
#[node_macro::node(skip_impl)]
|
||||
fn blit<P, BlendFn>(mut target: ImageFrameTable<P>, texture: Image<P>, positions: Vec<DVec2>, blend_mode: BlendFn) -> ImageFrameTable<P>
|
||||
where
|
||||
P: Pixel + Alpha + std::fmt::Debug + dyn_any::StaticType,
|
||||
P::Static: Pixel,
|
||||
P: Pixel + Alpha + std::fmt::Debug,
|
||||
BlendFn: for<'any_input> Node<'any_input, (P, P), Output = P>,
|
||||
GraphicElement: From<Image<P>>,
|
||||
{
|
||||
|
||||
@@ -14,8 +14,7 @@ use wgpu_executor::{Bindgroup, PipelineLayout, Shader, ShaderIO, ShaderInput, Wg
|
||||
use glam::{DAffine2, DVec2, Mat2, Vec2};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::wasm_application_io::WasmApplicationIo;
|
||||
|
||||
@@ -81,7 +80,7 @@ async fn map_gpu<'a: 'input>(image: ImageFrameTable<Color>, node: DocumentNode,
|
||||
let name = "placeholder".to_string();
|
||||
let Ok(compute_pass_descriptor) = create_compute_pass_descriptor(node, image_frame_table, executor).await else {
|
||||
log::error!("Error creating compute pass descriptor in 'map_gpu()");
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
};
|
||||
self.cache.lock().as_mut().unwrap().insert(name, compute_pass_descriptor.clone());
|
||||
log::error!("created compute pass");
|
||||
@@ -338,7 +337,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
||||
let proto_networks: Result<Vec<_>, _> = compiler.compile(network.clone()).collect();
|
||||
let Ok(proto_networks_result) = proto_networks else {
|
||||
log::error!("Error compiling network in 'blend_gpu_image()");
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
};
|
||||
let proto_networks = proto_networks_result;
|
||||
log::debug!("compiling shader");
|
||||
|
||||
@@ -47,7 +47,7 @@ fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: ImageFra
|
||||
|
||||
// If the image would not be visible, return an empty image
|
||||
if size.x <= 0. || size.y <= 0. {
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
}
|
||||
|
||||
let image_buffer = image::Rgba32FImage::from_raw(image.width, image.height, data).expect("Failed to convert internal image format into image-rs data type.");
|
||||
@@ -257,8 +257,7 @@ fn mask_image<
|
||||
#[node_macro::node(skip_impl)]
|
||||
async fn blend_image_tuple<_P, MapFn, _Fg>(images: (ImageFrameTable<_P>, _Fg), map_fn: &'n MapFn) -> ImageFrameTable<_P>
|
||||
where
|
||||
_P: Alpha + Pixel + Debug + Send + dyn_any::StaticType,
|
||||
_P::Static: Pixel,
|
||||
_P: Alpha + Pixel + Debug + Send,
|
||||
MapFn: for<'any_input> Node<'any_input, (_P, _P), Output = _P> + 'n + Clone,
|
||||
_Fg: Sample<Pixel = _P> + Transform + Clone + Send + 'n,
|
||||
GraphicElement: From<Image<_P>>,
|
||||
@@ -513,7 +512,7 @@ fn noise_pattern(
|
||||
|
||||
// If the image would not be visible, return an empty image
|
||||
if size.x <= 0. || size.y <= 0. {
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
}
|
||||
|
||||
let footprint_scale = footprint.scale();
|
||||
@@ -639,7 +638,7 @@ fn mandelbrot(ctx: impl ExtractFootprint + Send) -> ImageFrameTable<Color> {
|
||||
|
||||
// If the image would not be visible, return an empty image
|
||||
if size.x <= 0. || size.y <= 0. {
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
}
|
||||
|
||||
let scale = footprint.scale();
|
||||
|
||||
@@ -77,7 +77,7 @@ async fn load_resource<'a: 'n>(_: impl Ctx, _primary: (), #[scope("editor-api")]
|
||||
#[node_macro::node(category("Network"))]
|
||||
fn decode_image(_: impl Ctx, data: Arc<[u8]>) -> ImageFrameTable<Color> {
|
||||
let Some(image) = image::load_from_memory(data.as_ref()).ok() else {
|
||||
return ImageFrameTable::empty();
|
||||
return ImageFrameTable::one_empty_image();
|
||||
};
|
||||
let image = image.to_rgba32f();
|
||||
let image = Image {
|
||||
@@ -216,7 +216,7 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
|
||||
Context -> ImageFrameTable<Color>,
|
||||
Context -> GraphicGroupTable,
|
||||
Context -> graphene_core::Artboard,
|
||||
Context -> graphene_core::ArtboardGroup,
|
||||
Context -> graphene_core::ArtboardGroupTable,
|
||||
Context -> Option<Color>,
|
||||
Context -> Vec<Color>,
|
||||
Context -> bool,
|
||||
|
||||
Reference in New Issue
Block a user