[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager-debug.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/manager/update-manager-debug.h>
20
21 // EXTERNAL INCLUDES
22 #include <iomanip>
23 #include <ios>
24 #include <sstream>
25
26 // INTERNAL INCLUDES
27 #include <dali/integration-api/debug.h>
28 #include <dali/public-api/common/constants.h>
29 #include <dali/public-api/math/degree.h>
30 #include <dali/public-api/math/radian.h>
31 #include <dali/public-api/math/vector2.h>
32
33 #ifdef DALI_PRINT_UPDATE_INFO
34
35 namespace Dali
36 {
37 namespace Internal
38 {
39 namespace SceneGraph
40 {
41 #if defined(DEBUG_ENABLED)
42 static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
43 #endif
44
45 /**
46  * Debug helper function.
47  */
48 void PrintNodes(const Node& node, BufferIndex updateBufferIndex, int level)
49 {
50   std::string nodeName = DALI_LOG_GET_OBJECT_STRING((&node));
51
52   {
53     std::ostringstream      oss;
54     std::ios_base::fmtflags mask = oss.flags();
55     mask &= ~std::ios_base::scientific;
56     mask |= std::ios_base::fixed;
57     oss << std::setprecision(2) << std::setiosflags(mask)
58         << std::setw(level * 2) << std::setfill(' ') << "";
59
60     oss << "Node " << nodeName << " " << &node
61         << " Position: " << node.GetPosition(updateBufferIndex)
62         << " WorldPosition: " << node.GetWorldPosition(updateBufferIndex)
63         << " Size: " << node.GetSize(updateBufferIndex)
64         << " Visible: " << node.IsVisible(updateBufferIndex)
65         << std::endl;
66
67     DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s", oss.str().c_str());
68   }
69
70   ++level;
71
72   for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
73   {
74     PrintNodes(**iter, updateBufferIndex, level);
75   }
76 }
77
78 void PrintNodeTree(const Node& node, BufferIndex bufferIndex, std::string indentation)
79 {
80   std::cout << "Node " << &node
81             << " \"" << node.mDebugString << "\""
82             << " Origin: " << node.GetParentOrigin()
83             << " Anchor: " << node.GetAnchorPoint()
84             << " Size: " << node.GetSize(bufferIndex)
85             << " Pos: " << node.GetPosition(bufferIndex)
86             << " Ori: " << node.GetOrientation(bufferIndex)
87             << " Scale: " << node.GetScale(bufferIndex)
88             << " Color: " << node.GetColor(bufferIndex)
89             << " Visible: " << node.IsVisible(bufferIndex)
90             << " World Pos: " << node.GetWorldPosition(bufferIndex)
91             << " World Ori: " << node.GetWorldOrientation(bufferIndex)
92             << " World Scale: " << node.GetWorldScale(bufferIndex)
93             << " World Color: " << node.GetWorldColor(bufferIndex)
94             << " World Matrix: " << node.GetWorldMatrix(bufferIndex)
95             << std::endl;
96
97   for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
98   {
99     std::cout << indentation << "|" << std::endl
100               << indentation << "---->";
101
102     std::string nextIndent = indentation;
103     if((iter + 1) != node.GetChildren().End())
104     {
105       nextIndent += "|    ";
106     }
107     else
108     {
109       nextIndent += "     ";
110     }
111
112     PrintNodeTree(**iter, bufferIndex, nextIndent);
113   }
114 }
115
116 } // namespace SceneGraph
117
118 } // namespace Internal
119
120 } // namespace Dali
121
122 #endif