[Bf-blender-cvs] [34cebfbb78e] temp-geometry-nodes-fields-prototype: progress
Jacques Lucke
noreply at git.blender.org
Wed Jul 28 14:14:19 CEST 2021
Commit: 34cebfbb78e7751ebe9dbd1c157b050b8ca9cbfb
Author: Jacques Lucke
Date: Sat Jul 10 11:22:48 2021 +0200
Branches: temp-geometry-nodes-fields-prototype
https://developer.blender.org/rB34cebfbb78e7751ebe9dbd1c157b050b8ca9cbfb
progress
===================================================================
M source/blender/blenkernel/BKE_field.hh
M source/blender/functions/FN_generic_virtual_array.hh
M source/blender/functions/intern/generic_virtual_array.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_field.hh b/source/blender/blenkernel/BKE_field.hh
index 5d95b73a9ef..c36af5455e4 100644
--- a/source/blender/blenkernel/BKE_field.hh
+++ b/source/blender/blenkernel/BKE_field.hh
@@ -333,9 +333,7 @@ class MultiFunctionField : public GField {
MEM_freeN(span.data());
}
- /* TODO: Transfer ownership of the span. */
- GVArrayPtr varray = std::make_unique<fn::GVArray_For_GSpan>(output_span);
- return varray;
+ return {std::make_unique<fn::GVArray_For_OwnedGSpan>(output_span, mask)};
}
};
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 40dc585b39b..b6b738987e7 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -260,6 +260,23 @@ class GVArray_For_GSpan : public GVArray {
GSpan get_internal_span_impl() const override;
};
+class GVArray_For_OwnedGSpan : public GVArray_For_GSpan {
+ private:
+ IndexMask indices_to_destruct_;
+
+ public:
+ GVArray_For_OwnedGSpan(const GSpan span) : GVArray_For_OwnedGSpan(span, IndexMask(span.size()))
+ {
+ }
+
+ GVArray_For_OwnedGSpan(const GSpan span, IndexMask indices_to_destruct)
+ : GVArray_For_GSpan(span), indices_to_destruct_(indices_to_destruct)
+ {
+ }
+
+ ~GVArray_For_OwnedGSpan();
+};
+
class GVArray_For_Empty : public GVArray {
public:
GVArray_For_Empty(const CPPType &type) : GVArray(type, 0)
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index bd033a429de..8f2023ae8db 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -215,6 +215,16 @@ GSpan GVArray_For_GSpan::get_internal_span_impl() const
return GSpan(*type_, data_, size_);
}
+/* --------------------------------------------------------------------
+ * GVArray_For_OwnedGSpan.
+ */
+
+GVArray_For_OwnedGSpan::~GVArray_For_OwnedGSpan()
+{
+ type_->destruct_indices((void *)data_, indices_to_destruct_);
+ MEM_freeN((void *)data_);
+}
+
/* --------------------------------------------------------------------
* GVMutableArray_For_GMutableSpan.
*/
More information about the Bf-blender-cvs
mailing list