[Bf-blender-cvs] [a92b343] depsgraph_refactor: Clean up DepsNode flag fields.

Lukas Tönne noreply at git.blender.org
Tue May 13 18:41:04 CEST 2014


Commit: a92b343f63f4e58a426df89c419064577868ddbe
Author: Lukas Tönne
Date:   Sun May 11 10:26:38 2014 +0200
https://developer.blender.org/rBa92b343f63f4e58a426df89c419064577868ddbe

Clean up DepsNode flag fields.

The OperationDepsNode.flag field would shadow the DepsNode.flag field.
These flags are only used for eval tagging atm, so it's safe to move
these into the OperationDepsNode class.

If necessary, similar flags for "directly modified" etc. could be added
to ID nodes or components too, but they can and should be conceptually
separate and use a non-conflicting flag in the respective subclasses.

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

M	source/blender/depsgraph/intern/depsgraph_debug.cpp
M	source/blender/depsgraph/intern/depsgraph_tag.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_operation.cpp
M	source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 1d09e3a..7c4b80e 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -194,10 +194,13 @@ static void deg_debug_graphviz_node_color(const DebugContext &ctx, const DepsNod
 	
 	const char *color = color_default;
 	if (ctx.show_tags) {
-		if (node->flag & DEPSNODE_FLAG_DIRECTLY_MODIFIED)
-			color = color_modified;
-		else if (node->flag & DEPSNODE_FLAG_NEEDS_UPDATE)
-			color = color_update;
+		if (node->tclass == DEPSNODE_CLASS_OPERATION) {
+			OperationDepsNode *op_node = (OperationDepsNode *)node;
+			if (op_node->flag & DEPSOP_FLAG_DIRECTLY_MODIFIED)
+				color = color_modified;
+			else if (op_node->flag & DEPSOP_FLAG_NEEDS_UPDATE)
+				color = color_update;
+		}
 	}
 	
 	deg_debug_printf(ctx, "\"%s\"", color);
@@ -211,10 +214,13 @@ static void deg_debug_graphviz_node_penwidth(const DebugContext &ctx, const Deps
 	
 	float penwidth = penwidth_default;
 	if (ctx.show_tags) {
-		if (node->flag & DEPSNODE_FLAG_DIRECTLY_MODIFIED)
-			penwidth = penwidth_modified;
-		else if (node->flag & DEPSNODE_FLAG_NEEDS_UPDATE)
-			penwidth = penwidth_update;
+		if (node->tclass == DEPSNODE_CLASS_OPERATION) {
+			OperationDepsNode *op_node = (OperationDepsNode *)node;
+			if (op_node->flag & DEPSOP_FLAG_DIRECTLY_MODIFIED)
+				penwidth = penwidth_modified;
+			else if (op_node->flag & DEPSOP_FLAG_NEEDS_UPDATE)
+				penwidth = penwidth_update;
+		}
 	}
 	
 	deg_debug_printf(ctx, "\"%f\"", penwidth);
@@ -274,9 +280,12 @@ static void deg_debug_graphviz_relation_color(const DebugContext &ctx, const Dep
 static void deg_debug_graphviz_node_style(const DebugContext &ctx, const DepsNode *node)
 {
 	const char *base_style = "filled"; /* default style */
-	if (ctx.show_tags &&
-	    (node->flag & (DEPSNODE_FLAG_DIRECTLY_MODIFIED | DEPSNODE_FLAG_NEEDS_UPDATE))) {
-		base_style = "striped";
+	if (ctx.show_tags) {
+		if (node->tclass == DEPSNODE_CLASS_OPERATION) {
+			OperationDepsNode *op_node = (OperationDepsNode *)node;
+			if (op_node->flag & (DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE))
+				base_style = "striped";
+		}
 	}
 	
 	switch (node->tclass) {
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cpp b/source/blender/depsgraph/intern/depsgraph_tag.cpp
index 911aaeb..adaa626 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cpp
@@ -141,8 +141,8 @@ void DEG_graph_flush_updates(Depsgraph *graph)
 			DepsRelation *rel = *it;
 			OperationDepsNode *to_node = rel->to;
 			
-			if (!(to_node->flag & DEPSNODE_FLAG_NEEDS_UPDATE)) {
-				to_node->flag |= DEPSNODE_FLAG_NEEDS_UPDATE;
+			if (!(to_node->flag & DEPSOP_FLAG_NEEDS_UPDATE)) {
+				to_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
 				queue.push(to_node);
 				
 				flushed_relations = true;
@@ -167,7 +167,7 @@ void DEG_graph_clear_tags(Depsgraph *graph)
 		OperationDepsNode *node = *it;
 		
 		/* clear node's "pending update" settings */
-		node->flag &= ~(DEPSNODE_FLAG_DIRECTLY_MODIFIED | DEPSNODE_FLAG_NEEDS_UPDATE);
+		node->flag &= ~(DEPSOP_FLAG_DIRECTLY_MODIFIED | DEPSOP_FLAG_NEEDS_UPDATE);
 		node->num_links_pending = 0; /* reset so that it can be bumped up again */
 	}
 	
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index c1586d8..0c90618 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -59,19 +59,6 @@ typedef enum eDepsNode_Color {
 	DEPSNODE_BLACK = 2
 } eDepsNode_Color;
 
-/* Flags for Depsgraph Nodes */
-typedef enum eDepsNode_Flag {
-	/* node needs to be updated */
-	DEPSNODE_FLAG_NEEDS_UPDATE       = (1 << 0),
-	
-	/* node was directly modified, causing need for update */
-	/* XXX: intention is to make it easier to tell when we just need to take subgraphs */
-	DEPSNODE_FLAG_DIRECTLY_MODIFIED  = (1 << 1),
-	
-	/* node was visited/handled already in traversal... */
-	DEPSNODE_FLAG_TEMP_TAG           = (1 << 2),
-} eDepsNode_Flag;
-
 /* All nodes in Depsgraph are descended from this */
 struct DepsNode {
 	/* Helper class for static typeinfo in subclasses */
@@ -89,8 +76,6 @@ struct DepsNode {
 	eDepsNode_Type type;        /* structural type of node */
 	eDepsNode_Class tclass;     /* type of data/behaviour represented by node... */
 	
-	short flag;                 /* (eDepsNode_Flag) dirty/visited tags */
-	
 public:
 	DepsNode();
 	virtual ~DepsNode();
diff --git a/source/blender/depsgraph/intern/depsnode_operation.cpp b/source/blender/depsgraph/intern/depsnode_operation.cpp
index ff1d075..2840729 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.cpp
+++ b/source/blender/depsgraph/intern/depsnode_operation.cpp
@@ -66,7 +66,7 @@ OperationDepsNode::~OperationDepsNode()
 void OperationDepsNode::tag_update(Depsgraph *graph)
 {
 	/* tag for update, but also not that this was the source of an update */
-	flag |= (DEPSNODE_FLAG_NEEDS_UPDATE | DEPSNODE_FLAG_DIRECTLY_MODIFIED);
+	flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED);
 	
 	graph->add_entry_tag(this);
 }
diff --git a/source/blender/depsgraph/intern/depsnode_operation.h b/source/blender/depsgraph/intern/depsnode_operation.h
index e7fb5b8..c03965d 100644
--- a/source/blender/depsgraph/intern/depsnode_operation.h
+++ b/source/blender/depsgraph/intern/depsnode_operation.h
@@ -49,6 +49,22 @@ struct ID;
 struct Depsgraph;
 struct DepsgraphCopyContext;
 
+/* Flags for Depsgraph Nodes */
+typedef enum eDepsOperation_Flag {
+	/* node needs to be updated */
+	DEPSOP_FLAG_NEEDS_UPDATE       = (1 << 0),
+	
+	/* node was directly modified, causing need for update */
+	/* XXX: intention is to make it easier to tell when we just need to take subgraphs */
+	DEPSOP_FLAG_DIRECTLY_MODIFIED  = (1 << 1),
+
+	/* Operation is evaluated using CPython; has GIL and security implications... */
+	DEPSOP_FLAG_USES_PYTHON   = (1 << 2),
+	
+	/* node was visited/handled already in traversal... */
+	DEPSOP_FLAG_TEMP_TAG           = (1 << 3),
+} eDepsOperation_Flag;
+
 /* Atomic Operation - Base type for all operations */
 struct OperationDepsNode : public DepsNode {
 	typedef unordered_set<DepsRelation *> Relations;
@@ -80,11 +96,6 @@ struct OperationDepsNode : public DepsNode {
 #define DEG_DEPSNODE_OP_DEFINE(NodeType, type_, comp_type_, tname_) \
 	const DepsNode::TypeInfo NodeType::typeinfo = DepsNode::TypeInfo(type_, tname_, comp_type_)
 
-/* Extra flags affecting operations */
-typedef enum eDepsOperation_Flag {
-	DEPSOP_FLAG_USES_PYTHON   = (1 << 0),  /* Operation is evaluated using CPython; has GIL and security implications... */      
-} eDepsOperation_Flag;
-
 struct ParametersOperationDepsNode : public OperationDepsNode {
 	DEG_DEPSNODE_DECLARE;
 };




More information about the Bf-blender-cvs mailing list