[Bf-blender-cvs] [f775cfb] depsgraph_refactor: New 'mode' property for the info space to draw depsgraph statistics.

Lukas Tönne noreply at git.blender.org
Fri May 30 16:24:19 CEST 2014


Commit: f775cfbf286d1b963846ea8b17fb2ea366fe6e1d
Author: Lukas Tönne
Date:   Fri May 30 09:37:33 2014 +0200
https://developer.blender.org/rBf775cfbf286d1b963846ea8b17fb2ea366fe6e1d

New 'mode' property for the info space to draw depsgraph statistics.

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

M	source/blender/editors/space_info/CMakeLists.txt
A	source/blender/editors/space_info/depsgraphview.c
A	source/blender/editors/space_info/depsgraphview.h
M	source/blender/editors/space_info/info_draw.c
M	source/blender/editors/space_info/info_intern.h
M	source/blender/editors/space_info/space_info.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index 94b40a9..47092ca 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
 	../../blenloader
 	../../imbuf
 	../../bmesh
+	../../depsgraph
 	../../makesdna
 	../../makesrna
 	../../windowmanager
@@ -42,10 +43,12 @@ set(SRC
 	info_draw.c
 	info_report.c
 	textview.c
+	depsgraphview.c
 	space_info.c
 
 	info_intern.h
 	textview.h
+	depsgraphview.h
 )
 
 if(WITH_INTERNATIONAL)
diff --git a/source/blender/editors/space_info/depsgraphview.c b/source/blender/editors/space_info/depsgraphview.c
new file mode 100644
index 0000000..e81cf65
--- /dev/null
+++ b/source/blender/editors/space_info/depsgraphview.c
@@ -0,0 +1,44 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_info/depsgraphview.c
+ *  \ingroup spinfo
+ */
+
+
+#include <string.h>
+#include <assert.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "DEG_depsgraph_debug.h"
+
+#include "UI_interface.h"
+
+#include "depsgraphview.h"
+
+void depsgraphview_draw(const struct bContext *C, uiLayout *layout)
+{
+	
+}
diff --git a/source/blender/editors/space_info/depsgraphview.h b/source/blender/editors/space_info/depsgraphview.h
new file mode 100644
index 0000000..263954e
--- /dev/null
+++ b/source/blender/editors/space_info/depsgraphview.h
@@ -0,0 +1,35 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_info/depsgraphview.h
+ *  \ingroup spinfo
+ */
+
+#ifndef __DEPSGRAPHVIEW_H__
+#define __DEPSGRAPHVIEW_H__
+
+struct bContext;
+struct uiLayout;
+
+void depsgraphview_draw(const struct bContext *C, struct uiLayout *layout);
+
+#endif  /* __DEPSGRAPHVIEW_H__ */
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 86af89b..59737fe 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -35,6 +35,7 @@
 
 #include "BLF_api.h"
 
+#include "BLI_rect.h"
 #include "BLI_utildefines.h"
 
 #include "DNA_space_types.h"
@@ -42,6 +43,7 @@
 
 // #include "BKE_suggestions.h"
 #include "BKE_report.h"
+#include "BKE_screen.h"
 
 #include "BIF_gl.h"
 
@@ -54,6 +56,7 @@
 
 #include "info_intern.h"
 #include "../space_info/textview.h"
+#include "../space_info/depsgraphview.h"
 
 /* complicates things a bit, so leaving in old simple code */
 #define USE_INFO_NEWLINE
@@ -291,3 +294,25 @@ void info_textview_main(struct SpaceInfo *sinfo, ARegion *ar, ReportList *report
 	int mval[2] = {INT_MAX, INT_MAX};
 	info_textview_main__internal(sinfo, ar, reports, 1,  mval, NULL, NULL);
 }
