Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions node-graph/gcore/src/application_io.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
use crate::text::FontCache;
use crate::transform::Footprint;
use crate::vector::style::ViewMode;
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 core::time::Duration;
use dyn_any::{DynAny, StaticType, StaticTypeSized};
use glam::{DAffine2, UVec2};
use std::fmt::Debug;
use std::future::Future;
use std::hash::{Hash, Hasher};
use std::pin::Pin;
use std::ptr::addr_of;
use std::sync::Arc;
use std::time::Duration;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SurfaceId(pub u64);

impl core::fmt::Display for SurfaceId {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
impl std::fmt::Display for SurfaceId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{}", self.0))
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ impl<Io> PartialEq for EditorApi<Io> {
}

impl<T> Debug for EditorApi<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("EditorApi").field("font_cache", &self.font_cache).finish()
}
}
Expand Down
18 changes: 9 additions & 9 deletions node-graph/gcore/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::transform::Footprint;
use core::any::Any;
use core::borrow::Borrow;
use core::panic::Location;
use std::any::Any;
use std::borrow::Borrow;
use std::panic::Location;
use std::sync::Arc;

pub trait Ctx: Clone + Send {}
Expand Down Expand Up @@ -240,7 +240,7 @@ type DynBox = Box<dyn Any + Send + Sync>;

