mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 14:18:11 +08:00
Add node input type support for f32 to enable usage on GPU (#3095)
* update Cargo.lock * f32: switch to f32 params * f32: more f32 params, remove f32 casts * f32: property support for f32 * f32: fix test `stable_node_id_generation` * Fix f32 properties * Fix f32 frontend data types * Rename TaggedValue::Vec2 to ::FVec2 and ::Affine2 to ::FAffine2 --------- Co-authored-by: hypercube <0hypercube@gmail.com> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
hypercube
Keavon Chambers
parent
a199a5fd64
commit
82784b46a0
@@ -8,7 +8,7 @@ use graphene_core::table::Table;
|
||||
use graphene_core_shaders::Ctx;
|
||||
use graphene_core_shaders::blending::BlendMode;
|
||||
use graphene_core_shaders::color::{Color, Pixel};
|
||||
use graphene_core_shaders::registry::types::Percentage;
|
||||
use graphene_core_shaders::registry::types::PercentageF32;
|
||||
|
||||
pub trait Blend<P: Pixel> {
|
||||
fn blend(&self, under: &Self, blend_fn: impl Fn(P, P) -> P) -> Self;
|
||||
@@ -81,7 +81,7 @@ mod blend_std {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn blend_colors(foreground: Color, background: Color, blend_mode: BlendMode, opacity: f64) -> Color {
|
||||
pub fn blend_colors(foreground: Color, background: Color, blend_mode: BlendMode, opacity: f32) -> Color {
|
||||
let target_color = match blend_mode {
|
||||
// Other utility blend modes (hidden from the normal list) - do not have alpha blend
|
||||
BlendMode::Erase => return background.alpha_subtract(foreground),
|
||||
@@ -151,7 +151,7 @@ fn blend<T: Blend<Color> + Send>(
|
||||
)]
|
||||
under: T,
|
||||
blend_mode: BlendMode,
|
||||
#[default(100.)] opacity: Percentage,
|
||||
#[default(100.)] opacity: PercentageF32,
|
||||
) -> T {
|
||||
over.blend(&under, |a, b| blend_colors(a, b, blend_mode, opacity / 100.))
|
||||
}
|
||||
@@ -168,7 +168,7 @@ fn color_overlay<T: Adjust<Color>>(
|
||||
mut image: T,
|
||||
#[default(Color::BLACK)] color: Table<Color>,
|
||||
blend_mode: BlendMode,
|
||||
#[default(100.)] opacity: Percentage,
|
||||
#[default(100.)] opacity: PercentageF32,
|
||||
) -> T {
|
||||
let opacity = (opacity as f32 / 100.).clamp(0., 1.);
|
||||
|
||||
@@ -204,7 +204,7 @@ mod test {
|
||||
let overlay_color = Color::GREEN;
|
||||
|
||||
// 100% of the output should come from the multiplied value
|
||||
let opacity = 100_f64;
|
||||
let opacity = 100.;
|
||||
|
||||
let result = super::color_overlay(
|
||||
(),
|
||||
|
||||
Reference in New Issue
Block a user