Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-05-19 10:42:05 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-05-27 13:07:15 +0300
commit57aae2a35511e9c4e137016c33f3c44553375aeb (patch)
tree64cb56fd43296441f87702f8db37dbac46b11c77 /intern/opensubdiv
parentc81a5f58f8bee9e592963d5e65a62d2a9eba7825 (diff)
OpenSubdiv: Refactor, use C++ allocation for internal classes
Only use OBJECT_GUARDED_{NEW. DELETE} for structures which are part of public C-API (and hence can not have new/delete operators overloaded). Could try being brave and override new/delete from under C++ ifdef.
Diffstat (limited to 'intern/opensubdiv')
-rw-r--r--intern/opensubdiv/CMakeLists.txt3
-rw-r--r--intern/opensubdiv/internal/base/memory.h28
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc4
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.h4
-rw-r--r--intern/opensubdiv/internal/topology/topology_refiner_capi.cc4
-rw-r--r--intern/opensubdiv/internal/topology/topology_refiner_impl.h3
6 files changed, 42 insertions, 4 deletions
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index eae09bf5dd6..0bf3bbcb2b9 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -50,6 +50,9 @@ if(WITH_OPENSUBDIV)
)
list(APPEND SRC
+ # Base.
+ internal/base/memory.h
+
# Device.
internal/device/device_context_cuda.cc
internal/device/device_context_cuda.h
diff --git a/intern/opensubdiv/internal/base/memory.h b/intern/opensubdiv/internal/base/memory.h
new file mode 100644
index 00000000000..176d9c14694
--- /dev/null
+++ b/intern/opensubdiv/internal/base/memory.h
@@ -0,0 +1,28 @@
+// Copyright 2020 Blender Foundation. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+#ifndef OPENSUBDIV_BASE_MEMORY_H_
+#define OPENSUBDIV_BASE_MEMORY_H_
+
+#include "MEM_guardedalloc.h"
+
+namespace blender {
+namespace opensubdiv {
+
+} // namespace opensubdiv
+} // namespace blender
+
+#endif // OPENSUBDIV_BASE_MEMORY_H_
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
index ea345654484..e5b9654c5d9 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
@@ -858,7 +858,7 @@ OpenSubdiv_EvaluatorInternal *openSubdiv_createEvaluatorInternal(
OpenSubdiv::Far::PatchMap *patch_map = new PatchMap(*patch_table);
// Wrap everything we need into an object which we control from our side.
OpenSubdiv_EvaluatorInternal *evaluator_descr;
- evaluator_descr = OBJECT_GUARDED_NEW(OpenSubdiv_EvaluatorInternal);
+ evaluator_descr = new OpenSubdiv_EvaluatorInternal();
evaluator_descr->eval_output = new blender::opensubdiv::CpuEvalOutputAPI(eval_output, patch_map);
evaluator_descr->patch_map = patch_map;
evaluator_descr->patch_table = patch_table;
@@ -873,5 +873,5 @@ OpenSubdiv_EvaluatorInternal *openSubdiv_createEvaluatorInternal(
void openSubdiv_deleteEvaluatorInternal(OpenSubdiv_EvaluatorInternal *evaluator)
{
- OBJECT_GUARDED_DELETE(evaluator, OpenSubdiv_EvaluatorInternal);
+ delete evaluator;
}
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
index dbe4d88539f..a60b82b02fe 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.h
@@ -26,6 +26,8 @@
#include <opensubdiv/far/patchMap.h>
#include <opensubdiv/far/patchTable.h>
+#include "internal/base/memory.h"
+
struct OpenSubdiv_PatchCoord;
struct OpenSubdiv_TopologyRefiner;
@@ -144,6 +146,8 @@ struct OpenSubdiv_EvaluatorInternal {
blender::opensubdiv::CpuEvalOutputAPI *eval_output;
const OpenSubdiv::Far::PatchMap *patch_map;
const OpenSubdiv::Far::PatchTable *patch_table;
+
+ MEM_CXX_CLASS_ALLOC_FUNCS("OpenSubdiv_EvaluatorInternal");
};
OpenSubdiv_EvaluatorInternal *openSubdiv_createEvaluatorInternal(
diff --git a/intern/opensubdiv/internal/topology/topology_refiner_capi.cc b/intern/opensubdiv/internal/topology/topology_refiner_capi.cc
index 9bfba259671..5014d24a52b 100644
--- a/intern/opensubdiv/internal/topology/topology_refiner_capi.cc
+++ b/intern/opensubdiv/internal/topology/topology_refiner_capi.cc
@@ -230,7 +230,7 @@ void assignFunctionPointers(OpenSubdiv_TopologyRefiner *topology_refiner)
OpenSubdiv_TopologyRefiner *allocateTopologyRefiner()
{
OpenSubdiv_TopologyRefiner *topology_refiner = OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefiner);
- topology_refiner->impl = OBJECT_GUARDED_NEW(OpenSubdiv_TopologyRefinerImpl);
+ topology_refiner->impl = new OpenSubdiv_TopologyRefinerImpl();
assignFunctionPointers(topology_refiner);
return topology_refiner;
}
@@ -256,7 +256,7 @@ OpenSubdiv_TopologyRefiner *openSubdiv_createTopologyRefinerFromConverter(
void openSubdiv_deleteTopologyRefiner(OpenSubdiv_TopologyRefiner *topology_refiner)
{
- OBJECT_GUARDED_DELETE(topology_refiner->impl, OpenSubdiv_TopologyRefinerImpl);
+ delete topology_refiner->impl;
OBJECT_GUARDED_DELETE(topology_refiner, OpenSubdiv_TopologyRefiner);
}
diff --git a/intern/opensubdiv/internal/topology/topology_refiner_impl.h b/intern/opensubdiv/internal/topology/topology_refiner_impl.h
index 507f3d0f869..5c7b81c2540 100644
--- a/intern/opensubdiv/internal/topology/topology_refiner_impl.h
+++ b/intern/opensubdiv/internal/topology/topology_refiner_impl.h
@@ -25,6 +25,7 @@
#include <opensubdiv/far/topologyRefiner.h>
+#include "internal/base/memory.h"
#include "opensubdiv_topology_refiner_capi.h"
namespace blender {
@@ -45,6 +46,8 @@ class TopologyRefinerImpl {
// Ideally, we would also support refining topology without re-importing it
// from external world, but that is for later.
OpenSubdiv_TopologyRefinerSettings settings;
+
+ MEM_CXX_CLASS_ALLOC_FUNCS("TopologyRefinerImpl");
};
} // namespace opensubdiv