#[derive(dyn_any::DynAny)]
pub struct OwnedContextImpl {
footprint: Option<crate::transform::Footprint>,
footprint: Option<Footprint>,
varargs: Option<Arc<[DynBox]>>,
parent: Option<Arc<dyn ExtractVarArgs + Sync + Send>>,
// This could be converted into a single enum to save extra bytes
Expand All @@ -249,8 +249,8 @@ pub struct OwnedContextImpl {
animation_time: Option<f64>,
}

impl core::fmt::Debug for OwnedContextImpl {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
impl std::fmt::Debug for OwnedContextImpl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("OwnedContextImpl")
.field("footprint", &self.footprint)
.field("varargs", &self.varargs)
Expand All @@ -269,8 +269,8 @@ impl Default for OwnedContextImpl {
}
}

impl core::hash::Hash for OwnedContextImpl {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
impl std::hash::Hash for OwnedContextImpl {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.footprint.hash(state);
self.varargs.as_ref().map(|x| Arc::as_ptr(x).addr()).hash(state);
self.parent.as_ref().map(|x| Arc::as_ptr(x).addr()).hash(state);
Expand Down Expand Up @@ -348,7 +348,7 @@ impl OwnedContextImpl {

#[derive(Default, Clone, Copy, dyn_any::DynAny)]
pub struct ContextImpl<'a> {
pub(crate) footprint: Option<&'a crate::transform::Footprint>,
pub(crate) footprint: Option<&'a Footprint>,
varargs: Option<&'a [DynRef<'a>]>,
// This could be converted into a single enum to save extra bytes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the owned context should be moved out of the context file, the rest should if possible remain no std

Copy link
Collaborator Author

@Firestar99 Firestar99 Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comment confuses me. This PR doesn't move anything, it just changes the paths to symbols for things within the crate, to make all the absolute paths and use statements use std instead of core or alloc. I'll start extracting a no_std crate gcore_types out of the gcore crate in some later PR, yet to be submitted. And can change all the symbols back to core, as required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a future note to you that you will need to split this file into two versions, one which uses std (and containts the OwnedContextImpl) and a second one which contains the rest so you'll have to change the paths you've converted to std in this file for this pr back to core

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was a change request and was confused at what you wanted to have changed. All good if it was just a note :D

index: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion node-graph/gcore/src/generic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Node;
use core::marker::PhantomData;
use std::marker::PhantomData;
#[derive(Clone)]
pub struct FnNode<T: Fn(I) -> O, I, O>(T, PhantomData<(I, O)>);

Expand Down
4 changes: 2 additions & 2 deletions node-graph/gcore/src/graphic_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl Default for AlphaBlending {
Self::new()
}
}
impl core::hash::Hash for AlphaBlending {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
impl Hash for AlphaBlending {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.opacity.to_bits().hash(state);
self.fill.to_bits().hash(state);
self.blend_mode.hash(state);
Expand Down
24 changes: 12 additions & 12 deletions node-graph/gcore/src/graphic_element/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl FreePoint {

#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum ClickTargetType {
Subpath(bezier_rs::Subpath<PointId>),
Subpath(Subpath<PointId>),
FreePoint(FreePoint),
}

Expand Down Expand Up @@ -75,7 +75,7 @@ impl MaskType {
}

impl ClickTarget {
pub fn new_with_subpath(subpath: bezier_rs::Subpath<PointId>, stroke_width: f64) -> Self {
pub fn new_with_subpath(subpath: Subpath<PointId>, stroke_width: f64) -> Self {
let bounding_box = subpath.loose_bounding_box();
Self {
target_type: ClickTargetType::Subpath(subpath),
Expand Down Expand Up @@ -300,7 +300,7 @@ impl Default for SvgRender {
#[derive(Clone, Debug, Default)]
pub struct RenderContext {
#[cfg(feature = "wgpu")]
pub resource_overrides: std::collections::HashMap<u64, alloc::sync::Arc<wgpu::Texture>>,
pub resource_overrides: HashMap<u64, std::sync::Arc<wgpu::Texture>>,
}

/// Static state used whilst rendering
Expand Down Expand Up @@ -468,7 +468,7 @@ impl GraphicElementRendered for GraphicGroupTable {
peniko::BlendMode::new(blend_mode, peniko::Compose::SrcOver),
opacity,
kurbo::Affine::IDENTITY,
&vello::kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y),
&kurbo::Rect::new(bounds[0].x, bounds[0].y, bounds[1].x, bounds[1].y),
);
layer = true;
}
Expand Down Expand Up @@ -756,9 +756,9 @@ impl GraphicElementRendered for VectorDataTable {
let outline_stroke = kurbo::Stroke {
width: LAYER_OUTLINE_STROKE_WEIGHT,
miter_limit: 4.,
join: kurbo::Join::Miter,
start_cap: kurbo::Cap::Butt,
end_cap: kurbo::Cap::Butt,
join: Join::Miter,
start_cap: Cap::Butt,
end_cap: Cap::Butt,
dash_pattern: Default::default(),
dash_offset: 0.,
};
Expand Down Expand Up @@ -913,7 +913,7 @@ impl GraphicElementRendered for VectorDataTable {
if let Some(element_id) = element_id {
let stroke_width = instance.style.stroke().as_ref().map_or(0., Stroke::weight);
let filled = instance.style.fill() != &Fill::None;
let fill = |mut subpath: bezier_rs::Subpath<_>| {
let fill = |mut subpath: Subpath<_>| {
if filled {
subpath.set_closed(true);
}
Expand Down Expand Up @@ -953,7 +953,7 @@ impl GraphicElementRendered for VectorDataTable {
for instance in self.instance_ref_iter() {
let stroke_width = instance.instance.style.stroke().as_ref().map_or(0., Stroke::weight);
let filled = instance.instance.style.fill() != &Fill::None;
let fill = |mut subpath: bezier_rs::Subpath<_>| {
let fill = |mut subpath: Subpath<_>| {
if filled {
subpath.set_closed(true);
}
Expand Down Expand Up @@ -1186,10 +1186,10 @@ impl GraphicElementRendered for RasterDataTable<CPU> {
if image.data.is_empty() {
return;
}
let image = vello::peniko::Image::new(image.to_flat_u8().0.into(), peniko::Format::Rgba8, image.width, image.height).with_extend(peniko::Extend::Repeat);
let image = peniko::Image::new(image.to_flat_u8().0.into(), peniko::Format::Rgba8, image.width, image.height).with_extend(peniko::Extend::Repeat);
let transform = transform * *instance.transform * DAffine2::from_scale(1. / DVec2::new(image.width as f64, image.height as f64));

scene.draw_image(&image, vello::kurbo::Affine::new(transform.to_cols_array()));
scene.draw_image(&image, kurbo::Affine::new(transform.to_cols_array()));
}
}

Expand Down Expand Up @@ -1385,7 +1385,7 @@ impl GraphicElementRendered for GraphicElement {
}

/// Used to stop rust complaining about upstream traits adding display implementations to `Option<Color>`. This would not be an issue as we control that crate.
trait Primitive: core::fmt::Display {}
trait Primitive: std::fmt::Display {}
impl Primitive for String {}
impl Primitive for bool {}
impl Primitive for f32 {}
Expand Down
2 changes: 1 addition & 1 deletion node-graph/gcore/src/graphic_element/renderer/quad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Quad {
}
}

impl core::ops::Mul<Quad> for DAffine2 {
impl std::ops::Mul<Quad> for DAffine2 {
type Output = Quad;

fn mul(self, rhs: Quad) -> Self::Output {
Expand Down
10 changes: 5 additions & 5 deletions node-graph/gcore/src/graphic_element/renderer/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ impl Rect {
}
}

impl core::ops::Mul<Rect> for DAffine2 {
type Output = super::Quad;
impl std::ops::Mul<Rect> for DAffine2 {
type Output = Quad;

fn mul(self, rhs: Rect) -> Self::Output {
self * super::Quad::from_box(rhs.0)
self * Quad::from_box(rhs.0)
}
}

impl core::ops::Index<usize> for Rect {
impl std::ops::Index<usize> for Rect {
type Output = DVec2;
fn index(&self, index: usize) -> &Self::Output {
&self.0[index]
}
}
impl core::ops::IndexMut<usize> for Rect {
impl std::ops::IndexMut<usize> for Rect {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
&mut self.0[index]
}
Expand Down
4 changes: 2 additions & 2 deletions node-graph/gcore/src/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ impl<T> Default for Instances<T> {
}
}

impl<T: Hash> core::hash::Hash for Instances<T> {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
impl<T: Hash> Hash for Instances<T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
for instance in &self.instance {
instance.hash(state);
}
Expand Down
28 changes: 13 additions & 15 deletions node-graph/gcore/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
extern crate alloc;

#[macro_use]
extern crate log;
pub use crate as graphene_core;
pub use num_traits;

pub use crate as graphene_core;
pub use ctor;
pub use num_traits;

pub mod animation;
pub mod consts;
Expand Down Expand Up @@ -35,12 +33,12 @@ pub mod application_io;
pub mod registry;

pub use context::*;
use core::any::TypeId;
use core::future::Future;
use core::pin::Pin;
pub use dyn_any::{StaticTypeSized, WasmNotSend, WasmNotSync};
pub use memo::MemoHash;
pub use raster::Color;
use std::any::TypeId;
use std::future::Future;
use std::pin::Pin;
pub use types::Cow;

// pub trait Node: for<'n> NodeIO<'n> {
Expand All @@ -54,11 +52,11 @@ pub trait Node<'i, Input> {
fn reset(&self) {}
/// Returns the name of the node for diagnostic purposes.
fn node_name(&self) -> &'static str {
core::any::type_name::<Self>()
std::any::type_name::<Self>()
}
/// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes.
fn serialize(&self) -> Option<std::sync::Arc<dyn core::any::Any + Send + Sync>> {
log::warn!("Node::serialize not implemented for {}", core::any::type_name::<Self>());
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
log::warn!("Node::serialize not implemented for {}", std::any::type_name::<Self>());
None
}
}
Expand All @@ -75,13 +73,13 @@ where
TypeId::of::<Input::Static>()
}
fn input_type_name(&self) -> &'static str {
core::any::type_name::<Input>()
std::any::type_name::<Input>()
}
fn output_type(&self) -> core::any::TypeId {
fn output_type(&self) -> TypeId {
TypeId::of::<<Self::Output as StaticTypeSized>::Static>()
}
fn output_type_name(&self) -> &'static str {
core::any::type_name::<Self::Output>()
std::any::type_name::<Self::Output>()
}
fn to_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes {
NodeIOTypes {
Expand Down Expand Up @@ -122,7 +120,7 @@ impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box<
(**self).eval(input)
}
}
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc<N> {
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for std::sync::Arc<N> {
type Output = O;
fn eval(&'i self, input: I) -> O {
(**self).eval(input)
Expand All @@ -148,7 +146,7 @@ pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasEl
#[cfg(feature = "wasm")]
pub type WasmSurfaceHandleFrame = application_io::SurfaceHandleFrame<web_sys::HtmlCanvasElement>;

pub trait InputAccessorSource<'a, T>: InputAccessorSourceIdentifier + core::fmt::Debug {
pub trait InputAccessorSource<'a, T>: InputAccessorSourceIdentifier + std::fmt::Debug {
fn get_input(&'a self, index: usize) -> Option<&'a T>;
fn set_input(&'a mut self, index: usize, value: T);
}
Expand Down
5 changes: 2 additions & 3 deletions node-graph/gcore/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ use crate::{Color, Context, Ctx};
use glam::{DAffine2, DVec2};

#[node_macro::node(category("Debug"))]
fn log_to_console<T: core::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2, Color, Option<Color>)] value: T) -> T {
#[cfg(not(target_arch = "spirv"))]
fn log_to_console<T: std::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2, Color, Option<Color>)] value: T) -> T {
// KEEP THIS `debug!()` - It acts as the output for the debug node itself
log::debug!("{:#?}", value);
value
}

#[node_macro::node(category("Text"))]
fn to_string<T: core::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2)] value: T) -> String {
fn to_string<T: std::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2)] value: T) -> String {
format!("{:?}", value)
}

Expand Down
Loading
Loading