Upgrade to the Rust 2024 edition (#2367)

* Update to rust 2024 edition

* Fixes

* Clean up imports

* Cargo fmt again

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2025-03-13 01:29:12 +01:00
committed by GitHub
parent 927d7dd9b2
commit beb1c6ae64
253 changed files with 980 additions and 1371 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "compilation-client"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[dependencies]

View File

@@ -1,5 +1,6 @@
use gpu_compiler_bin_wrapper::CompileRequest;
use graph_craft::{proto::ProtoNetwork, Type};
use graph_craft::Type;
use graph_craft::proto::ProtoNetwork;
use wgpu_executor::ShaderIO;
pub async fn compile(networks: Vec<ProtoNetwork>, inputs: Vec<Type>, outputs: Vec<Type>, io: ShaderIO) -> Result<Shader, reqwest::Error> {

View File

@@ -2,11 +2,10 @@ use gpu_compiler_bin_wrapper::CompileRequest;
use graph_craft::concrete;
use graph_craft::document::value::TaggedValue;
use graph_craft::document::*;
use graphene_core::raster::adjustments::BlendMode;
use graphene_core::Color;
use wgpu_executor::{ShaderIO, ShaderInput};
use graphene_core::raster::adjustments::BlendMode;
use std::time::Duration;
use wgpu_executor::{ShaderIO, ShaderInput};
fn main() {
let client = reqwest::blocking::Client::new();

View File

@@ -1,7 +1,7 @@
[package]
name = "compilation-server"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[dependencies]

View File

@@ -1,15 +1,13 @@
use std::{collections::HashMap, sync::Arc, sync::RwLock};
use axum::Router;
use axum::extract::{Json, State};
use axum::http::StatusCode;
use axum::routing::{get, post};
use gpu_compiler_bin_wrapper::CompileRequest;
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::RwLock;
use tower_http::cors::CorsLayer;
use axum::{
extract::{Json, State},
http::StatusCode,
routing::{get, post},
Router,
};
struct AppState {
compile_dir: tempfile::TempDir,
cache: RwLock<HashMap<CompileRequest, Result<Vec<u8>, StatusCode>>>,

View File

@@ -1,7 +1,7 @@
[package]
name = "graphene-core"
version = "0.1.0"
edition = "2021"
edition = "2024"
description = "API definitions for Graphene"
authors = ["Graphite Authors <contact@graphite.rs>"]
license = "MIT OR Apache-2.0"

View File

@@ -2,15 +2,13 @@ use crate::instances::Instances;
use crate::text::FontCache;
use crate::transform::{Footprint, Transform, TransformMut};
use crate::vector::style::ViewMode;
use dyn_any::{DynAny, StaticType, StaticTypeSized};
use alloc::sync::Arc;
use core::fmt::Debug;
use core::future::Future;
use core::hash::{Hash, Hasher};
use core::pin::Pin;
use core::ptr::addr_of;
use dyn_any::{DynAny, StaticType, StaticTypeSized};
use glam::{DAffine2, UVec2};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

View File

@@ -1,6 +1,7 @@
use crate::transform::Footprint;
use core::{any::Any, borrow::Borrow, panic::Location};
use core::any::Any;
use core::borrow::Borrow;
use core::panic::Location;
use std::sync::Arc;
pub trait Ctx: Clone + Send {}
@@ -87,12 +88,12 @@ impl<T: ExtractIndex> ExtractIndex for Option<T> {
}
impl<T: ExtractVarArgs + Sync> ExtractVarArgs for Option<T> {
fn vararg(&self, index: usize) -> Result<DynRef<'_>, VarArgsResult> {
let Some(ref inner) = self else { return Err(VarArgsResult::NoVarArgs) };
let Some(inner) = self else { return Err(VarArgsResult::NoVarArgs) };
inner.vararg(index)
}
fn varargs_len(&self) -> Result<usize, VarArgsResult> {
let Some(ref inner) = self else { return Err(VarArgsResult::NoVarArgs) };
let Some(inner) = self else { return Err(VarArgsResult::NoVarArgs) };
inner.varargs_len()
}
}

View File

@@ -1,6 +1,5 @@
use core::marker::PhantomData;
use crate::Node;
use core::marker::PhantomData;
#[derive(Clone)]
pub struct FnNode<T: Fn(I) -> O, I, O>(T, PhantomData<(I, O)>);

View File

@@ -1,5 +1,5 @@
use crate::{raster::Sample, Color};
use crate::Color;
use crate::raster::Sample;
use bytemuck::{Pod, Zeroable};
use spirv_std::image::{Image2d, SampledImage};

View File

@@ -1,14 +1,12 @@
use crate::application_io::{ImageTexture, TextureFrameTable};
use crate::instances::Instances;
use crate::raster::image::{Image, ImageFrameTable};
use crate::raster::BlendMode;
use crate::raster::image::{Image, ImageFrameTable};
use crate::transform::TransformMut;
use crate::uuid::NodeId;
use crate::vector::{VectorData, VectorDataTable};
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl};
use dyn_any::DynAny;
use glam::{DAffine2, IVec2};
use std::hash::Hash;

View File

@@ -1,22 +1,20 @@
mod quad;
mod rect;
pub use quad::Quad;
pub use rect::Rect;
use crate::raster::image::ImageFrameTable;
use crate::raster::{BlendMode, Image};
use crate::transform::{Footprint, Transform};
use crate::uuid::{generate_uuid, NodeId};
use crate::uuid::{NodeId, generate_uuid};
use crate::vector::style::{Fill, Stroke, ViewMode};
use crate::vector::{PointId, VectorDataTable};
use crate::{Artboard, ArtboardGroupTable, Color, GraphicElement, GraphicGroupTable, RasterFrame};
use base64::Engine;
use bezier_rs::Subpath;
use dyn_any::DynAny;
use base64::Engine;
use glam::{DAffine2, DMat2, DVec2};
use num_traits::Zero;
pub use quad::Quad;
pub use rect::Rect;
use std::collections::{HashMap, HashSet};
use std::fmt::Write;
#[cfg(feature = "vello")]
@@ -883,7 +881,7 @@ impl GraphicElementRendered for ImageFrameTable<Color> {
impl GraphicElementRendered for RasterFrame {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
match self {
RasterFrame::ImageFrame(ref image) => image.render_svg(render, render_params),
RasterFrame::ImageFrame(image) => image.render_svg(render, render_params),
RasterFrame::TextureFrame(_) => unimplemented!(),
}
}

View File

@@ -1,6 +1,5 @@
use glam::{DAffine2, DVec2};
use super::Quad;
use glam::{DAffine2, DVec2};
#[derive(Debug, Clone, Default, Copy, PartialEq)]
/// An axis aligned rect defined by two vertices.

View File

@@ -1,13 +1,11 @@
use crate::application_io::TextureFrameTable;
use crate::raster::image::{Image, ImageFrameTable};
use crate::raster::Pixel;
use crate::raster::image::{Image, ImageFrameTable};
use crate::transform::{Transform, TransformMut};
use crate::uuid::NodeId;
use crate::vector::{InstanceId, VectorDataTable};
use crate::{AlphaBlending, GraphicElement, RasterFrame};
use dyn_any::StaticType;
use glam::DAffine2;
use std::hash::Hash;

View File

@@ -1,6 +1,6 @@
use crate::vector::VectorDataTable;
use crate::Context;
use crate::Ctx;
use crate::vector::VectorDataTable;
use glam::{DAffine2, DVec2};
#[node_macro::node(category("Debug"))]

View File

@@ -1,11 +1,9 @@
use crate::{Node, WasmNotSend};
use dyn_any::DynFuture;
#[cfg(feature = "alloc")]
use alloc::sync::Arc;
use core::future::Future;
use core::ops::Deref;
use dyn_any::DynFuture;
use std::hash::DefaultHasher;
use std::sync::Mutex;

View File

@@ -1,17 +1,15 @@
use crate::raster::image::ImageFrameTable;
use crate::Ctx;
use crate::raster::BlendMode;
use crate::raster::image::ImageFrameTable;
use crate::registry::types::Percentage;
use crate::vector::style::GradientStops;
use crate::Ctx;
use crate::{Color, Node};
use math_parser::ast;
use math_parser::context::{EvalContext, NothingMap, ValueProvider};
use math_parser::value::{Number, Value};
use core::marker::PhantomData;
use core::ops::{Add, Div, Mul, Rem, Sub};
use glam::DVec2;
use math_parser::ast;
use math_parser::context::{EvalContext, NothingMap, ValueProvider};
use math_parser::value::{Number, Value};
use num_traits::Pow;
use rand::{Rng, SeedableRng};
@@ -136,11 +134,7 @@ fn modulo<U: Rem<T, Output: Add<T, Output: Rem<T, Output = U::Output>>>, T: Copy
modulus: T,
always_positive: bool,
) -> <U as Rem<T>>::Output {
if always_positive {
(numerator % modulus + modulus) % modulus
} else {
numerator % modulus
}
if always_positive { (numerator % modulus + modulus) % modulus } else { numerator % modulus }
}
/// The exponent operation (^) calculates the result of raising a number to a power.
@@ -198,61 +192,37 @@ fn logarithm<U: num_traits::float::Float>(
/// The sine trigonometric function (sin) calculates the ratio of the angle's opposite side length to its hypotenuse length.
#[node_macro::node(category("Math: Trig"))]
fn sine<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
if radians {
theta.sin()
} else {
theta.to_radians().sin()
}
if radians { theta.sin() } else { theta.to_radians().sin() }
}
/// The cosine trigonometric function (cos) calculates the ratio of the angle's adjacent side length to its hypotenuse length.
#[node_macro::node(category("Math: Trig"))]
fn cosine<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
if radians {
theta.cos()
} else {
theta.to_radians().cos()
}
if radians { theta.cos() } else { theta.to_radians().cos() }
}
/// The tangent trigonometric function (tan) calculates the ratio of the angle's opposite side length to its adjacent side length.
#[node_macro::node(category("Math: Trig"))]
fn tangent<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] theta: U, radians: bool) -> U {
if radians {
theta.tan()
} else {
theta.to_radians().tan()
}
if radians { theta.tan() } else { theta.to_radians().tan() }
}
/// The inverse sine trigonometric function (asin) calculates the angle whose sine is the specified value.
#[node_macro::node(category("Math: Trig"))]
fn sine_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
if radians {
value.asin()
} else {
value.asin().to_degrees()
}
if radians { value.asin() } else { value.asin().to_degrees() }
}
/// The inverse cosine trigonometric function (acos) calculates the angle whose cosine is the specified value.
#[node_macro::node(category("Math: Trig"))]
fn cosine_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
if radians {
value.acos()
} else {
value.acos().to_degrees()
}
if radians { value.acos() } else { value.acos().to_degrees() }
}
/// The inverse tangent trigonometric function (atan) calculates the angle whose tangent is the specified value.
#[node_macro::node(category("Math: Trig"))]
fn tangent_inverse<U: num_traits::float::Float>(_: impl Ctx, #[implementations(f64, f32)] value: U, radians: bool) -> U {
if radians {
value.atan()
} else {
value.atan().to_degrees()
}
if radians { value.atan() } else { value.atan().to_degrees() }
}
/// The inverse tangent trigonometric function (atan2) calculates the angle whose tangent is the ratio of the two specified values.
@@ -265,11 +235,7 @@ fn tangent_inverse_2_argument<U: num_traits::float::Float>(
x: U,
radians: bool,
) -> U {
if radians {
y.atan2(x)
} else {
y.atan2(x).to_degrees()
}
if radians { y.atan2(x) } else { y.atan2(x).to_degrees() }
}
/// The random function (rand) converts a seed into a random number within the specified range, inclusive of the minimum and exclusive of the maximum. The minimum and maximum values are automatically swapped if they are reversed.

