[Bf-blender-cvs] [959a7a5] depsgraph_refactor: Simple stats drawing for the depsgraph info mode.
Lukas Tönne
noreply at git.blender.org
Fri May 30 16:24:21 CEST 2014
Commit: 959a7a5c4217238fadbe7d2ac7e4d9f94e9f40c5
Author: Lukas Tönne
Date: Fri May 30 16:17:30 2014 +0200
https://developer.blender.org/rB959a7a5c4217238fadbe7d2ac7e4d9f94e9f40c5
Simple stats drawing for the depsgraph info mode.
===================================================================
M source/blender/depsgraph/CMakeLists.txt
M source/blender/depsgraph/DEG_depsgraph_debug.h
M source/blender/depsgraph/intern/depsgraph_debug.cpp
M source/blender/depsgraph/intern/depsgraph_debug.h
M source/blender/editors/space_info/depsgraphview.c
M source/blender/editors/space_info/info_draw.c
M source/blender/editors/space_info/space_info.c
===================================================================
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 25bce3e..27846f4 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -33,6 +33,7 @@ set(INC
../makesdna
../makesrna
../modifiers
+ ../windowmanager
../../../intern/guardedalloc
)
diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h
index ce5ea26..8ac8c9b 100644
--- a/source/blender/depsgraph/DEG_depsgraph_debug.h
+++ b/source/blender/depsgraph/DEG_depsgraph_debug.h
@@ -72,6 +72,8 @@ struct DepsgraphStats *DEG_stats(void);
void DEG_stats_verify(struct DepsgraphSettings *settings);
+struct DepsgraphStatsID *DEG_stats_id(struct ID *id);
+
/* ************************************************ */
/* Graphviz Debugging */
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index c415850..44a7d28 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -50,6 +50,9 @@ extern "C" {
#include "RNA_access.h"
#include "RNA_types.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
} /* extern "C" */
#include "depsgraph_debug.h"
@@ -715,6 +718,7 @@ void DepsgraphDebug::eval_begin(eEvaluationContextType context_type)
void DepsgraphDebug::eval_end(eEvaluationContextType context_type)
{
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
}
void DepsgraphDebug::eval_step(eEvaluationContextType context_type, const char *message)
@@ -857,3 +861,11 @@ void DEG_stats_verify(DepsgraphSettings *settings)
{
DepsgraphDebug::verify_stats(settings);
}
+
+DepsgraphStatsID *DEG_stats_id(ID *id)
+{
+ if (!DepsgraphDebug::stats)
+ return NULL;
+
+ return DepsgraphDebug::get_id_stats(id, false);
+}
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.h b/source/blender/depsgraph/intern/depsgraph_debug.h
index e3a1b29..6f9c974 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.h
+++ b/source/blender/depsgraph/intern/depsgraph_debug.h
@@ -67,15 +67,15 @@ struct DepsgraphDebug {
static void task_started(const DepsgraphTask &task);
static void task_completed(const DepsgraphTask &task, double time);
-protected:
- static ThreadMutex stats_mutex;
-
static DepsgraphStatsID *get_id_stats(ID *id, bool create);
static DepsgraphStatsComponent *get_component_stats(DepsgraphStatsID *id_stats, const string &name, bool create);
static DepsgraphStatsComponent *get_component_stats(ID *id, const string &name, bool create)
{
return get_component_stats(get_id_stats(id, create), name, create);
}
+
+protected:
+ static ThreadMutex stats_mutex;
};
#endif // __DEPSGRAPH_DEBUG_H__
diff --git a/source/blender/editors/space_info/depsgraphview.c b/source/blender/editors/space_info/depsgraphview.c
index e81cf65..3e1afec 100644
--- a/source/blender/editors/space_info/depsgraphview.c
+++ b/source/blender/editors/space_info/depsgraphview.c
@@ -30,15 +30,55 @@
#include "MEM_guardedalloc.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
+#include "BKE_context.h"
+#include "BKE_main.h"
+
#include "DEG_depsgraph_debug.h"
#include "UI_interface.h"
#include "depsgraphview.h"
+static void draw_fields_header(uiLayout *layout)
+{
+ uiLayout *row = uiLayoutRow(layout, true);
+
+ uiItemL(row, "Name", 0);
+ uiItemL(row, "Last Duration [ms]", 0);
+}
+
+static void draw_fields_id(uiLayout *layout, ID *id, DepsgraphStatsID *id_stats)
+{
+ uiLayout *row = uiLayoutRow(layout, true);
+ char num[256];
+
+ uiItemL(row, id->name+2, 0);
+
+ if (id_stats) {
+ BLI_snprintf(num, sizeof(num), "%.3f", id_stats->times.duration_last);
+ uiItemL(row, num, 0);
+ }
+ else {
+ uiItemL(row, "-", 0);
+ }
+}
+
void depsgraphview_draw(const struct bContext *C, uiLayout *layout)
{
+ Main *bmain = CTX_data_main(C);
+ DepsgraphStats *stats = DEG_stats();
+ uiLayout *col = uiLayoutColumn(layout, true);
+ ID *id;
+
+ if (!stats)
+ return;
+
+ draw_fields_header(col);
+ for (id = bmain->object.first; id; id = id->next) {
+ draw_fields_id(col, id, DEG_stats_id(id));
+ }
}
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 59737fe..1106b8c 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -300,19 +300,26 @@ void info_depsgraphview_main(const struct bContext *C, struct ARegion *ar)\
View2D *v2d = &ar->v2d;
uiBlock *block;
uiLayout *layout;
- float width, em;
+ float x, y, width, em;
+ int xco, yco;
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
+ x = v2d->cur.xmin;
+ y = v2d->cur.ymax;
width = BLI_rctf_size_x(&v2d->cur);
+
em = (ar->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
- 0, 0, width, em, 0, UI_GetStyle());
+ x, y, width, em, 0, UI_GetStyle());
depsgraphview_draw(C, layout);
- uiBlockLayoutResolve(block, NULL, NULL);
+ uiBlockLayoutResolve(block, &xco, &yco);
uiEndBlock(C, block);
+ uiDrawBlock(C, block);
+
+// UI_view2d_totRect_set(v2d, 1000, 1000);
}
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 45f36d5..befe8c0 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -163,10 +163,9 @@ static void info_main_area_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
/* force it on init, for old files, until it becomes config */
- ar->v2d.scroll = (V2D_SCROLL_RIGHT);
+ ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
-
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Info Generic", SPACE_INFO, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
@@ -211,7 +210,12 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
break;
case INFO_MODE_DEPSGRAPH:
+ UI_view2d_view_ortho(v2d);
+
info_depsgraphview_main(C, ar);
+
+ /* reset view matrix */
+ UI_view2d_view_restore(C);
break;
}
More information about the Bf-blender-cvs
mailing list