mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 15:08:12 +08:00
Graphene CLI + quantization research (#1320)
* Implement skeleton for graphene-cli * Configure gpu surface on non wasm32 targets * Create window with full hd size * Create window using the graphen-cli * Use window size for surface creation * Reuse surface configuration * Reduce window size for native applications to 800x600 * Add compute pipeline test * Poll wgpu execution externally * Remove cache node after texture upload * Add profiling instructions * Add more debug markers * Evaluate extract node before flattening the network * Reenable hue saturation node for compilation * Make hue saturation node work on the gpu + make f32 default for user inputs * Add version of test files without caching * Only dispatch each workgroup not pixel * ICE * Add quantization to gpu code * Fix quantization * Load images at graph runtime * Fix quantization calculation * Feature gate quantization * Use git version of autoquant * Add license to `graphene-cli` * Fix graphene-cli test case * Ignore tests on non unix platforms * Fix flattening test
This commit is contained in:
committed by
Keavon Chambers
parent
61c5dd1f88
commit
3c2d371173
+3
-3
@@ -111,12 +111,12 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
fn stroke_set(&mut self, stroke: Stroke) {
|
||||
self.modify_inputs("Stroke", false, |inputs| {
|
||||
inputs[1] = NodeInput::value(TaggedValue::OptionalColor(stroke.color), false);
|
||||
inputs[2] = NodeInput::value(TaggedValue::F64(stroke.weight), false);
|
||||
inputs[2] = NodeInput::value(TaggedValue::F32(stroke.weight as f32), false);
|
||||
inputs[3] = NodeInput::value(TaggedValue::VecF32(stroke.dash_lengths), false);
|
||||
inputs[4] = NodeInput::value(TaggedValue::F64(stroke.dash_offset), false);
|
||||
inputs[4] = NodeInput::value(TaggedValue::F32(stroke.dash_offset as f32), false);
|
||||
inputs[5] = NodeInput::value(TaggedValue::LineCap(stroke.line_cap), false);
|
||||
inputs[6] = NodeInput::value(TaggedValue::LineJoin(stroke.line_join), false);
|
||||
inputs[7] = NodeInput::value(TaggedValue::F64(stroke.line_join_miter_limit), false);
|
||||
inputs[7] = NodeInput::value(TaggedValue::F32(stroke.line_join_miter_limit as f32), false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ pub fn update_transform(inputs: &mut [NodeInput], transform: DAffine2) {
|
||||
let (scale, angle, translation, shear) = compute_scale_angle_translation_shear(transform);
|
||||
|
||||
inputs[1] = NodeInput::value(TaggedValue::DVec2(translation), false);
|
||||
inputs[2] = NodeInput::value(TaggedValue::F64(angle), false);
|
||||
inputs[2] = NodeInput::value(TaggedValue::F32(angle as f32), false);
|
||||
inputs[3] = NodeInput::value(TaggedValue::DVec2(scale), false);
|
||||
inputs[4] = NodeInput::value(TaggedValue::DVec2(shear), false);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ pub fn get_current_transform(inputs: &[NodeInput]) -> DAffine2 {
|
||||
};
|
||||
|
||||
let angle = if let NodeInput::Value {
|
||||
tagged_value: TaggedValue::F64(angle),
|
||||
tagged_value: TaggedValue::F32(angle),
|
||||
..
|
||||
} = inputs[2]
|
||||
{
|
||||
@@ -116,7 +116,7 @@ pub fn get_current_transform(inputs: &[NodeInput]) -> DAffine2 {
|
||||
DVec2::ZERO
|
||||
};
|
||||
|
||||
DAffine2::from_scale_angle_translation(scale, angle, translation) * DAffine2::from_cols_array(&[1., shear.y, shear.x, 1., 0., 0.])
|
||||
DAffine2::from_scale_angle_translation(scale, angle as f64, translation) * DAffine2::from_cols_array(&[1., shear.y, shear.x, 1., 0., 0.])
|
||||
}
|
||||
|
||||
/// Extract the current normalized pivot from the layer
|
||||
|
||||
+149
-119
@@ -254,6 +254,50 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
}],
|
||||
properties: node_properties::input_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Load Image",
|
||||
category: "Structural",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![0, 0],
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Load Resource".to_string(),
|
||||
inputs: vec![NodeInput::Network(concrete!(WasmEditorApi)), NodeInput::Network(concrete!(String))],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::wasm_application_io::LoadResourceNode<_>")),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Decode Image".to_string(),
|
||||
inputs: vec![NodeInput::node(0, 0)],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::wasm_application_io::DecodeImageNode")),
|
||||
..Default::default()
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(id, node)| (id as NodeId, node))
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}),
|
||||
inputs: vec![
|
||||
DocumentInputType {
|
||||
name: "api",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::Network(concrete!(WasmEditorApi)),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "path",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
default: NodeInput::value(TaggedValue::String("graphite:null".to_string()), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType {
|
||||
name: "Image Frame",
|
||||
data_type: FrontendGraphDataType::Raster,
|
||||
}],
|
||||
properties: node_properties::load_image_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Create Canvas",
|
||||
category: "Structural",
|
||||
@@ -289,7 +333,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
name: "Canvas",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
}],
|
||||
properties: node_properties::input_properties,
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Draw Canvas",
|
||||
@@ -345,7 +389,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
name: "Canvas",
|
||||
data_type: FrontendGraphDataType::General,
|
||||
}],
|
||||
properties: node_properties::input_properties,
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Begin Scope",
|
||||
@@ -490,7 +534,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Second", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("BlendMode", TaggedValue::BlendMode(BlendMode::Normal), false),
|
||||
DocumentInputType::value("Opacity", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("Opacity", TaggedValue::F32(100.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::blend_properties,
|
||||
@@ -508,27 +552,27 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
DocumentInputType {
|
||||
name: "Shadows",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(0.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(0.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Midtones",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(50.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(50.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Highlights",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(100.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(100.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Output Minimums",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(0.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(0.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Output Maximums",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(100.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(100.), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
@@ -552,32 +596,32 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
DocumentInputType {
|
||||
name: "Reds",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(40.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(40.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Yellows",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(60.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(60.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Greens",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(40.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(40.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Cyans",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(60.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(60.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Blues",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(20.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(20.), false),
|
||||
},
|
||||
DocumentInputType {
|
||||
name: "Magentas",
|
||||
data_type: FrontendGraphDataType::Number,
|
||||
default: NodeInput::value(TaggedValue::F64(80.), false),
|
||||
default: NodeInput::value(TaggedValue::F32(80.), false),
|
||||
},
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
@@ -713,7 +757,10 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
name: "Memoize",
|
||||
category: "Structural",
|
||||
identifier: NodeImplementation::proto("graphene_core::memo::MemoNode<_, _>"),
|
||||
inputs: vec![DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true)],
|
||||
inputs: vec![
|
||||
DocumentInputType::value("ShortCircut", TaggedValue::None, false),
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::no_properties,
|
||||
},
|
||||
@@ -1136,7 +1183,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
category: "Gpu",
|
||||
identifier: NodeImplementation::DocumentNode(NodeNetwork {
|
||||
inputs: vec![1, 1, 0],
|
||||
outputs: vec![NodeOutput::new(2, 0)],
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Extract Executor".to_string(),
|
||||
@@ -1154,12 +1201,6 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("gpu_executor::RenderTextureNode<_, _>")),
|
||||
..Default::default()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Cache".to_string(),
|
||||
inputs: vec![NodeInput::ShortCircut(concrete!(())), NodeInput::node(1, 0)],
|
||||
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
|
||||
..Default::default()
|
||||
},
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
@@ -1367,9 +1408,9 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::HueSaturationNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Hue Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Saturation Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Lightness Shift", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Hue Shift", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Saturation Shift", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Lightness Shift", TaggedValue::F32(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_hsl_properties,
|
||||
@@ -1380,8 +1421,8 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::BrightnessContrastNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Brightness", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Contrast", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Brightness", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Contrast", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Use Legacy", TaggedValue::Bool(false), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
@@ -1393,8 +1434,8 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ThresholdNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Min Luminance", TaggedValue::F64(50.), false),
|
||||
DocumentInputType::value("Max Luminance", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("Min Luminance", TaggedValue::F32(50.), false),
|
||||
DocumentInputType::value("Max Luminance", TaggedValue::F32(100.), false),
|
||||
DocumentInputType::value("Luminance Calc", TaggedValue::LuminanceCalculation(LuminanceCalculation::SRGB), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
@@ -1406,7 +1447,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::VibranceNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Vibrance", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Vibrance", TaggedValue::F32(0.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::adjust_vibrance_properties,
|
||||
@@ -1420,25 +1461,25 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
// Monochrome toggle
|
||||
DocumentInputType::value("Monochrome", TaggedValue::Bool(false), false),
|
||||
// Monochrome
|
||||
DocumentInputType::value("Red", TaggedValue::F64(40.), false),
|
||||
DocumentInputType::value("Green", TaggedValue::F64(40.), false),
|
||||
DocumentInputType::value("Blue", TaggedValue::F64(20.), false),
|
||||
DocumentInputType::value("Constant", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Red", TaggedValue::F32(40.), false),
|
||||
DocumentInputType::value("Green", TaggedValue::F32(40.), false),
|
||||
DocumentInputType::value("Blue", TaggedValue::F32(20.), false),
|
||||
DocumentInputType::value("Constant", TaggedValue::F32(0.), false),
|
||||
// Red output channel
|
||||
DocumentInputType::value("(Red) Red", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("(Red) Green", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Red) Blue", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Red) Constant", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Red) Red", TaggedValue::F32(100.), false),
|
||||
DocumentInputType::value("(Red) Green", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Red) Blue", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Red) Constant", TaggedValue::F32(0.), false),
|
||||
// Green output channel
|
||||
DocumentInputType::value("(Green) Red", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Green) Green", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("(Green) Blue", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Green) Constant", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Green) Red", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Green) Green", TaggedValue::F32(100.), false),
|
||||
DocumentInputType::value("(Green) Blue", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Green) Constant", TaggedValue::F32(0.), false),
|
||||
// Blue output channel
|
||||
DocumentInputType::value("(Blue) Red", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blue) Green", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blue) Blue", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("(Blue) Constant", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blue) Red", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blue) Green", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blue) Blue", TaggedValue::F32(100.), false),
|
||||
DocumentInputType::value("(Blue) Constant", TaggedValue::F32(0.), false),
|
||||
// Display-only properties (not used within the node)
|
||||
DocumentInputType::value("Output Channel", TaggedValue::RedGreenBlue(RedGreenBlue::Red), false),
|
||||
],
|
||||
@@ -1456,50 +1497,50 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
// Mode
|
||||
DocumentInputType::value("Mode", TaggedValue::RelativeAbsolute(RelativeAbsolute::Relative), false),
|
||||
// Reds
|
||||
DocumentInputType::value("(Reds) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Reds) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Reds) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Reds) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Reds) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Reds) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Reds) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Reds) Black", TaggedValue::F32(0.), false),
|
||||
// Yellows
|
||||
DocumentInputType::value("(Yellows) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Yellows) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Yellows) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Yellows) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Yellows) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Yellows) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Yellows) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Yellows) Black", TaggedValue::F32(0.), false),
|
||||
// Greens
|
||||
DocumentInputType::value("(Greens) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Greens) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Greens) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Greens) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Greens) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Greens) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Greens) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Greens) Black", TaggedValue::F32(0.), false),
|
||||
// Cyans
|
||||
DocumentInputType::value("(Cyans) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Cyans) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Cyans) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Cyans) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Cyans) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Cyans) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Cyans) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Cyans) Black", TaggedValue::F32(0.), false),
|
||||
// Blues
|
||||
DocumentInputType::value("(Blues) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blues) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blues) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blues) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blues) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blues) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blues) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blues) Black", TaggedValue::F32(0.), false),
|
||||
// Magentas
|
||||
DocumentInputType::value("(Magentas) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Magentas) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Magentas) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Magentas) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Magentas) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Magentas) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Magentas) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Magentas) Black", TaggedValue::F32(0.), false),
|
||||
// Whites
|
||||
DocumentInputType::value("(Whites) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Whites) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Whites) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Whites) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Whites) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Whites) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Whites) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Whites) Black", TaggedValue::F32(0.), false),
|
||||
// Neutrals
|
||||
DocumentInputType::value("(Neutrals) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Neutrals) Black", TaggedValue::F32(0.), false),
|
||||
// Blacks
|
||||
DocumentInputType::value("(Blacks) Cyan", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blacks) Magenta", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blacks) Yellow", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blacks) Black", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("(Blacks) Cyan", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blacks) Magenta", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blacks) Yellow", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("(Blacks) Black", TaggedValue::F32(0.), false),
|
||||
// Display-only properties (not used within the node)
|
||||
DocumentInputType::value("Colors", TaggedValue::SelectiveColorChoice(SelectiveColorChoice::Reds), false),
|
||||
],
|
||||
@@ -1512,7 +1553,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::OpacityNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Factor", TaggedValue::F64(100.), false),
|
||||
DocumentInputType::value("Factor", TaggedValue::F32(100.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::multiply_opacity,
|
||||
@@ -1523,7 +1564,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::PosterizeNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Value", TaggedValue::F64(4.), false),
|
||||
DocumentInputType::value("Value", TaggedValue::F32(4.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::posterize_properties,
|
||||
@@ -1534,9 +1575,9 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ExposureNode<_, _, _>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Exposure", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Offset", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Gamma Correction", TaggedValue::F64(1.), false),
|
||||
DocumentInputType::value("Exposure", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Offset", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Gamma Correction", TaggedValue::F32(1.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Image", FrontendGraphDataType::Raster)],
|
||||
properties: node_properties::exposure_properties,
|
||||
@@ -1546,8 +1587,8 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
category: "Math",
|
||||
identifier: NodeImplementation::proto("graphene_core::ops::AddParameterNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Input", TaggedValue::F64(0.), true),
|
||||
DocumentInputType::value("Addend", TaggedValue::F64(0.), true),
|
||||
DocumentInputType::value("Input", TaggedValue::F32(0.), true),
|
||||
DocumentInputType::value("Addend", TaggedValue::F32(0.), true),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Output", FrontendGraphDataType::Number)],
|
||||
properties: node_properties::add_properties,
|
||||
@@ -1580,7 +1621,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
DocumentInputType::none(),
|
||||
DocumentInputType::value("Text", TaggedValue::String("hello world".to_string()), false),
|
||||
DocumentInputType::value("Font", TaggedValue::Font(Font::new(DEFAULT_FONT_FAMILY.into(), DEFAULT_FONT_STYLE.into())), false),
|
||||
DocumentInputType::value("Size", TaggedValue::F64(24.), false),
|
||||
DocumentInputType::value("Size", TaggedValue::F32(24.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::node_section_font,
|
||||
@@ -1592,7 +1633,7 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Data", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
DocumentInputType::value("Translation", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
DocumentInputType::value("Rotation", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Rotation", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Scale", TaggedValue::DVec2(DVec2::ONE), false),
|
||||
DocumentInputType::value("Skew", TaggedValue::DVec2(DVec2::ZERO), false),
|
||||
DocumentInputType::value("Pivot", TaggedValue::DVec2(DVec2::splat(0.5)), false),
|
||||
@@ -1635,12 +1676,12 @@ fn static_nodes() -> Vec<DocumentNodeType> {
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Vector Data", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
DocumentInputType::value("Color", TaggedValue::OptionalColor(Some(Color::BLACK)), false),
|
||||
DocumentInputType::value("Weight", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Weight", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Dash Lengths", TaggedValue::VecF32(Vec::new()), false),
|
||||
DocumentInputType::value("Dash Offset", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::value("Dash Offset", TaggedValue::F32(0.), false),
|
||||
DocumentInputType::value("Line Cap", TaggedValue::LineCap(graphene_core::vector::style::LineCap::Butt), false),
|
||||
DocumentInputType::value("Line Join", TaggedValue::LineJoin(graphene_core::vector::style::LineJoin::Miter), false),
|
||||
DocumentInputType::value("Miter Limit", TaggedValue::F64(4.), false),
|
||||
DocumentInputType::value("Miter Limit", TaggedValue::F32(4.), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
properties: node_properties::stroke_properties,
|
||||
@@ -1727,18 +1768,18 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
|
||||
default: NodeInput::Network(concrete!(WasmEditorApi)),
|
||||
},
|
||||
DocumentInputType::value("Controller", TaggedValue::ImaginateController(Default::default()), false),
|
||||
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::value("Seed", TaggedValue::F32(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::value("Resolution", TaggedValue::OptionalDVec2(None), false),
|
||||
DocumentInputType::value("Samples", TaggedValue::U32(30), false),
|
||||
DocumentInputType::value("Sampling Method", TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),
|
||||
DocumentInputType::value("Prompt Guidance", TaggedValue::F64(7.5), false),
|
||||
DocumentInputType::value("Prompt Guidance", TaggedValue::F32(7.5), false),
|
||||
DocumentInputType::value("Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::value("Negative Prompt", TaggedValue::String(String::new()), false),
|
||||
DocumentInputType::value("Adapt Input Image", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::value("Image Creativity", TaggedValue::F64(66.), false),
|
||||
DocumentInputType::value("Image Creativity", TaggedValue::F32(66.), false),
|
||||
DocumentInputType::value("Masking Layer", TaggedValue::LayerPath(None), false),
|
||||
DocumentInputType::value("Inpaint", TaggedValue::Bool(true), false),
|
||||
DocumentInputType::value("Mask Blur", TaggedValue::F64(4.), false),
|
||||
DocumentInputType::value("Mask Blur", TaggedValue::F32(4.), false),
|
||||
DocumentInputType::value("Mask Starting Fill", TaggedValue::ImaginateMaskStartingFill(ImaginateMaskStartingFill::Fill), false),
|
||||
DocumentInputType::value("Improve Faces", TaggedValue::Bool(false), false),
|
||||
DocumentInputType::value("Tiling", TaggedValue::Bool(false), false),
|
||||
@@ -1767,7 +1808,9 @@ impl DocumentNodeType {
|
||||
|
||||
let inner_network = match &self.identifier {
|
||||
NodeImplementation::DocumentNode(network) => network.clone(),
|
||||
NodeImplementation::ProtoNode(ident) => {
|
||||
|
||||
NodeImplementation::ProtoNode(ident) => return DocumentNodeImplementation::Unresolved(ident.clone()),
|
||||
/*
|
||||
NodeNetwork {
|
||||
inputs: (0..num_inputs).map(|_| 0).collect(),
|
||||
outputs: vec![NodeOutput::new(0, 0)],
|
||||
@@ -1785,23 +1828,10 @@ impl DocumentNodeType {
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}
|
||||
|
||||
}
|
||||
NodeImplementation::Extract => NodeNetwork {
|
||||
inputs: (0..num_inputs).map(|_| 0).collect(),
|
||||
outputs: vec![NodeOutput::new(0, 0)],
|
||||
nodes: [(
|
||||
0,
|
||||
DocumentNode {
|
||||
name: "ExtractNode".to_string(),
|
||||
implementation: DocumentNodeImplementation::Extract,
|
||||
inputs: self.inputs.iter().map(|i| NodeInput::Network(i.default.ty())).collect(),
|
||||
..Default::default()
|
||||
},
|
||||
)]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
..Default::default()
|
||||
},
|
||||
*/
|
||||
NodeImplementation::Extract => return DocumentNodeImplementation::Extract,
|
||||
};
|
||||
|
||||
DocumentNodeImplementation::Network(inner_network)
|
||||
@@ -1830,9 +1860,9 @@ impl DocumentNodeType {
|
||||
}
|
||||
|
||||
pub fn wrap_network_in_scope(mut network: NodeNetwork) -> NodeNetwork {
|
||||
let node_ids = network.nodes.keys().copied().collect::<Vec<_>>();
|
||||
|
||||
network.generate_node_paths(&[]);
|
||||
|
||||
let node_ids = network.nodes.keys().copied().collect::<Vec<_>>();
|
||||
for id in node_ids {
|
||||
network.flatten(id);
|
||||
}
|
||||
@@ -1927,7 +1957,7 @@ pub fn new_vector_network(subpaths: Vec<bezier_rs::Subpath<uuid::ManipulatorGrou
|
||||
network
|
||||
}
|
||||
|
||||
pub fn new_text_network(text: String, font: Font, size: f64) -> NodeNetwork {
|
||||
pub fn new_text_network(text: String, font: Font, size: f32) -> NodeNetwork {
|
||||
let text_generator = resolve_document_node_type("Text").expect("Text node does not exist");
|
||||
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist");
|
||||
let fill = resolve_document_node_type("Fill").expect("Fill node does not exist");
|
||||
@@ -1944,7 +1974,7 @@ pub fn new_text_network(text: String, font: Font, size: f64) -> NodeNetwork {
|
||||
NodeInput::Network(concrete!(WasmEditorApi)),
|
||||
NodeInput::value(TaggedValue::String(text), false),
|
||||
NodeInput::value(TaggedValue::Font(font), false),
|
||||
NodeInput::value(TaggedValue::F64(size), false),
|
||||
NodeInput::value(TaggedValue::F32(size), false),
|
||||
],
|
||||
DocumentNodeMetadata::position((0, 4)),
|
||||
),
|
||||
|
||||
+6
@@ -624,6 +624,12 @@ pub fn blend_properties(document_node: &DocumentNode, node_id: NodeId, _context:
|
||||
vec![backdrop, blend_mode, LayoutGroup::Row { widgets: opacity }]
|
||||
}
|
||||
|
||||
pub fn load_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let url = text_widget(document_node, node_id, 1, "Url", true);
|
||||
|
||||
vec![LayoutGroup::Row { widgets: url }]
|
||||
}
|
||||
|
||||
pub fn output_properties(_document_node: &DocumentNode, _node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let output_type = context.executor.previous_output_type(context.layer_path);
|
||||
let raster_output_type = concrete!(ImageFrame<Color>);
|
||||
|
||||
@@ -319,7 +319,7 @@ impl TextToolData {
|
||||
else if let Some(editing_text) = self.editing_text.as_ref().filter(|_| state == TextToolFsmState::Ready) {
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let network = new_text_network(String::new(), editing_text.font.clone(), editing_text.font_size);
|
||||
let network = new_text_network(String::new(), editing_text.font.clone(), editing_text.font_size as f32);
|
||||
|
||||
responses.add(Operation::AddFrame {
|
||||
path: self.layer_path.clone(),
|
||||
|
||||
Reference in New Issue
Block a user