From cb5bfb32ba01705cf88e2c21eb61f7b9b24688da Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 29 Jun 2020 15:19:56 +0200 Subject: Depsgraph: introduce blender::deg namespace Reviewers: sergey Differential Revision: https://developer.blender.org/D8150 --- source/blender/depsgraph/intern/depsgraph_debug.cc | 94 +++++++++++----------- 1 file changed, 48 insertions(+), 46 deletions(-) (limited to 'source/blender/depsgraph/intern/depsgraph_debug.cc') diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 8f5117ec0f6..0763738ff59 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -42,27 +42,29 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_time.h" +namespace deg = blender::deg; + void DEG_debug_flags_set(Depsgraph *depsgraph, int flags) { - DEG::Depsgraph *deg_graph = reinterpret_cast(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast(depsgraph); deg_graph->debug.flags = flags; } int DEG_debug_flags_get(const Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast(depsgraph); return deg_graph->debug.flags; } void DEG_debug_name_set(struct Depsgraph *depsgraph, const char *name) { - DEG::Depsgraph *deg_graph = reinterpret_cast(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast(depsgraph); deg_graph->debug.name = name; } const char *DEG_debug_name_get(struct Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast(depsgraph); return deg_graph->debug.name.c_str(); } @@ -70,8 +72,8 @@ bool DEG_debug_compare(const struct Depsgraph *graph1, const struct Depsgraph *g { BLI_assert(graph1 != nullptr); BLI_assert(graph2 != nullptr); - const DEG::Depsgraph *deg_graph1 = reinterpret_cast(graph1); - const DEG::Depsgraph *deg_graph2 = reinterpret_cast(graph2); + const deg::Depsgraph *deg_graph1 = reinterpret_cast(graph1); + const deg::Depsgraph *deg_graph2 = reinterpret_cast(graph2); if (deg_graph1->operations.size() != deg_graph2->operations.size()) { return false; } @@ -103,18 +105,18 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph, bool DEG_debug_consistency_check(Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast(graph); /* Validate links exists in both directions. */ - for (DEG::OperationNode *node : deg_graph->operations) { - for (DEG::Relation *rel : node->outlinks) { + for (deg::OperationNode *node : deg_graph->operations) { + for (deg::Relation *rel : node->outlinks) { int counter1 = 0; - for (DEG::Relation *tmp_rel : node->outlinks) { + for (deg::Relation *tmp_rel : node->outlinks) { if (tmp_rel == rel) { counter1++; } } int counter2 = 0; - for (DEG::Relation *tmp_rel : rel->to->inlinks) { + for (deg::Relation *tmp_rel : rel->to->inlinks) { if (tmp_rel == rel) { counter2++; } @@ -130,16 +132,16 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } } - for (DEG::OperationNode *node : deg_graph->operations) { - for (DEG::Relation *rel : node->inlinks) { + for (deg::OperationNode *node : deg_graph->operations) { + for (deg::Relation *rel : node->inlinks) { int counter1 = 0; - for (DEG::Relation *tmp_rel : node->inlinks) { + for (deg::Relation *tmp_rel : node->inlinks) { if (tmp_rel == rel) { counter1++; } } int counter2 = 0; - for (DEG::Relation *tmp_rel : rel->from->outlinks) { + for (deg::Relation *tmp_rel : rel->from->outlinks) { if (tmp_rel == rel) { counter2++; } @@ -153,19 +155,19 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } /* Validate node valency calculated in both directions. */ - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { node->num_links_pending = 0; node->custom_flags = 0; } - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { if (node->custom_flags) { printf("Node %s is twice in the operations!\n", node->identifier().c_str()); return false; } - for (DEG::Relation *rel : node->outlinks) { - if (rel->to->type == DEG::NodeType::OPERATION) { - DEG::OperationNode *to = (DEG::OperationNode *)rel->to; + for (deg::Relation *rel : node->outlinks) { + if (rel->to->type == deg::NodeType::OPERATION) { + deg::OperationNode *to = (deg::OperationNode *)rel->to; BLI_assert(to->num_links_pending < to->inlinks.size()); ++to->num_links_pending; } @@ -173,10 +175,10 @@ bool DEG_debug_consistency_check(Depsgraph *graph) node->custom_flags = 1; } - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { int num_links_pending = 0; - for (DEG::Relation *rel : node->inlinks) { - if (rel->from->type == DEG::NodeType::OPERATION) { + for (deg::Relation *rel : node->inlinks) { + if (rel->from->type == deg::NodeType::OPERATION) { num_links_pending++; } } @@ -205,7 +207,7 @@ void DEG_stats_simple(const Depsgraph *graph, size_t *r_operations, size_t *r_relations) { - const DEG::Depsgraph *deg_graph = reinterpret_cast(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast(graph); /* number of operations */ if (r_operations) { @@ -219,17 +221,17 @@ void DEG_stats_simple(const Depsgraph *graph, size_t tot_outer = 0; size_t tot_rels = 0; - for (DEG::IDNode *id_node : deg_graph->id_nodes) { + for (deg::IDNode *id_node : deg_graph->id_nodes) { tot_outer++; - for (DEG::ComponentNode *comp_node : id_node->components.values()) { + for (deg::ComponentNode *comp_node : id_node->components.values()) { tot_outer++; - for (DEG::OperationNode *op_node : comp_node->operations) { + for (deg::OperationNode *op_node : comp_node->operations) { tot_rels += op_node->inlinks.size(); } } } - DEG::TimeSourceNode *time_source = deg_graph->find_time_source(); + deg::TimeSourceNode *time_source = deg_graph->find_time_source(); if (time_source != nullptr) { tot_rels += time_source->inlinks.size(); } @@ -243,13 +245,13 @@ void DEG_stats_simple(const Depsgraph *graph, } } -static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph) +static deg::string depsgraph_name_for_logging(struct Depsgraph *depsgraph) { const char *name = DEG_debug_name_get(depsgraph); if (name[0] == '\0') { return ""; } - return "[" + DEG::string(name) + "]: "; + return "[" + deg::string(name) + "]: "; } void DEG_debug_print_begin(struct Depsgraph *depsgraph) @@ -270,9 +272,9 @@ void DEG_debug_print_eval(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -292,14 +294,14 @@ void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), subdata_comment, subdata_name, - DEG::color_for_pointer(subdata_address).c_str(), + deg::color_for_pointer(subdata_address).c_str(), subdata_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -320,15 +322,15 @@ void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), subdata_comment, subdata_name, subdata_index, - DEG::color_for_pointer(subdata_address).c_str(), + deg::color_for_pointer(subdata_address).c_str(), subdata_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -348,14 +350,14 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), parent_comment, parent_name, - DEG::color_for_pointer(parent_address).c_str(), + deg::color_for_pointer(parent_address).c_str(), parent_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -373,9 +375,9 @@ void DEG_debug_print_eval_time(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), time); fflush(stdout); } -- cgit v1.2.3