[Bf-blender-cvs] [9ad17f6005d] profiler-editor: add ED_profiler.h

Jacques Lucke noreply at git.blender.org
Thu Apr 29 11:30:47 CEST 2021


Commit: 9ad17f6005deda5d0ee86d5b56ecae470623496d
Author: Jacques Lucke
Date:   Tue Apr 27 15:33:41 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB9ad17f6005deda5d0ee86d5b56ecae470623496d

add ED_profiler.h

===================================================================

A	source/blender/editors/include/ED_profiler.h
M	source/blender/editors/space_profiler/CMakeLists.txt
A	source/blender/editors/space_profiler/profiler_profile.cc
M	source/blender/editors/util/CMakeLists.txt

===================================================================

diff --git a/source/blender/editors/include/ED_profiler.h b/source/blender/editors/include/ED_profiler.h
new file mode 100644
index 00000000000..2a0a8716d15
--- /dev/null
+++ b/source/blender/editors/include/ED_profiler.h
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup editors
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct SpaceProfiler;
+
+void ED_profiler_profile_enable(struct SpaceProfiler *sprofiler);
+void ED_profiler_profile_disable(struct SpaceProfiler *sprofiler);
+bool ED_profiler_profile_is_enabled(struct SpaceProfiler *sprofiler);
+void ED_profiler_profile_clear(struct SpaceProfiler *sprofiler);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/editors/space_profiler/CMakeLists.txt b/source/blender/editors/space_profiler/CMakeLists.txt
index 9ac83285321..0353ac1d39f 100644
--- a/source/blender/editors/space_profiler/CMakeLists.txt
+++ b/source/blender/editors/space_profiler/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
 
 set(SRC
   profiler_layout.cc
+  profiler_profile.cc
   space_profiler.cc
 
   profiler_layout.hh
diff --git a/source/blender/editors/space_profiler/profiler_profile.cc b/source/blender/editors/space_profiler/profiler_profile.cc
new file mode 100644
index 00000000000..1dcaf9bb460
--- /dev/null
+++ b/source/blender/editors/space_profiler/profiler_profile.cc
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#include "ED_profiler.h"
+
+#include "DNA_space_types.h"
+
+#include "profiler_runtime.hh"
+
+void ED_profiler_profile_enable(SpaceProfiler *sprofiler)
+{
+  if (ED_profiler_profile_is_enabled(sprofiler)) {
+    return;
+  }
+  SpaceProfiler_Runtime &runtime = *sprofiler->runtime;
+  runtime.profile_listener = std::make_unique<blender::ed::profiler::SpaceProfilerListener>(
+      runtime);
+}
+
+void ED_profiler_profile_disable(SpaceProfiler *sprofiler)
+{
+  if (!ED_profiler_profile_is_enabled(sprofiler)) {
+    return;
+  }
+  SpaceProfiler_Runtime &runtime = *sprofiler->runtime;
+  runtime.profile_listener.reset();
+}
+
+bool ED_profiler_profile_is_enabled(SpaceProfiler *sprofiler)
+{
+  SpaceProfiler_Runtime &runtime = *sprofiler->runtime;
+  return (bool)runtime.profile_listener;
+}
+
+void ED_profiler_profile_clear(SpaceProfiler *sprofiler)
+{
+  SpaceProfiler_Runtime &runtime = *sprofiler->runtime;
+  runtime.profile_layout.reset();
+}
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index 54ec6b22e70..b7262c875d3 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -77,6 +77,7 @@ set(SRC
   ../include/ED_paint.h
   ../include/ED_particle.h
   ../include/ED_physics.h
+  ../include/ED_profiler.h
   ../include/ED_render.h
   ../include/ED_scene.h
   ../include/ED_screen.h



More information about the Bf-blender-cvs mailing list