Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/intern/COM_Debug.cc
| Show All 25 Lines | |||||
| #include "BLI_fileops.h" | #include "BLI_fileops.h" | ||||
| #include "BLI_path_util.h" | #include "BLI_path_util.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_sys_types.h" | #include "BLI_sys_types.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "IMB_imbuf.h" | |||||
| #include "IMB_imbuf_types.h" | |||||
| } | } | ||||
| #include "COM_ExecutionSystem.h" | #include "COM_ExecutionSystem.h" | ||||
| #include "COM_Node.h" | #include "COM_Node.h" | ||||
| #include "COM_ReadBufferOperation.h" | #include "COM_ReadBufferOperation.h" | ||||
| #include "COM_ViewerOperation.h" | #include "COM_ViewerOperation.h" | ||||
| #include "COM_WriteBufferOperation.h" | #include "COM_WriteBufferOperation.h" | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| int DebugInfo::m_file_index = 0; | int DebugInfo::m_file_index = 0; | ||||
| DebugInfo::NodeNameMap DebugInfo::m_node_names; | DebugInfo::NodeNameMap DebugInfo::m_node_names; | ||||
| DebugInfo::OpNameMap DebugInfo::m_op_names; | DebugInfo::OpNameMap DebugInfo::m_op_names; | ||||
| std::string DebugInfo::m_current_node_name; | std::string DebugInfo::m_current_node_name; | ||||
| std::string DebugInfo::m_current_op_name; | std::string DebugInfo::m_current_op_name; | ||||
| DebugInfo::GroupStateMap DebugInfo::m_group_states; | DebugInfo::GroupStateMap DebugInfo::m_group_states; | ||||
| static std::string operation_class_name(const NodeOperation *op) | |||||
| { | |||||
| std::string full_name = typeid(*op).name(); | |||||
| /* Remove namespace. */ | |||||
| size_t pos = full_name.find_last_of(':'); | |||||
| BLI_assert(pos != std::string::npos); | |||||
| return full_name.substr(pos + 1); | |||||
| } | |||||
| std::string DebugInfo::node_name(const Node *node) | std::string DebugInfo::node_name(const Node *node) | ||||
| { | { | ||||
| NodeNameMap::const_iterator it = m_node_names.find(node); | NodeNameMap::const_iterator it = m_node_names.find(node); | ||||
| if (it != m_node_names.end()) { | if (it != m_node_names.end()) { | ||||
| return it->second; | return it->second; | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | if (graphviz_system(system, str, sizeof(str) - 1)) { | ||||
| std::cout << "Writing compositor debug to: " << filename << "\n"; | std::cout << "Writing compositor debug to: " << filename << "\n"; | ||||
| FILE *fp = BLI_fopen(filename, "wb"); | FILE *fp = BLI_fopen(filename, "wb"); | ||||
| fputs(str, fp); | fputs(str, fp); | ||||
| fclose(fp); | fclose(fp); | ||||
| } | } | ||||
| } | } | ||||
| static std::string get_operations_export_dir() | |||||
| { | |||||
| return std::string(BKE_tempdir_session()) + "COM_operations" + SEP_STR; | |||||
| } | |||||
| void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render) | |||||
| { | |||||
| ImBuf *ibuf = IMB_allocFromBuffer(NULL, | |||||
| render->getBuffer(), | |||||
| render->getWidth(), | |||||
| render->getHeight(), | |||||
| render->get_num_channels()); | |||||
| const std::string file_name = operation_class_name(op) + "_" + std::to_string(op->get_id()) + | |||||
| ".png"; | |||||
| const std::string path = get_operations_export_dir() + file_name; | |||||
| BLI_make_existing_file(path.c_str()); | |||||
| IMB_saveiff(ibuf, path.c_str(), ibuf->flags); | |||||
| IMB_freeImBuf(ibuf); | |||||
| } | |||||
| void DebugInfo::delete_operations_exports() | |||||
jbakker: This is risky.
would rather only delete .png and only files.
an incorrect placed link could do… | |||||
| { | |||||
| const std::string dir = get_operations_export_dir(); | |||||
| if (BLI_exists(dir.c_str())) { | |||||
| BLI_delete(dir.c_str(), true, true); | |||||
| } | |||||
| } | |||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||
This is risky.
would rather only delete .png and only files.
an incorrect placed link could do a lot of harm.