[Bf-blender-cvs] [a535c074178] spreadsheet-active-node: avoid some copies
Jacques Lucke
noreply at git.blender.org
Wed Mar 31 13:31:15 CEST 2021
Commit: a535c074178a78154cc24fbd140f5130e4f8dd0e
Author: Jacques Lucke
Date: Wed Mar 31 12:24:14 2021 +0200
Branches: spreadsheet-active-node
https://developer.blender.org/rBa535c074178a78154cc24fbd140f5130e4f8dd0e
avoid some copies
===================================================================
M source/blender/blenkernel/BKE_geometry_set.hh
M source/blender/blenkernel/intern/geometry_component_mesh.cc
M source/blender/blenkernel/intern/geometry_set.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index ae0d2daff2d..54f4465b71c 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -141,6 +141,8 @@ class GeometryComponent {
/* The returned component should be of the same type as the type this is called on. */
virtual GeometryComponent *copy() const = 0;
+ /* TODO: Make pure virtual. */
+ virtual bool owns_non_instance_data() const;
virtual void ensure_own_non_instances();
void user_add() const;
@@ -378,6 +380,7 @@ class MeshComponent : public GeometryComponent {
bool is_empty() const final;
+ bool owns_non_instance_data() const override;
void ensure_own_non_instances() override;
static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_MESH;
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 0d6e7ee97f7..4c221d4c992 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -157,6 +157,11 @@ bool MeshComponent::is_empty() const
return mesh_ == nullptr;
}
+bool MeshComponent::owns_non_instance_data() const
+{
+ return ownership_ == GeometryOwnershipType::Owned;
+}
+
void MeshComponent::ensure_own_non_instances()
{
BLI_assert(this->is_mutable());
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index cb1bf4131fe..63d48c31417 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -89,6 +89,11 @@ bool GeometryComponent::is_mutable() const
return users_ <= 1;
}
+bool GeometryComponent::owns_non_instance_data() const
+{
+ return false;
+}
+
void GeometryComponent::ensure_own_non_instances()
{
}
@@ -218,8 +223,11 @@ void GeometrySet::clear()
void GeometrySet::ensure_own_non_instances()
{
for (GeometryComponentType type : components_.keys()) {
- GeometryComponent &component = this->get_component_for_write(type);
- component.ensure_own_non_instances();
+ const GeometryComponent *component = this->get_component_for_read(type);
+ if (!component->owns_non_instance_data()) {
+ GeometryComponent &component_for_write = this->get_component_for_write(type);
+ component_for_write.ensure_own_non_instances();
+ }
}
}
More information about the Bf-blender-cvs
mailing list