+
+void info_depsgraphview_main(const struct bContext *C, struct ARegion *ar)\
+{
+	View2D *v2d = &ar->v2d;
+	uiBlock *block;
+	uiLayout *layout;
+	float width, em;
+	
+	block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
+	
+	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());
+	
+	depsgraphview_draw(C, layout);
+	
+	uiBlockLayoutResolve(block, NULL, NULL);
+	
+	uiEndBlock(C, block);
+}
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 967bcec..52285d1 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -33,6 +33,7 @@
 
 /* internal exports only */
 
+struct bContext;
 struct SpaceInfo;
 struct wmOperatorType;
 struct ReportList;
@@ -56,6 +57,7 @@ void INFO_OT_reports_display_update(struct wmOperatorType *ot);
 void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y);
 int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports);
 void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports);
+void info_depsgraphview_main(const struct bContext *C, struct ARegion *ar);
 
 /* info_report.c */
 int info_report_mask(struct SpaceInfo *sinfo);
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 062fc0c..6600507 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -156,19 +156,26 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
 	UI_ThemeClearColor(TH_BACK);
 	glClear(GL_COLOR_BUFFER_BIT);
 
-	/* quick way to avoid drawing if not bug enough */
+	/* quick way to avoid drawing if not big enough */
 	if (ar->winy < 16)
 		return;
-		
-	info_textview_update_rect(C, ar);
-
-	/* worlks best with no view2d matrix set */
-	UI_view2d_view_ortho(v2d);
-
-	info_textview_main(sinfo, ar, CTX_wm_reports(C));
-
-	/* reset view matrix */
-	UI_view2d_view_restore(C);
+	
+	switch (sinfo->mode) {
+		case INFO_MODE_REPORTS:
+			info_textview_update_rect(C, ar);
+			
+			/* worlks best with no view2d matrix set */
+			UI_view2d_view_ortho(v2d);
+			
+			info_textview_main(sinfo, ar, CTX_wm_reports(C));
+			
+			/* reset view matrix */
+			UI_view2d_view_restore(C);
+			break;
+		case INFO_MODE_DEPSGRAPH:
+			info_depsgraphview_main(C, ar);
+			break;
+	}
 	
 	/* scrollers */
 	scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index c7a6d48..0bd5238 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -102,10 +102,18 @@ typedef struct SpaceInfo {
 	float blockscale DNA_DEPRECATED;
 	short blockhandler[8]  DNA_DEPRECATED;      /* XXX make deprecated */
 	
+	short mode;
+	
 	char rpt_mask;
-	char pad[7];
+	char pad[5];
 } SpaceInfo;
 
+/* SpaceInfo.mode */
+typedef enum eSpaceInfo_Mode {
+	INFO_MODE_REPORTS       = 0,
+	INFO_MODE_DEPSGRAPH     = 1,
+} eSpaceInfo_Mode;
+
 /* SpaceInfo.rpt_mask */
 typedef enum eSpaceInfo_RptMask {
 	INFO_RPT_DEBUG  = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 39d6e66..ccf887b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3278,10 +3278,22 @@ static void rna_def_space_info(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
+	static EnumPropertyItem mode_items[] = {
+		{INFO_MODE_REPORTS, "INFO_REPORTS", ICON_INFO, "Reports", "Display report history"},
+		{INFO_MODE_DEPSGRAPH, "INFO_DEPSGRAPH", ICON_LINKED, "Depsgraph", "Display dependency graph statistics"},
+		{0, NULL, 0, NULL, NULL}
+	};
+
 	srna = RNA_def_struct(brna, "SpaceInfo", "Space");
 	RNA_def_struct_sdna(srna, "SpaceInfo");
 	RNA_def_struct_ui_text(srna, "Space Info", "Info space data");
-	
+
+	prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "mode");
+	RNA_def_property_enum_items(prop, mode_items);
+	RNA_def_property_ui_text(prop, "Mode", "Type of info to display");
+	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
+
 	/* reporting display */
 	prop = RNA_def_property(srna, "show_report_debug", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_DEBUG);




More information about the Bf-blender-cvs mailing list