Restructure node graph execution to be safer (#1277)

* Reorganize file structure

* Remove all unsafe code

* Add testcase for debugging ub

* Convert into proper test with fail condition

* General cleanup

* Fix tests

* Add feature guard for deallocation

* Use raw pointer for storing values to avoid violating aliasing rules

* Add comment explaining the disabling of simd128

* Fix brush node

* Fix formatting
This commit is contained in:
Dennis Kobert
2023-06-03 01:18:44 +02:00
committed by Keavon Chambers
parent 5558deba5e
commit 26473a8002
29 changed files with 363 additions and 299 deletions
@@ -1001,10 +1001,6 @@ impl DocumentMessageHandler {
// Calculate the size of the region to be exported and generate an SVG of the artwork below this layer within that region
let transform = self.document_legacy.multiply_transforms(&layer_path).unwrap();
let size = DVec2::new(transform.transform_vector2(DVec2::new(1., 0.)).length(), transform.transform_vector2(DVec2::new(0., 1.)).length());
// TODO: Fix this hack
// This is a hack to prevent the compiler from optimizing out the size calculation which likely is due
// to undefined behavior. THIS IS NOT A FIX.
log::trace!("size: {:?}", size);
let svg = self.render_document(size, transform.inverse(), persistent_data, DocumentRenderMode::OnlyBelowLayerInFolder(&layer_path));
self.restore_document_transform(old_transforms);
@@ -224,11 +224,7 @@ impl<'a> ModifyInputsContext<'a> {
fn brush_modify(&mut self, strokes: Vec<BrushStroke>) {
self.modify_inputs("Brush", false, |inputs| {
if matches!(inputs[0], NodeInput::Node { .. }) {
inputs[1] = core::mem::replace(&mut inputs[0], NodeInput::value(TaggedValue::None, false));
}
inputs[0] = NodeInput::value(TaggedValue::None, false);
inputs[3] = NodeInput::value(TaggedValue::BrushStrokes(strokes), false);
inputs[2] = NodeInput::value(TaggedValue::BrushStrokes(strokes), false);
});
}
}
@@ -669,9 +669,8 @@ fn static_nodes() -> Vec<DocumentNodeType> {
DocumentNodeType {
name: "Brush",
category: "Brush",
identifier: NodeImplementation::proto("graphene_std::brush::BrushNode"),
identifier: NodeImplementation::proto("graphene_std::brush::BrushNode<_, _>"),
inputs: vec![
DocumentInputType::value("None", TaggedValue::None, false),
DocumentInputType::value("Background", TaggedValue::ImageFrame(ImageFrame::empty()), true),
DocumentInputType::value("Bounds", TaggedValue::ImageFrame(ImageFrame::empty()), true),
DocumentInputType::value("Trace", TaggedValue::BrushStrokes(Vec::new()), false),