Change DebugPriority name and Debug priority
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-debug.cpp
1 /*
2  * Copyright (c) 2022 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/render/common/render-debug.h>
20
21 // EXTERNAL INCLUDES
22 #include <sstream>
23
24 // INTERNAL INCLUDES
25 #include <dali/integration-api/debug.h>
26 #include <dali/internal/render/common/render-instruction.h>
27 #include <dali/internal/render/common/render-item.h>
28 #include <dali/internal/render/common/render-list.h>
29 #include <dali/internal/update/nodes/node.h>
30
31 using Dali::Internal::SceneGraph::Node;
32 using Dali::Internal::SceneGraph::RenderList;
33
34 namespace Dali
35 {
36 namespace Internal
37 {
38 namespace Render
39 {
40 // These functions should only be defined if they are being used by the #define in the header.
41 // Otherwise they will contribute negatively to code coverage.
42 #ifdef DALI_PRINT_RENDER_INFO
43
44 void PrintFrameStart(BufferIndex bufferIndex)
45 {
46   DALI_LOG_RENDER_INFO("RENDER START - bufferIndex: %d\n", bufferIndex);
47 }
48
49 void PrintFrameEnd()
50 {
51   DALI_LOG_RENDER_INFO("RENDER END\n\n");
52 }
53
54 void PrintRenderInstruction(const SceneGraph::RenderInstruction& instruction, BufferIndex index)
55 {
56   const char* target = (nullptr != instruction.mFrameBuffer) ? "FrameBuffer" : "Screen";
57
58   std::stringstream debugStream;
59   debugStream << "Rendering to " << target << ", View: " << *(instruction.GetViewMatrix(index)) << " Projection: " << *(instruction.GetProjectionMatrix(index));
60
61   if(instruction.mIsViewportSet)
62   {
63     debugStream << " Viewport: " << instruction.mViewport.x << "," << instruction.mViewport.y << " " << instruction.mViewport.width << "x" << instruction.mViewport.height;
64   }
65
66   if(instruction.mIsClearColorSet)
67   {
68     debugStream << " ClearColor: " << instruction.mClearColor;
69   }
70
71   std::string debugString(debugStream.str());
72   DALI_LOG_RENDER_INFO("   %s\n", debugString.c_str());
73 }
74
75 void PrintRenderList(const RenderList& list)
76 {
77   std::stringstream debugStream;
78   debugStream << "Rendering items";
79
80   if(list.IsClipping())
81   {
82     debugStream << ", ClippingBox: " << list.GetClippingBox().x << "," << list.GetClippingBox().y << " " << list.GetClippingBox().width << "x" << list.GetClippingBox().height;
83   }
84
85   std::string debugString(debugStream.str());
86   DALI_LOG_RENDER_INFO("      %s\n", debugString.c_str());
87 }
88
89 void PrintRenderItem(const SceneGraph::RenderItem& item)
90 {
91   std::stringstream debugStream;
92   debugStream << "Rendering item, ModelView: " << item.mModelViewMatrix;
93
94   std::string debugString(debugStream.str());
95   DALI_LOG_RENDER_INFO("         %s\n", debugString.c_str());
96 }
97
98 void PrintRendererCount(unsigned int frameCount, unsigned int rendererCount)
99 {
100   if(frameCount % 120 == 30) // Print every 2 seconds reg
101   {
102     Debug::LogMessage(Debug::INFO, "Renderer Total # renderers: %u\n", rendererCount);
103   }
104 }
105
106 #endif
107
108 } // namespace Render
109
110 } // namespace Internal
111
112 } // namespace Dali