[Bf-blender-cvs] [258038ca848] profiler-editor: add runtime data
Jacques Lucke
noreply at git.blender.org
Thu Apr 29 11:30:47 CEST 2021
Commit: 258038ca848175259d3dc81b8e5a729692d6484c
Author: Jacques Lucke
Date: Tue Apr 27 15:26:03 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rB258038ca848175259d3dc81b8e5a729692d6484c
add runtime data
===================================================================
A source/blender/editors/space_profiler/profiler_runtime.cc
A source/blender/editors/space_profiler/profiler_runtime.hh
M source/blender/editors/space_profiler/space_profiler.cc
M source/blender/makesdna/DNA_space_types.h
===================================================================
diff --git a/source/blender/editors/space_profiler/profiler_runtime.cc b/source/blender/editors/space_profiler/profiler_runtime.cc
new file mode 100644
index 00000000000..1da114106a4
--- /dev/null
+++ b/source/blender/editors/space_profiler/profiler_runtime.cc
@@ -0,0 +1,30 @@
+/*
+ * 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 "profiler_runtime.hh"
+
+namespace blender::ed::profiler {
+
+void SpaceProfilerListener::handle(const RecordedProfile &profile)
+{
+ if (!runtime_->profile_layout) {
+ runtime_->profile_layout = std::make_unique<ProfileLayout>();
+ }
+ ProfileLayout &profile_layout = *runtime_->profile_layout;
+ profile_layout.add(profile);
+}
+
+} // namespace blender::ed::profiler
diff --git a/source/blender/editors/space_profiler/profiler_runtime.hh b/source/blender/editors/space_profiler/profiler_runtime.hh
new file mode 100644
index 00000000000..c90e53a8ce3
--- /dev/null
+++ b/source/blender/editors/space_profiler/profiler_runtime.hh
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <optional>
+
+#include "profiler_layout.hh"
+
+namespace blender::ed::profiler {
+
+class SpaceProfilerListener : public profile::ProfileListener {
+ private:
+ SpaceProfiler_Runtime *runtime_;
+
+ public:
+ SpaceProfilerListener(SpaceProfiler_Runtime &runtime) : runtime_(&runtime)
+ {
+ }
+
+ void handle(const RecordedProfile &profile) final;
+};
+
+} // namespace blender::ed::profiler
+
+struct SpaceProfiler_Runtime {
+ std::unique_ptr<blender::ed::profiler::ProfileLayout> profile_layout;
+ std::unique_ptr<blender::ed::profiler::SpaceProfilerListener> profile_listener;
+
+ SpaceProfiler_Runtime() = default;
+ SpaceProfiler_Runtime(const SpaceProfiler_Runtime &UNUSED(other))
+ {
+ }
+};
diff --git a/source/blender/editors/space_profiler/space_profiler.cc b/source/blender/editors/space_profiler/space_profiler.cc
index 4bbdfbc9fe0..b540424f22e 100644
--- a/source/blender/editors/space_profiler/space_profiler.cc
+++ b/source/blender/editors/space_profiler/space_profiler.cc
@@ -37,6 +37,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "profiler_runtime.hh"
+
static SpaceLink *profiler_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
SpaceProfiler *sprofiler = (SpaceProfiler *)MEM_callocN(sizeof(SpaceProfiler), "profiler space");
@@ -64,13 +66,20 @@ static void profiler_free(SpaceLink *UNUSED(sl))
{
}
-static void profiler_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
+static void profiler_init(wmWindowManager *UNUSED(wm), ScrArea *area)
{
+ SpaceProfiler *sprofiler = (SpaceProfiler *)area->spacedata.first;
+ if (sprofiler->runtime == nullptr) {
+ sprofiler->runtime = new SpaceProfiler_Runtime();
+ }
}
static SpaceLink *profiler_duplicate(SpaceLink *sl)
{
- return (SpaceLink *)MEM_dupallocN(sl);
+ SpaceProfiler *sprofiler_old = (SpaceProfiler *)sl;
+ SpaceProfiler *sprofiler_new = (SpaceProfiler *)MEM_dupallocN(sl);
+ sprofiler_new->runtime = new SpaceProfiler_Runtime(*sprofiler_old->runtime);
+ return (SpaceLink *)sprofiler_new;
}
static void profiler_keymap(wmKeyConfig *UNUSED(keyconf))
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index b02aa69c493..47ea9569ed1 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1963,6 +1963,8 @@ typedef enum eSpaceSpreadsheet_ContextType {
/** \name Profiler
* \{ */
+typedef struct SpaceProfiler_Runtime SpaceProfiler_Runtime;
+
typedef struct SpaceProfiler {
SpaceLink *next, *prev;
/** Storage of regions for inactive spaces. */
@@ -1971,6 +1973,8 @@ typedef struct SpaceProfiler {
char link_flag;
char _pad0[6];
/* End 'SpaceLink' header. */
+
+ SpaceProfiler_Runtime *runtime;
} SpaceProfiler;
/** \} */
More information about the Bf-blender-cvs
mailing list