mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Shaders: more graster-nodes no-std fixups (#3090)
* gcore-shaders: fix missing `num-traits/libm` features * graster-nodes: fix missing cfg on use statements * shaders: use unchecked Color constructors * graster-nodes: remove async from shader nodes not needing it * gcore-shaders: remove explicit fn pointer * graster-nodes: make kurbo std-only * graster-nodes: replace glam reexport with normal dep * gcore: impl Display for ProtoNodeIdentifier * unify glam workspace dep
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use core::fmt::Display;
|
||||
use core::hash::{Hash, Hasher};
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::Float;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
|
||||
@@ -3,7 +3,7 @@ use bytemuck::{Pod, Zeroable};
|
||||
use core::fmt::Debug;
|
||||
use glam::DVec2;
|
||||
use num_derive::*;
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::Float;
|
||||
|
||||
pub trait Linear {
|
||||
|
||||
@@ -4,9 +4,9 @@ use bytemuck::{Pod, Zeroable};
|
||||
use core::fmt::Debug;
|
||||
use core::hash::Hash;
|
||||
use half::f16;
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::Euclid;
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::Float;
|
||||
|
||||
#[repr(C)]
|
||||
@@ -439,9 +439,9 @@ impl Color {
|
||||
lightness + saturation - lightness * saturation
|
||||
};
|
||||
let temp2 = 2. * lightness - temp1;
|
||||
#[cfg(not(target_arch = "spirv"))]
|
||||
#[cfg(feature = "std")]
|
||||
let rem = |x: f32| x.rem_euclid(1.);
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
let rem = |x: f32| x.rem_euclid(&1.);
|
||||
|
||||
let mut red = rem(hue + 1. / 3.);
|
||||
@@ -700,7 +700,7 @@ impl Color {
|
||||
if c_s <= 0.5 {
|
||||
c_b - (1. - 2. * c_s) * c_b * (1. - c_b)
|
||||
} else {
|
||||
let d: fn(f32) -> f32 = |x| if x <= 0.25 { ((16. * x - 12.) * x + 4.) * x } else { x.sqrt() };
|
||||
let d = |x: f32| if x <= 0.25 { ((16. * x - 12.) * x + 4.) * x } else { x.sqrt() };
|
||||
c_b + (2. * c_s - 1.) * (d(c_b) - c_b)
|
||||
}
|
||||
}
|
||||
@@ -892,9 +892,9 @@ impl Color {
|
||||
} else {
|
||||
4. + (self.red - self.green) / (max_channel - min_channel)
|
||||
} / 6.;
|
||||
#[cfg(not(target_arch = "spirv"))]
|
||||
#[cfg(feature = "std")]
|
||||
let hue = hue.rem_euclid(1.);
|
||||
#[cfg(target_arch = "spirv")]
|
||||
#[cfg(not(feature = "std"))]
|
||||
let hue = hue.rem_euclid(&1.);
|
||||
|
||||
[hue, saturation, lightness, self.alpha]
|
||||
|
||||
Reference in New Issue
Block a user