View File

@@ -1,10 +1,9 @@
pub use self::color::{Color, Luma, SRGBA8};
use crate::Ctx;
use crate::GraphicGroupTable;
use crate::raster::image::ImageFrameTable;
use crate::registry::types::Percentage;
use crate::vector::VectorDataTable;
use crate::Ctx;
use crate::GraphicGroupTable;
use bytemuck::{Pod, Zeroable};
use core::fmt::Debug;
use glam::DVec2;
@@ -22,6 +21,7 @@ pub mod color;
#[cfg(not(target_arch = "spirv"))]
pub mod curve;
pub mod discrete_srgb;
pub use adjustments::*;
pub trait Linear {
@@ -95,11 +95,7 @@ impl Channel for SRGBGammaFloat {
#[inline(always)]
fn from_linear<In: Linear>(linear: In) -> Self {
let x = linear.to_f32();
if x <= 0.0031308 {
Self(x * 12.92)
} else {
Self(1.055 * x.powf(1. / 2.4) - 0.055)
}
if x <= 0.0031308 { Self(x * 12.92) } else { Self(1.055 * x.powf(1. / 2.4) - 0.055) }
}
}
pub trait RGBPrimaries {

View File

@@ -6,15 +6,13 @@ use crate::raster::curve::{Curve, CurveManipulatorGroup, ValueMapperNode};
use crate::raster::image::{Image, ImageFrameTable};
use crate::raster::{Channel, Color, Pixel};
use crate::registry::types::{Angle, Percentage, SignedPercentage};
use crate::vector::style::GradientStops;
use crate::vector::VectorDataTable;
use crate::vector::style::GradientStops;
use crate::{Ctx, Node};
use crate::{GraphicElement, GraphicGroupTable};
use dyn_any::DynAny;
use core::cmp::Ordering;
use core::fmt::Debug;
use dyn_any::DynAny;
#[cfg(feature = "serde")]
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::float::Float;
@@ -574,11 +572,7 @@ async fn threshold<T: Adjust<Color>>(
LuminanceCalculation::MaximumChannels => color.maximum_rgb_channels(),
};
if luminance >= min_luminance && luminance <= max_luminance {
Color::WHITE
} else {
Color::BLACK
}
if luminance >= min_luminance && luminance <= max_luminance { Color::WHITE } else { Color::BLACK }
});
image
}
@@ -720,7 +714,7 @@ impl Adjust<Color> for Color {
}
impl Adjust<Color> for Option<Color> {
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
if let Some(ref mut v) = self {
if let Some(v) = self {
*v = map_fn(v)
}
}

View File

@@ -1,5 +1,4 @@
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
#[cfg_attr(not(target_arch = "spirv"), derive(Debug))]

View File

@@ -1,12 +1,10 @@
use crate::Color;
use crate::graphene_core::raster::image::ImageFrameTable;
use crate::raster::Image;
use crate::vector::brush_stroke::BrushStroke;
use crate::vector::brush_stroke::BrushStyle;
use crate::Color;
use dyn_any::DynAny;
use core::hash::Hash;
use dyn_any::DynAny;
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::Mutex;

View File

@@ -1,16 +1,14 @@
use super::discrete_srgb::{float_to_srgb_u8, srgb_u8_to_float};
use super::{Alpha, AlphaMut, AssociatedAlpha, Luminance, LuminanceMut, Pixel, RGBMut, Rec709Primaries, RGB, SRGB};
use super::{Alpha, AlphaMut, AssociatedAlpha, Luminance, LuminanceMut, Pixel, RGB, RGBMut, Rec709Primaries, SRGB};
use bytemuck::{Pod, Zeroable};
use core::hash::Hash;
use dyn_any::DynAny;
use half::f16;
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::Euclid;
#[cfg(feature = "serde")]
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::float::Float;
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::Euclid;
use bytemuck::{Pod, Zeroable};
use core::hash::Hash;
use half::f16;
use std::fmt::Write;
#[repr(C)]
@@ -663,11 +661,7 @@ impl Color {
#[inline(always)]
pub fn blend_darker_color(&self, other: Color) -> Color {
if self.average_rgb_channels() <= other.average_rgb_channels() {
*self
} else {
other
}
if self.average_rgb_channels() <= other.average_rgb_channels() { *self } else { other }
}
#[inline(always)]
@@ -682,11 +676,7 @@ impl Color {
#[inline(always)]
pub fn blend_color_dodge(c_b: f32, c_s: f32) -> f32 {
if c_s == 1. {
1.
} else {
(c_b / (1. - c_s)).min(1.)
}
if c_s == 1. { 1. } else { (c_b / (1. - c_s)).min(1.) }
}
#[inline(always)]
@@ -696,11 +686,7 @@ impl Color {
#[inline(always)]
pub fn blend_lighter_color(&self, other: Color) -> Color {
if self.average_rgb_channels() >= other.average_rgb_channels() {
*self
} else {
other
}
if self.average_rgb_channels() >= other.average_rgb_channels() { *self } else { other }
}
pub fn blend_softlight(c_b: f32, c_s: f32) -> f32 {
@@ -745,11 +731,7 @@ impl Color {
}
pub fn blend_hard_mix(c_b: f32, c_s: f32) -> f32 {
if Color::blend_linear_light(c_b, c_s) < 0.5 {
0.
} else {
1.
}
if Color::blend_linear_light(c_b, c_s) < 0.5 { 0. } else { 1. }
}
pub fn blend_difference(c_b: f32, c_s: f32) -> f32 {
@@ -765,11 +747,7 @@ impl Color {
}
pub fn blend_divide(c_b: f32, c_s: f32) -> f32 {
if c_b == 0. {
1.
} else {
c_b / c_s
}
if c_b == 0. { 1. } else { c_b / c_s }
}
pub fn blend_hue(&self, c_s: Color) -> Color {
@@ -988,20 +966,12 @@ impl Color {
#[inline(always)]
pub fn srgb_to_linear(channel: f32) -> f32 {
if channel <= 0.04045 {
channel / 12.92
} else {
((channel + 0.055) / 1.055).powf(2.4)
}
if channel <= 0.04045 { channel / 12.92 } else { ((channel + 0.055) / 1.055).powf(2.4) }
}
#[inline(always)]
pub fn linear_to_srgb(channel: f32) -> f32 {
if channel <= 0.0031308 {
channel * 12.92
} else {
1.055 * channel.powf(1. / 2.4) - 0.055
}
if channel <= 0.0031308 { channel * 12.92 } else { 1.055 * channel.powf(1. / 2.4) - 0.055 }
}
#[inline(always)]

View File

@@ -1,9 +1,7 @@
use super::{Channel, Linear, LuminanceMut};
use crate::Node;
use dyn_any::{DynAny, StaticType, StaticTypeSized};
use core::ops::{Add, Mul, Sub};
use dyn_any::{DynAny, StaticType, StaticTypeSized};
#[derive(Debug, Clone, PartialEq, DynAny, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]

View File

@@ -85,11 +85,7 @@ pub fn float_to_srgb_u8(mut f: f32) -> u8 {
let lerp = bias.wrapping_add(mult * lerp_idx) >> 24;
// Adjust linear interpolation to the correct value.
if f > CRITICAL_POINTS[lerp as usize] {
lerp as u8 + 1
} else {
lerp as u8
}
if f > CRITICAL_POINTS[lerp as usize] { lerp as u8 + 1 } else { lerp as u8 }
}
#[rustfmt::skip]
@@ -156,11 +152,7 @@ mod tests {
// https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#SRGBtoFLOAT
fn srgb_to_float_ref(f: f32) -> f32 {
if f <= 0.04045f32 {
f / 12.92f32
} else {
((f + 0.055f32) / 1.055f32).powf(2.4_f32)
}
if f <= 0.04045f32 { f / 12.92f32 } else { ((f + 0.055f32) / 1.055f32).powf(2.4_f32) }
}
fn srgb_u8_to_float_ref(c: u8) -> f32 {

View File

@@ -1,9 +1,9 @@
use super::discrete_srgb::float_to_srgb_u8;
use super::Color;
use crate::instances::Instances;
use crate::transform::TransformMut;
use super::discrete_srgb::float_to_srgb_u8;
use crate::AlphaBlending;
use crate::GraphicElement;
use crate::instances::Instances;
use crate::transform::TransformMut;
use alloc::vec::Vec;
use core::hash::{Hash, Hasher};
use dyn_any::StaticType;

View File

@@ -1,8 +1,6 @@
use crate::transform::Footprint;
use crate::{Node, NodeIO, NodeIOTypes, Type, WasmNotSend};
use dyn_any::{DynAny, StaticType};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::ops::Deref;
@@ -150,7 +148,9 @@ impl NodeContainer {
#[cfg(feature = "dealloc_nodes")]
unsafe fn dealloc_unchecked(&mut self) {
std::mem::drop(Box::from_raw(self.node as *mut TypeErasedNode));
unsafe {
std::mem::drop(Box::from_raw(self.node as *mut TypeErasedNode));
}
}
}

View File

@@ -1,6 +1,5 @@
use core::marker::PhantomData;
use crate::Node;
use core::marker::PhantomData;
/// This is how we can generically define composition of two nodes.
/// This is done generically as shown: <https://files.keavon.com/-/SurprisedGaseousAnhinga/capture.png>

View File

@@ -1,5 +1,4 @@
use dyn_any::DynAny;
use std::collections::HashMap;
/// A font type (storing font family and font style and an optional preview URL)

View File

@@ -1,7 +1,5 @@
use crate::vector::PointId;
use bezier_rs::{ManipulatorGroup, Subpath};
use glam::DVec2;
use rustybuzz::ttf_parser::{GlyphId, OutlineBuilder};
use rustybuzz::{GlyphBuffer, UnicodeBuffer};

View File

@@ -4,7 +4,6 @@ use crate::raster::bbox::AxisAlignedBbox;
use crate::raster::image::ImageFrameTable;
use crate::vector::VectorDataTable;
use crate::{Artboard, ArtboardGroupTable, CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicGroupTable, OwnedContextImpl};
use glam::{DAffine2, DVec2};
pub trait Transform {

View File

@@ -29,7 +29,7 @@ macro_rules! concrete {
#[macro_export]
macro_rules! concrete_with_name {
($type:ty, $name:expr) => {
($type:ty, $name:expr_2021) => {
$crate::Type::Concrete($crate::TypeDescriptor {
id: Some(core::any::TypeId::of::<$type>()),
name: $crate::Cow::Borrowed($name),
@@ -42,16 +42,12 @@ macro_rules! concrete_with_name {
#[macro_export]
macro_rules! generic {
($type:ty) => {{
$crate::Type::Generic($crate::Cow::Borrowed(stringify!($type)))
}};
($type:ty) => {{ $crate::Type::Generic($crate::Cow::Borrowed(stringify!($type))) }};
}
#[macro_export]
macro_rules! future {
($type:ty) => {{
$crate::Type::Future(Box::new(concrete!($type)))
}};
($type:ty) => {{ $crate::Type::Future(Box::new(concrete!($type))) }};
($type:ty, $name:ty) => {
$crate::Type::Future(Box::new(concrete!($type, $name)))
};

View File

@@ -1,6 +1,5 @@
pub use uuid_generation::*;
use dyn_any::DynAny;
pub use uuid_generation::*;
#[derive(Clone, Copy, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct Uuid(
@@ -45,8 +44,8 @@ mod u64_string {
mod uuid_generation {
use core::cell::Cell;
use rand_chacha::rand_core::{RngCore, SeedableRng};
use rand_chacha::ChaCha20Rng;
use rand_chacha::rand_core::{RngCore, SeedableRng};
use std::sync::Mutex;
static RNG: Mutex<Option<ChaCha20Rng>> = Mutex::new(None);

View File

@@ -1,9 +1,6 @@
use crate::Node;
use core::{
cell::{Cell, RefCell, RefMut},
marker::PhantomData,
};
use core::cell::{Cell, RefCell, RefMut};
use core::marker::PhantomData;
#[derive(Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct IntNode<const N: u32>;

View File

@@ -1,9 +1,7 @@
use crate::raster::bbox::AxisAlignedBbox;
use crate::raster::BlendMode;
use crate::Color;
use crate::raster::BlendMode;
use crate::raster::bbox::AxisAlignedBbox;
use dyn_any::DynAny;
use glam::DVec2;
use std::hash::{Hash, Hasher};

View File

@@ -1,6 +1,5 @@
use crate::vector::{HandleId, VectorData, VectorDataTable};
use crate::Ctx;
use crate::vector::{HandleId, VectorData, VectorDataTable};
use bezier_rs::Subpath;
use glam::DVec2;

View File

@@ -1,14 +1,11 @@
pub mod brush_stroke;
pub mod generator_nodes;
pub mod misc;
pub mod style;
pub use style::PathStyle;
mod vector_data;
pub use vector_data::*;
mod vector_nodes;
pub use vector_nodes::*;
pub use bezier_rs;
pub use style::PathStyle;
pub use vector_data::*;
pub use vector_nodes::*;

View File

@@ -1,11 +1,9 @@
//! Contains stylistic options for SVG elements.
use crate::Color;
use crate::consts::{LAYER_OUTLINE_STROKE_COLOR, LAYER_OUTLINE_STROKE_WEIGHT};
use crate::renderer::format_transform_matrix;
use crate::Color;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use std::fmt::{self, Display, Write};

View File

@@ -1,17 +1,15 @@
mod attributes;
mod modification;
pub use attributes::*;
pub use modification::*;
use super::style::{PathStyle, Stroke};
use crate::instances::Instances;
use crate::{AlphaBlending, Color, GraphicGroupTable};
pub use attributes::*;
use bezier_rs::ManipulatorGroup;
use dyn_any::DynAny;
use core::borrow::Borrow;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
pub use modification::*;
use std::collections::HashMap;
// TODO: Eventually remove this migration document upgrade code

View File

@@ -1,7 +1,5 @@
use crate::vector::vector_data::{HandleId, VectorData};
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
@@ -218,7 +216,7 @@ impl SegmentDomain {
.zip(&self.start_point)
.zip(&self.end_point)
.filter(|((_, start), end)| **start >= points_length || **end >= points_length)
.map(|x| *x.0 .0)
.map(|x| *x.0.0)
.collect::<Vec<_>>();
let can_delete = || {

View File

@@ -1,12 +1,10 @@
use super::*;
use crate::Ctx;
use crate::transform::TransformMut;
use crate::uuid::generate_uuid;
use crate::Ctx;
use bezier_rs::BezierHandles;
use dyn_any::DynAny;
use core::hash::BuildHasher;
use dyn_any::DynAny;
use std::collections::{HashMap, HashSet};
/// Represents a procedural change to the [`PointDomain`] in [`VectorData`].

View File

@@ -5,10 +5,9 @@ use crate::instances::{InstanceMut, Instances};
use crate::registry::types::{Angle, Fraction, IntegerCount, Length, SeedValue};
use crate::renderer::GraphicElementRendered;
use crate::transform::{Footprint, Transform, TransformMut};
use crate::vector::style::LineJoin;
use crate::vector::PointDomain;
use crate::vector::style::LineJoin;
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicElement, GraphicGroupTable, OwnedContextImpl};
use bezier_rs::{Cap, Join, Subpath, SubpathTValue, TValue};
use glam::{DAffine2, DVec2};
use rand::{Rng, SeedableRng};
@@ -1067,9 +1066,7 @@ async fn centroid(ctx: impl Ctx + CloneVarArgs + ExtractAll, vector_data: impl N
mod test {
use super::*;
use crate::Node;
use bezier_rs::Bezier;
use std::pin::Pin;
#[derive(Clone)]

View File

@@ -1,7 +1,7 @@
[package]
name = "gpu-compiler"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,7 +1,7 @@
[package]
name = "gpu-compiler-bin-wrapper"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,7 +1,7 @@
use graph_craft::{proto::ProtoNetwork, Type};
use wgpu_executor::ShaderIO;
use graph_craft::Type;
use graph_craft::proto::ProtoNetwork;
use std::io::Write;
use wgpu_executor::ShaderIO;
pub fn compile_spirv(request: &CompileRequest, compile_dir: Option<&str>, manifest_path: &str) -> anyhow::Result<Vec<u8>> {
let serialized_graph = serde_json::to_string(&graph_craft::graphene_compiler::CompileRequest {

View File

@@ -1,7 +1,6 @@
use gpu_executor::{GPUConstant, ShaderIO, ShaderInput, SpirVCompiler};
use graph_craft::proto::*;
use graphene_core::Cow;
use std::path::{Path, PathBuf};
use tera::Context;
@@ -242,7 +241,7 @@ mod test {
name = "project-node"
version = "0.1.0"
authors = ["Example <john.smith@example.com>", "smith.john@example.com", ]
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
publish = false

View File

@@ -2,7 +2,7 @@
authors = [{% for author in authors %}"{{author}}", {% endfor %}]
name = "{{name}}-node"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
publish = false

View File

@@ -1,7 +1,7 @@
[package]
name = "gpu-executor"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,9 +1,9 @@
use graphene_core::raster::{color::RGBA16F, Image, Pixel, SRGBA8};
use graphene_core::*;
use bytemuck::{Pod, Zeroable};
use dyn_any::{StaticType, StaticTypeSized};
use glam::UVec3;
use graphene_core::raster::color::RGBA16F;
use graphene_core::raster::{Image, Pixel, SRGBA8};
use graphene_core::*;
use std::borrow::Cow;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, dyn_any::DynAny)]

View File

@@ -1,7 +1,7 @@
[package]
name = "graph-craft"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use graph_craft::util::DEMO_ART;
fn compile_to_proto(c: &mut Criterion) {
use graph_craft::util::{compile, load_from_name};

View File

@@ -1,18 +1,17 @@
use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use dyn_any::DynAny;
use graphene_core::memo::MemoHashGuard;
pub use graphene_core::uuid::generate_uuid;
pub use graphene_core::uuid::NodeId;
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
pub mod value;
use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use dyn_any::DynAny;
use glam::IVec2;
use graphene_core::memo::MemoHashGuard;
pub use graphene_core::uuid::NodeId;
pub use graphene_core::uuid::generate_uuid;
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
use log::Metadata;
use rustc_hash::FxHashMap;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
/// Hash two IDs together, returning a new ID that is always consistent for two input IDs in a specific order.
@@ -455,33 +454,17 @@ impl NodeInput {
}
pub fn as_value(&self) -> Option<&TaggedValue> {
if let NodeInput::Value { tagged_value, .. } = self {
Some(tagged_value)
} else {
None
}
if let NodeInput::Value { tagged_value, .. } = self { Some(tagged_value) } else { None }
}
pub fn as_value_mut(&mut self) -> Option<MemoHashGuard<TaggedValue>> {
if let NodeInput::Value { tagged_value, .. } = self {
Some(tagged_value.inner_mut())
} else {
None
}
if let NodeInput::Value { tagged_value, .. } = self { Some(tagged_value.inner_mut()) } else { None }
}
pub fn as_non_exposed_value(&self) -> Option<&TaggedValue> {
if let NodeInput::Value { tagged_value, exposed: false } = self {
Some(tagged_value)
} else {
None
}
if let NodeInput::Value { tagged_value, exposed: false } = self { Some(tagged_value) } else { None }
}
pub fn as_node(&self) -> Option<NodeId> {
if let NodeInput::Node { node_id, .. } = self {
Some(*node_id)
} else {
None
}
if let NodeInput::Node { node_id, .. } = self { Some(*node_id) } else { None }
}
}
@@ -942,12 +925,7 @@ impl NodeNetwork {
fn replace_node_inputs(&mut self, node_id: NodeId, old_input: (NodeId, usize), new_input: (NodeId, usize)) {
let Some(node) = self.nodes.get_mut(&node_id) else { return };
node.inputs.iter_mut().for_each(|input| {
if let NodeInput::Node {
node_id: ref mut input_id,
ref mut output_index,
..
} = input
{
if let NodeInput::Node { node_id: input_id, output_index, .. } = input {
if (*input_id, *output_index) == old_input {
(*input_id, *output_index) = new_input;
}
@@ -1241,12 +1219,7 @@ impl NodeNetwork {
}
}
for node_input in self.exports.iter_mut() {
if let NodeInput::Node {
ref mut node_id,
ref mut output_index,
..
} = node_input
{
if let NodeInput::Node { node_id, output_index, .. } = node_input {
if *node_id == id {
*node_id = input_node_id;
*output_index = node_input_output_index;
@@ -1382,9 +1355,7 @@ impl<'a> Iterator for RecursiveNodeIter<'a> {
mod test {
use super::*;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use graphene_core::ProtoNodeIdentifier;
use std::sync::atomic::AtomicU64;
fn gen_node_id() -> NodeId {
@@ -1478,7 +1449,7 @@ mod test {
assert_eq!(extraction_network.nodes.len(), 1);
let inputs = extraction_network.nodes.get(&NodeId(1)).unwrap().inputs.clone();
assert_eq!(inputs.len(), 1);
assert!(matches!(&inputs[0].as_value(), &Some(TaggedValue::DocumentNode(ref network), ..) if network == &id_node));
assert!(matches!(&inputs[0].as_value(), &Some(TaggedValue::DocumentNode(network), ..) if network == &id_node));
}
#[test]

View File

@@ -2,17 +2,15 @@ use super::DocumentNode;
pub use crate::imaginate_input::{ImaginateCache, ImaginateController, ImaginateMaskStartingFill, ImaginateSamplingMethod};
use crate::proto::{Any as DAny, FutureAny};
use crate::wasm_application_io::WasmEditorApi;
use dyn_any::DynAny;
pub use dyn_any::StaticType;
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphene_core::raster::brush_cache::BrushCache;
use graphene_core::raster::{BlendMode, LuminanceCalculation};
use graphene_core::renderer::RenderMetadata;
use graphene_core::uuid::NodeId;
use graphene_core::vector::style::Fill;
use graphene_core::{Color, MemoHash, Node, Type};
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use std::fmt::Display;
use std::hash::Hash;
use std::marker::PhantomData;

View File

@@ -1,7 +1,6 @@
use std::error::Error;
use crate::document::NodeNetwork;
use crate::proto::{LocalFuture, ProtoNetwork};
use std::error::Error;
pub struct Compiler {}

View File

@@ -1,6 +1,5 @@
use dyn_any::DynAny;
use graphene_core::Color;
use std::borrow::Cow;
use std::fmt::Debug;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@@ -3,7 +3,7 @@ extern crate log;
#[macro_use]
extern crate graphene_core;
pub use graphene_core::{concrete, generic, ProtoNodeIdentifier, Type, TypeDescriptor};
pub use graphene_core::{ProtoNodeIdentifier, Type, TypeDescriptor, concrete, generic};
pub mod document;
pub mod proto;

View File

@@ -1,9 +1,7 @@
use crate::document::{value, InlineRust};
use crate::document::{InlineRust, value};
use crate::document::{NodeId, OriginalLocation};
pub use graphene_core::registry::*;
use graphene_core::*;
use rustc_hash::FxHashMap;
#[cfg(feature = "serde")]
use std::borrow::Cow;

View File

@@ -1,16 +1,12 @@
use dyn_any::StaticType;
use graphene_core::application_io::SurfaceHandleFrame;
use graphene_core::application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
use wgpu_executor::WgpuExecutor;
use dyn_any::StaticType;
#[cfg(target_arch = "wasm32")]
use js_sys::{Object, Reflect};
use std::collections::HashMap;
use std::sync::Arc;
#[cfg(target_arch = "wasm32")]
use std::sync::atomic::AtomicU64;
use std::sync::Arc;
// #[cfg(not(target_arch = "wasm32"))]
// use std::sync::Mutex;
#[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt;
#[cfg(target_arch = "wasm32")]
@@ -18,9 +14,10 @@ use wasm_bindgen::JsCast;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::JsValue;
#[cfg(target_arch = "wasm32")]
use web_sys::window;
#[cfg(target_arch = "wasm32")]
use web_sys::HtmlCanvasElement;
#[cfg(target_arch = "wasm32")]
use web_sys::window;
use wgpu_executor::WgpuExecutor;
#[derive(Debug)]
struct WindowWrapper {

View File

@@ -1,7 +1,7 @@
[package]
name = "graphene-cli"
version = "0.1.0"
edition = "2021"
edition = "2024"
description = "CLI interface for the graphene language"
authors = ["Graphite Authors <contact@graphite.rs>"]
license = "MIT OR Apache-2.0"

View File

@@ -1,3 +1,6 @@
use clap::{Args, Parser, Subcommand};
use fern::colors::{Color, ColoredLevelConfig};
use futures::executor::block_on;
use graph_craft::document::*;
use graph_craft::graphene_compiler::{Compiler, Executor};
use graph_craft::proto::ProtoNetwork;
@@ -7,12 +10,10 @@ 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 clap::{Args, Parser, Subcommand};
use fern::colors::{Color, ColoredLevelConfig};
use futures::executor::block_on;
use interpreted_executor::util::wrap_network_in_scope;
use std::{error::Error, path::PathBuf, sync::Arc};
use std::error::Error;
use std::path::PathBuf;
use std::sync::Arc;
struct UpdateLogger {}
@@ -107,9 +108,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
}
Command::Run { run_loop, .. } => {
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_nanos(10));
device.poll(wgpu::Maintain::Poll);
std::thread::spawn(move || {
loop {
std::thread::sleep(std::time::Duration::from_nanos(10));
device.poll(wgpu::Maintain::Poll);
}
});
let executor = create_executor(proto_graph)?;
let render_config = graphene_core::application_io::RenderConfig::default();

View File

@@ -1,7 +1,7 @@
[package]
name = "graphene-std"
version = "0.1.0"
edition = "2021"
edition = "2024"
description = "Graphene standard library"
authors = ["Graphite Authors <contact@graphite.rs>"]
license = "MIT OR Apache-2.0"

View File

@@ -1,10 +1,10 @@
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};
pub use graphene_core::registry::{DowncastBothNode, DynAnyNode, FutureWrapperNode, PanicNode};
pub use graphene_core::{Node, generic, ops};
pub trait IntoTypeErasedNode<'n> {
fn into_type_erased(self) -> TypeErasedBox<'n>;

View File

@@ -1,5 +1,5 @@
use crate::raster::{blend_image_closure, BlendImageTupleNode, ExtendImageToBoundsNode};
use crate::raster::{BlendImageTupleNode, ExtendImageToBoundsNode, blend_image_closure};
use glam::{DAffine2, DVec2};
use graph_craft::generic::FnNode;
use graph_craft::proto::FutureWrapperNode;
use graphene_core::raster::adjustments::blend_colors;
@@ -9,12 +9,10 @@ use graphene_core::raster::image::{Image, ImageFrameTable};
use graphene_core::raster::{Alpha, Bitmap, BlendMode, Color, Pixel, Sample};
use graphene_core::transform::{Transform, TransformMut};
use graphene_core::value::{ClonedNode, CopiedNode, ValueNode};
use graphene_core::vector::brush_stroke::{BrushStroke, BrushStyle};
use graphene_core::vector::VectorDataTable;
use graphene_core::vector::brush_stroke::{BrushStroke, BrushStyle};
use graphene_core::{Ctx, GraphicElement, Node};
use glam::{DAffine2, DVec2};
#[node_macro::node(category("Debug"))]
fn vector_points(_: impl Ctx, vector_data: VectorDataTable) -> Vec<DVec2> {
let vector_data = vector_data.one_instance().instance;
@@ -335,12 +333,10 @@ async fn brush(_: impl Ctx, image_frame_table: ImageFrameTable<Color>, bounds: I
#[cfg(test)]
mod test {
use super::*;
use glam::DAffine2;
use graphene_core::raster::Bitmap;
use graphene_core::transform::Transform;
use glam::DAffine2;
#[test]
fn test_brush_texture() {
let size = 20.;

View File

@@ -1,14 +1,12 @@
use parking_lot::RawRwLock;
use std::{
any::Any,
borrow::Borrow,
cell::RefCell,
collections::{hash_map::DefaultHasher, HashMap},
hash::{Hash, Hasher},
iter,
iter::Sum,
marker::PhantomData,
};
use std::any::Any;
use std::borrow::Borrow;
use std::cell::RefCell;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::iter::{self, Sum};
use std::marker::PhantomData;
use storage_map::{StorageMap, StorageMapGuard};
/// Caches the output of a given Node and acts as a proxy
@@ -21,8 +19,16 @@ impl<'n: 'c, 'c, NODE: Node + 'c> Node for SmartCacheNode<'n, 'c, NODE>
where
for<'a> NODE::Input<'a>: Hash,
{
type Input<'a> = NODE::Input<'a> where Self: 'a, 'c : 'a;
type Output<'a> = StorageMapGuard<'a, RawRwLock, CacheNode<'n, 'c, NODE>> where Self: 'a, 'c: 'a;
type Input<'a>
= NODE::Input<'a>
where
Self: 'a,
'c: 'a;
type Output<'a>
= StorageMapGuard<'a, RawRwLock, CacheNode<'n, 'c, NODE>>
where
Self: 'a,
'c: 'a;
fn eval<'a, I: Borrow<Self::Input<'a>>>(&'a self, input: I) -> Self::Output<'a> {
let mut hasher = DefaultHasher::new();
input.borrow().hash(&mut hasher);

View File

@@ -2,7 +2,6 @@ use graph_craft::proto::types::Percentage;
use graphene_core::raster::image::{Image, ImageFrameTable};
use graphene_core::transform::{Transform, TransformMut};
use graphene_core::{Color, Ctx};
use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
use ndarray::{Array2, ArrayBase, Dim, OwnedRepr};
use std::cmp::{max, min};

View File

@@ -1,4 +1,6 @@
use crate::wasm_application_io::WasmApplicationIo;
use dyn_any::StaticTypeSized;
use glam::{DAffine2, DVec2, Mat2, Vec2};
use gpu_executor::{ComputePassDimensions, StorageBufferOptions};
use graph_craft::document::value::TaggedValue;
use graph_craft::document::*;
@@ -9,14 +11,9 @@ use graphene_core::raster::{BlendMode, Pixel};
use graphene_core::transform::Transform;
use graphene_core::transform::TransformMut;
use graphene_core::*;
use wgpu_executor::{Bindgroup, PipelineLayout, Shader, ShaderIO, ShaderInput, WgpuExecutor, WgpuShaderInput};
use glam::{DAffine2, DVec2, Mat2, Vec2};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use crate::wasm_application_io::WasmApplicationIo;
use wgpu_executor::{Bindgroup, PipelineLayout, Shader, ShaderIO, ShaderInput, WgpuExecutor, WgpuShaderInput};
// TODO: Move to graph-craft
#[node_macro::node(category("Debug: GPU"))]

View File

@@ -29,7 +29,7 @@ async fn image_color_palette(
colors[bin].push(pixel.to_gamma_srgb());
}
let shorted = histogram.iter().enumerate().filter(|(_, &count)| count > 0).map(|(i, _)| i).collect::<Vec<usize>>();
let shorted = histogram.iter().enumerate().filter(|&(_, &count)| count > 0).map(|(i, _)| i).collect::<Vec<usize>>();
let mut palette = vec![];
@@ -64,7 +64,6 @@ async fn image_color_palette(
#[cfg(test)]
mod test {
use super::*;
use graphene_core::raster::image::{Image, ImageFrameTable};
#[test]

View File

@@ -1,7 +1,8 @@
use crate::wasm_application_io::WasmEditorApi;
use core::any::TypeId;
use core::future::Future;
use futures::{future::Either, TryFutureExt};
use futures::TryFutureExt;
use futures::future::Either;
use glam::{DVec2, U64Vec2};
use graph_craft::imaginate_input::{ImaginateController, ImaginateMaskStartingFill, ImaginateSamplingMethod, ImaginateServerStatus, ImaginateStatus, ImaginateTerminationHandle};
use graph_craft::wasm_application_io::EditorPreferences;

View File

@@ -1,4 +1,6 @@
use dyn_any::DynAny;
use fastnoise_lite;
use glam::{DAffine2, DVec2, Vec2};
use graphene_core::raster::bbox::Bbox;
use graphene_core::raster::image::{Image, ImageFrameTable};
use graphene_core::raster::{
@@ -6,9 +8,6 @@ use graphene_core::raster::{
};
use graphene_core::transform::{Transform, TransformMut};
use graphene_core::{AlphaBlending, Color, Ctx, ExtractFootprint, GraphicElement, Node};
use fastnoise_lite;
use glam::{DAffine2, DVec2, Vec2};
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
use std::fmt::Debug;

View File

@@ -1,9 +1,8 @@
use crate::vector::{VectorData, VectorDataTable};
use graph_craft::wasm_application_io::WasmEditorApi;
use graphene_core::text::TypesettingConfig;
pub use graphene_core::text::{bounding_box, load_face, to_path, Font, FontCache};
use graphene_core::Ctx;
use graphene_core::text::TypesettingConfig;
pub use graphene_core::text::{Font, FontCache, bounding_box, load_face, to_path};
#[node_macro::node(category(""))]
fn text<'i: 'n>(

View File

@@ -1,7 +1,6 @@
use core::marker::PhantomData;
pub use graphene_core::value::*;
use graphene_core::Node;
use dyn_any::DynAny;
pub struct AnyRefNode<'n, N: Node<'n>>(N, PhantomData<&'n ()>);

View File

@@ -1,4 +1,5 @@
use bezier_rs::{ManipulatorGroup, Subpath};
use glam::{DAffine2, DVec2};
use graphene_core::transform::Transform;
use graphene_core::transform::TransformMut;
use graphene_core::vector::misc::BooleanOperation;
@@ -7,8 +8,6 @@ pub use graphene_core::vector::*;
use graphene_core::{Color, Ctx, GraphicElement, GraphicGroupTable};
pub use path_bool as path_bool_lib;
use path_bool::{FillRule, PathBooleanOperation};
use glam::{DAffine2, DVec2};
use std::ops::Mul;
#[node_macro::node(category(""))]

View File

@@ -10,7 +10,7 @@ use graphene_core::instances::Instances;
use graphene_core::raster::bbox::Bbox;
use graphene_core::raster::image::{Image, ImageFrameTable};
use graphene_core::renderer::RenderMetadata;
use graphene_core::renderer::{format_transform_matrix, GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender};
use graphene_core::renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
use graphene_core::transform::Footprint;
#[cfg(target_arch = "wasm32")]
use graphene_core::transform::TransformMut;

View File

@@ -1,7 +1,7 @@
[package]
name = "interpreted-executor"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,9 +1,8 @@
use criterion::{measurement::Measurement, BenchmarkGroup};
use criterion::BenchmarkGroup;
use criterion::measurement::Measurement;
use futures::executor::block_on;
use graph_craft::{
proto::ProtoNetwork,
util::{compile, load_from_name, DEMO_ART},
};
use graph_craft::proto::ProtoNetwork;
use graph_craft::util::{DEMO_ART, compile, load_from_name};
use interpreted_executor::dynamic_executor::DynamicExecutor;
pub fn setup_network(name: &str) -> (DynamicExecutor, ProtoNetwork) {

View File

@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, Criterion};
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
use criterion::{Criterion, criterion_group, criterion_main};
use graph_craft::graphene_compiler::Executor;
use graphene_std::transform::Footprint;
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
fn subsequent_evaluations(c: &mut Criterion) {
let mut group = c.benchmark_group("Subsequent Evaluations");
let footprint = Footprint::default();

View File

@@ -1,9 +1,8 @@
use criterion::{black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion};
use graph_craft::{
graphene_compiler::Executor,
proto::ProtoNetwork,
util::{compile, load_from_name, DEMO_ART},
};
use criterion::measurement::Measurement;
use criterion::{BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main};
use graph_craft::graphene_compiler::Executor;
use graph_craft::proto::ProtoNetwork;
use graph_craft::util::{DEMO_ART, compile, load_from_name};
use graphene_std::transform::Footprint;
use interpreted_executor::dynamic_executor::DynamicExecutor;

View File

@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, Criterion};
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
use criterion::{Criterion, criterion_group, criterion_main};
use graph_craft::graphene_compiler::Executor;
use graphene_std::transform::Footprint;
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
fn run_once(c: &mut Criterion) {
let mut group = c.benchmark_group("Run Once");
let footprint = Footprint::default();

View File

@@ -1,10 +1,10 @@
use criterion::{criterion_group, criterion_main, Criterion};
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
use criterion::{Criterion, criterion_group, criterion_main};
use graph_craft::proto::ProtoNetwork;
use interpreted_executor::dynamic_executor::DynamicExecutor;
mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network};
fn update_executor(c: &mut Criterion) {
let mut group = c.benchmark_group("Update Executor");
bench_for_each_demo(&mut group, |name, g| {

View File

@@ -1,13 +1,11 @@
use crate::node_registry;
use dyn_any::StaticType;
use graph_craft::document::value::{TaggedValue, UpcastAsRefNode, UpcastNode};
use graph_craft::Type;
use graph_craft::document::NodeId;
use graph_craft::document::value::{TaggedValue, UpcastAsRefNode, UpcastNode};
use graph_craft::graphene_compiler::Executor;
use graph_craft::proto::{ConstructionArgs, GraphError, LocalFuture, NodeContainer, ProtoNetwork, ProtoNode, SharedNodeContainer, TypeErasedBox, TypingContext};
use graph_craft::proto::{GraphErrorType, GraphErrors};
use graph_craft::Type;
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::panic::UnwindSafe;
@@ -266,8 +264,10 @@ impl BorrowTree {
///
/// ```rust
/// use std::collections::HashMap;
/// use graph_craft::{proto::*, document::*};
/// use interpreted_executor::{node_registry, dynamic_executor::BorrowTree};
/// use graph_craft::document::*;
/// use graph_craft::proto::*;
/// use interpreted_executor::dynamic_executor::BorrowTree;
/// use interpreted_executor::node_registry;
///
///
/// async fn example() -> Result<(), GraphErrors> {
@@ -409,7 +409,6 @@ impl BorrowTree {
#[cfg(test)]
mod test {
use super::*;
use graph_craft::document::value::TaggedValue;
#[test]

View File

@@ -4,9 +4,8 @@ pub mod util;
#[cfg(test)]
mod tests {
use graphene_core::*;
use futures::executor::block_on;
use graphene_core::*;
#[test]
fn double_number() {

View File

@@ -1,4 +1,5 @@
use dyn_any::StaticType;
use glam::{DVec2, UVec2};
use graph_craft::document::value::RenderOutput;
use graph_craft::proto::{NodeConstructor, TypeErasedBox};
use graphene_core::fn_type;
@@ -7,23 +8,21 @@ use graphene_core::raster::image::ImageFrameTable;
use graphene_core::raster::*;
use graphene_core::value::{ClonedNode, ValueNode};
use graphene_core::vector::VectorDataTable;
use graphene_core::{concrete, generic, Artboard, GraphicGroupTable};
use graphene_core::{fn_type_fut, future};
use graphene_core::{Artboard, GraphicGroupTable, concrete, generic};
use graphene_core::{Cow, ProtoNodeIdentifier, Type};
use graphene_core::{Node, NodeIO, NodeIOTypes};
use graphene_core::{fn_type_fut, future};
use graphene_std::Context;
use graphene_std::GraphicElement;
use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, FutureWrapperNode, IntoTypeErasedNode};
use graphene_std::application_io::ImageTexture;
use graphene_std::wasm_application_io::*;
use graphene_std::Context;
use graphene_std::GraphicElement;
#[cfg(feature = "gpu")]
use wgpu_executor::{ShaderInputFrame, WgpuExecutor};
use wgpu_executor::{WgpuSurface, WindowHandle};
use glam::{DVec2, UVec2};
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::sync::Arc;
#[cfg(feature = "gpu")]
use wgpu_executor::{ShaderInputFrame, WgpuExecutor};
use wgpu_executor::{WgpuSurface, WindowHandle};
macro_rules! async_node {
// TODO: we currently need to annotate the type here because the compiler would otherwise (correctly)
@@ -193,7 +192,8 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
// (
// ProtoNodeIdentifier::new("graphene_core::raster::CurvesNode"),
// |args| {
// use graphene_core::raster::{curve::Curve, GenerateCurvesNode};
// use graphene_core::raster::curve::Curve;
// use graphene_core::raster::GenerateCurvesNode;
// let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone());
// Box::pin(async move {
// let curve = ClonedNode::new(curve.eval(()).await);
@@ -211,7 +211,8 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
// (
// ProtoNodeIdentifier::new("graphene_core::raster::CurvesNode"),
// |args| {
// use graphene_core::raster::{curve::Curve, GenerateCurvesNode};
// use graphene_core::raster::curve::Curve;
// use graphene_core::raster::GenerateCurvesNode;
// let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone());
// Box::pin(async move {
// let curve = ValueNode::new(ClonedNode::new(curve.eval(()).await));

View File

@@ -1,12 +1,12 @@
use std::sync::Arc;
use graph_craft::ProtoNodeIdentifier;
use graph_craft::concrete;
use graph_craft::document::{value::TaggedValue, DocumentNode, DocumentNodeImplementation, NodeInput, NodeNetwork};
use graph_craft::document::value::TaggedValue;
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeInput, NodeNetwork};
use graph_craft::generic;
use graph_craft::wasm_application_io::WasmEditorApi;
use graph_craft::ProtoNodeIdentifier;
use graphene_std::uuid::NodeId;
use graphene_std::Context;
use graphene_std::uuid::NodeId;
use std::sync::Arc;
// TODO: this is copy pasta from the editor (and does get out of sync)
pub fn wrap_network_in_scope(mut network: NodeNetwork, editor_api: Arc<WasmEditorApi>) -> NodeNetwork {

View File

@@ -2,9 +2,9 @@
name = "node-macro"
publish = false
version = "0.0.0"
rust-version = "1.79"
rust-version = "1.85"
authors = ["Graphite Authors <contact@graphite.rs>"]
edition = "2021"
edition = "2024"
readme = "../../README.md"
homepage = "https://graphite.rs"
repository = "https://github.com/GraphiteEditor/Graphite"

View File

@@ -1,14 +1,13 @@
use std::sync::atomic::AtomicU64;
use crate::parsing::*;
use convert_case::{Case, Casing};
use proc_macro2::TokenStream as TokenStream2;
use proc_macro_crate::FoundCrate;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use std::sync::atomic::AtomicU64;
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::Comma;
use syn::{parse_quote, Error, Ident, PatIdent, Token, WhereClause, WherePredicate};
use syn::{Error, Ident, PatIdent, Token, WhereClause, WherePredicate, parse_quote};
static NODE_ID: AtomicU64 = AtomicU64::new(0);
pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStream2> {
@@ -68,8 +67,8 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStre
})
.collect();
let struct_fields = field_names.iter().zip(struct_generics.iter()).map(|(name, gen)| {
quote! { pub(super) #name: #gen }
let struct_fields = field_names.iter().zip(struct_generics.iter()).map(|(name, r#gen)| {
quote! { pub(super) #name: #r#gen }
});
let graphene_core = match graphene_core_crate {
@@ -225,8 +224,8 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStre
);
struct_where_clause.predicates.extend(extra_where);
let new_args = struct_generics.iter().zip(field_names.iter()).map(|(gen, name)| {
quote! { #name: #gen }
let new_args = struct_generics.iter().zip(field_names.iter()).map(|(r#gen, name)| {
quote! { #name: #r#gen }
});
let async_keyword = is_async.then(|| quote!(async));
@@ -520,7 +519,7 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st
);
}
#[cfg(target_arch = "wasm32")]
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn #registry_name() {
register_node();
register_metadata();
@@ -528,7 +527,8 @@ fn generate_register_node_impl(parsed: &ParsedNodeFn, field_names: &[&Ident], st
})
}
use syn::{visit_mut::VisitMut, GenericArgument, Lifetime, Type};
use syn::visit_mut::VisitMut;
use syn::{GenericArgument, Lifetime, Type};
struct LifetimeReplacer(&'static str);

View File

@@ -1,12 +1,12 @@
// TODO: Deprecate and remove this file
use proc_macro::TokenStream;
use proc_macro2::Span;
use proc_macro_error2::proc_macro_error;
use quote::{format_ident, quote, ToTokens};
use proc_macro2::Span;
use quote::{ToTokens, format_ident, quote};
use syn::{
parse_macro_input, punctuated::Punctuated, token::Comma, AngleBracketedGenericArguments, AssocType, FnArg, GenericArgument, GenericParam, Ident, ItemFn, Lifetime, Pat, PatIdent, PathArguments,
PathSegment, PredicateType, ReturnType, Token, TraitBound, Type, TypeImplTrait, TypeParam, TypeParamBound, TypeTuple, WhereClause, WherePredicate,
AngleBracketedGenericArguments, AssocType, FnArg, GenericArgument, GenericParam, Ident, ItemFn, Lifetime, Pat, PatIdent, PathArguments, PathSegment, PredicateType, ReturnType, Token, TraitBound,
Type, TypeImplTrait, TypeParam, TypeParamBound, TypeTuple, WhereClause, WherePredicate, parse_macro_input, punctuated::Punctuated, token::Comma,
};
mod codegen;

View File

@@ -1,13 +1,13 @@
use convert_case::{Case, Casing};
use indoc::{formatdoc, indoc};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, ToTokens};
use quote::{ToTokens, format_ident};
use syn::parse::{Parse, ParseStream, Parser};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::{Comma, RArrow};
use syn::{
parse_quote, AttrStyle, Attribute, Error, Expr, ExprTuple, FnArg, GenericParam, Ident, ItemFn, Lit, LitFloat, LitStr, Meta, Pat, PatIdent, PatType, Path, ReturnType, Type, TypeParam, WhereClause,
AttrStyle, Attribute, Error, Expr, ExprTuple, FnArg, GenericParam, Ident, ItemFn, Lit, LitFloat, LitStr, Meta, Pat, PatIdent, PatType, Path, ReturnType, Type, TypeParam, WhereClause, parse_quote,
};
use crate::codegen::generate_node_code;
@@ -519,11 +519,7 @@ fn parse_node_type(ty: &Type) -> (bool, Option<Type>, Option<Type>) {
let input_type = args.args.iter().find_map(|arg| if let syn::GenericArgument::Type(ty) = arg { Some(ty.clone()) } else { None });
let output_type = args.args.iter().find_map(|arg| {
if let syn::GenericArgument::AssocType(assoc_type) = arg {
if assoc_type.ident == "Output" {
Some(assoc_type.ty.clone())
} else {
None
}
if assoc_type.ident == "Output" { Some(assoc_type.ty.clone()) } else { None }
} else {
None
}
@@ -597,8 +593,8 @@ impl ParsedNodeFn {
#[cfg(test)]
mod tests {
use super::*;
use proc_macro2::Span;
use proc_macro_crate::FoundCrate;
use proc_macro2::Span;
use quote::{quote, quote_spanned};
use syn::parse_quote;
fn pat_ident(name: &str) -> PatIdent {

View File

@@ -1,8 +1,8 @@
use crate::parsing::{Implementation, ParsedField, ParsedNodeFn};
use proc_macro_error2::emit_error;
use quote::quote;
use syn::{spanned::Spanned, GenericParam, Type};
use syn::spanned::Spanned;
use syn::{GenericParam, Type};
pub fn validate_node_fn(parsed: &ParsedNodeFn) -> syn::Result<()> {
let validators: &[fn(&ParsedNodeFn)] = &[

View File

@@ -1,7 +1,7 @@
[package]
name = "wgpu-executor"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
[features]

View File

@@ -1,8 +1,6 @@
use super::context::Context;
use dyn_any::StaticTypeSized;
use bytemuck::Pod;
use dyn_any::StaticTypeSized;
use std::borrow::Cow;
use std::error::Error;
use std::pin::Pin;

View File

@@ -1,20 +1,18 @@
mod context;
mod executor;
use anyhow::{Result, bail};
pub use context::Context;
pub use executor::GpuExecutor;
use dyn_any::{DynAny, StaticType};
pub use executor::GpuExecutor;
use futures::Future;
use glam::{DAffine2, UVec2};
use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer};
use graphene_core::application_io::{ApplicationIo, EditorApi, ImageTexture, SurfaceHandle};
use graphene_core::raster::image::ImageFrameTable;
use graphene_core::raster::{Image, SRGBA8};
use graphene_core::transform::{Footprint, Transform};
use graphene_core::{Color, Cow, Ctx, ExtractFootprint, Node, SurfaceFrame, Type};
use anyhow::{bail, Result};
use futures::Future;
use glam::{DAffine2, UVec2};
use std::pin::Pin;
use std::sync::Arc;
use vello::{AaConfig, AaSupport, RenderParams, Renderer, RendererOptions, Scene};
@@ -473,39 +471,38 @@ impl WgpuExecutor {
pub fn read_output_buffer(&self, buffer: Arc<WgpuShaderInput>) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send>> {
Box::pin(async move {
if let ShaderInput::ReadBackBuffer(buffer, _) = buffer.as_ref() {
let buffer_slice = buffer.slice(..);
// Sets the buffer up for mapping, sending over the result of the mapping back to us when it is finished.
let (sender, receiver) = futures_intrusive::channel::shared::oneshot_channel();
buffer_slice.map_async(wgpu::MapMode::Read, move |v| sender.send(v).unwrap());
// Wait for the mapping to finish.
#[cfg(feature = "profiling")]
nvtx::range_push!("compute");
let result = receiver.receive().await;
#[cfg(feature = "profiling")]
nvtx::range_pop!();
if result == Some(Ok(())) {
// Gets contents of buffer
let data = buffer_slice.get_mapped_range();
// Since contents are got in bytes, this converts these bytes back to u32
let result = bytemuck::cast_slice(&data).to_vec();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(data);
buffer.unmap(); // Unmaps buffer from memory
// Returns data from buffer
Ok(result)
} else {
bail!("failed to run compute on gpu!")
}
} else {
let ShaderInput::ReadBackBuffer(buffer, _) = buffer.as_ref() else {
bail!("Tried to read a non readback buffer")
};
let buffer_slice = buffer.slice(..);
// Sets the buffer up for mapping, sending over the result of the mapping back to us when it is finished.
let (sender, receiver) = futures_intrusive::channel::shared::oneshot_channel();
buffer_slice.map_async(wgpu::MapMode::Read, move |v| sender.send(v).unwrap());
// Wait for the mapping to finish.
#[cfg(feature = "profiling")]
nvtx::range_push!("compute");
let result = receiver.receive().await;
#[cfg(feature = "profiling")]
nvtx::range_pop!();
if result.is_none_or(|x| x.is_err()) {
bail!("failed to run compute on gpu!")
}
// Gets contents of buffer
let data = buffer_slice.get_mapped_range();
// Since contents are got in bytes, this converts these bytes back to u32
let result = bytemuck::cast_slice(&data).to_vec();
// With the current interface, we have to make sure all mapped views are
// dropped before we unmap the buffer.
drop(data);
buffer.unmap(); // Unmaps buffer from memory
// Returns data from buffer
Ok(result)
})
}