diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-16 14:26:37 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-16 14:26:37 +0300 |
commit | 36e7de9eb329e122605e3fe1ba80585d3aff1b26 (patch) | |
tree | 25bddeff8cb491d7518f060faffdf2709dea4913 /source/blender/depsgraph | |
parent | 5baf0de6e74a4df43dea91e177aeece5468648c4 (diff) | |
parent | da4efaeb87b74f73bd5b640eb70132521a1db5cb (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 70 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_intern.h | 4 |
2 files changed, 65 insertions, 9 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index a05e422d602..a2e6993e442 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -35,6 +35,8 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_console.h" +#include "BLI_hash.h" #include "BLI_ghash.h" #include "BLI_listbase.h" @@ -526,6 +528,31 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, } } +bool deg_terminal_do_color(void) +{ + return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0; +} + +string deg_color_for_pointer(const void *pointer) +{ + if (!deg_terminal_do_color()) { + return ""; + } + int r, g, b; + BLI_hash_pointer_to_color(pointer, &r, &g, &b); + char buffer[64]; + BLI_snprintf(buffer, sizeof(buffer), TRUECOLOR_ANSI_COLOR_FORMAT, r, g, b); + return string(buffer); +} + +string deg_color_end(void) +{ + if (!deg_terminal_do_color()) { + return ""; + } + return string(TRUECOLOR_ANSI_COLOR_FINISH); +} + } // namespace DEG /* **************** */ @@ -554,6 +581,8 @@ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, DEG::deg_editor_update_scene_cb = scene_func; } +/* Evaluation and debug */ + void DEG_debug_print_eval(const char *function_name, const char *object_name, const void *object_address) @@ -561,7 +590,12 @@ void DEG_debug_print_eval(const char *function_name, if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) { return; } - printf("%s on %s (%p)\n", function_name, object_name, object_address); + printf("%s on %s %s(%p)%s\n", + function_name, + object_name, + DEG::deg_color_for_pointer(object_address).c_str(), + object_address, + DEG::deg_color_end().c_str()); } void DEG_debug_print_eval_subdata(const char *function_name, @@ -574,11 +608,17 @@ void DEG_debug_print_eval_subdata(const char *function_name, if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) { return; } - printf("%s on %s (%p) %s %s (%p)\n", + printf("%s on %s %s(%p)%s %s %s %s(%p)%s\n", function_name, - object_name, object_address, + object_name, + DEG::deg_color_for_pointer(object_address).c_str(), + object_address, + DEG::deg_color_end().c_str(), subdata_comment, - subdata_name, subdata_address); + subdata_name, + DEG::deg_color_for_pointer(subdata_address).c_str(), + subdata_address, + DEG::deg_color_end().c_str()); } void DEG_debug_print_eval_subdata_index(const char *function_name, @@ -592,11 +632,18 @@ void DEG_debug_print_eval_subdata_index(const char *function_name, if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) { return; } - printf("%s on %s (%p) %s %s[%d] (%p)\n", + printf("%s on %s %s(%p)^%s %s %s[%d] %s(%p)%s\n", function_name, - object_name, object_address, + object_name, + DEG::deg_color_for_pointer(object_address).c_str(), + object_address, + DEG::deg_color_end().c_str(), subdata_comment, - subdata_name, subdata_index, subdata_address); + subdata_name, + subdata_index, + DEG::deg_color_for_pointer(subdata_address).c_str(), + subdata_address, + DEG::deg_color_end().c_str()); } void DEG_debug_print_eval_time(const char *function_name, @@ -607,6 +654,11 @@ void DEG_debug_print_eval_time(const char *function_name, if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) { return; } - printf("%s on %s (%p) at time %f\n", - function_name, object_name, object_address, time); + printf("%s on %s %s(%p)%s at time %f\n", + function_name, + object_name, + DEG::deg_color_for_pointer(object_address).c_str(), + object_address, + DEG::deg_color_end().c_str(), + time); } diff --git a/source/blender/depsgraph/intern/depsgraph_intern.h b/source/blender/depsgraph/intern/depsgraph_intern.h index e310608b25e..9961723ed17 100644 --- a/source/blender/depsgraph/intern/depsgraph_intern.h +++ b/source/blender/depsgraph/intern/depsgraph_intern.h @@ -125,4 +125,8 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, fflush(stderr); \ } while (0) +bool deg_terminal_do_color(void); +string deg_color_for_pointer(const void *pointer); +string deg_color_end(void); + } // namespace DEG |