Emscripten workarounds and llvm syntax fixes
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-debug.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/internal/render/common/render-debug.h>
19
20 // EXTERNAL INCLUDES
21 #include <sstream>
22
23 // INTERNAL INCLUDES
24 #include <dali/integration-api/debug.h>
25 #include <dali/internal/render/common/render-item.h>
26 #include <dali/internal/render/common/render-list.h>
27 #include <dali/internal/render/common/render-instruction.h>
28
29 using Dali::Internal::SceneGraph::RenderList;
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Render
38 {
39
40 void PrintFrameStart( BufferIndex bufferIndex )
41 {
42   DALI_LOG_RENDER_INFO( "RENDER START - bufferIndex: %d\n", bufferIndex );
43 }
44
45 void PrintFrameEnd()
46 {
47   DALI_LOG_RENDER_INFO( "RENDER END\n\n" );
48 }
49
50 void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction )
51 {
52   const char* target = (0 != instruction.mOffscreenTextureId) ? "FrameBuffer" : "Screen";
53
54   std::stringstream debugStream;
55   debugStream << "Rendering to " << target << ", View: " << *(instruction.mViewMatrix) << " Projection: " << *(instruction.mProjectionMatrix);
56
57   if( instruction.mIsViewportSet )
58   {
59     debugStream << " Viewport: " << instruction.mViewport.x << "," << instruction.mViewport.y << " " << instruction.mViewport.width << "x" << instruction.mViewport.height;
60   }
61
62   if( instruction.mIsClearColorSet )
63   {
64     debugStream << " ClearColor: " << instruction.mClearColor;
65   }
66
67   std::string debugString( debugStream.str() );
68   DALI_LOG_RENDER_INFO( "   %s\n", debugString.c_str() );
69 }
70
71 void PrintRenderList( const RenderList& list )
72 {
73   unsigned int flags = list.GetFlags();
74
75   std::stringstream debugStream;
76   debugStream << "Rendering items";
77
78   if( flags )
79   {
80     debugStream << " with:";
81
82     if( flags & RenderList::DEPTH_TEST )
83     {
84       debugStream << " DEPTH_TEST";
85     }
86
87     if( flags & RenderList::DEPTH_WRITE )
88     {
89       debugStream << " DEPTH_WRITE";
90     }
91
92     if( flags & RenderList::DEPTH_CLEAR )
93     {
94       debugStream << " DEPTH_CLEAR";
95     }
96
97     if( flags & RenderList::STENCIL_TEST )
98     {
99       debugStream << " STENCIL_TEST";
100     }
101
102     if( flags & RenderList::STENCIL_WRITE )
103     {
104       debugStream << " STENCIL_WRITE";
105     }
106
107     if( flags & RenderList::STENCIL_CLEAR )
108     {
109       debugStream << " STENCIL_CLEAR";
110     }
111   }
112   else
113   {
114     debugStream << " without any DEPTH_TEST, DEPTH_WRITE etc";
115   }
116
117   if( list.IsClipping() )
118   {
119     debugStream << ", ClippingBox: " << list.GetClippingBox().x << "," << list.GetClippingBox().y << " " << list.GetClippingBox().width << "x" << list.GetClippingBox().height;
120   }
121
122   std::string debugString( debugStream.str() );
123   DALI_LOG_RENDER_INFO( "      %s\n", debugString.c_str() );
124 }
125
126 void PrintRenderItem( const SceneGraph::RenderItem& item )
127 {
128   std::stringstream debugStream;
129   debugStream << "Rendering item, ModelView: " << item.GetModelViewMatrix();
130
131   std::string debugString( debugStream.str() );
132   DALI_LOG_RENDER_INFO( "         %s\n", debugString.c_str() );
133 }
134
135 } // Render
136
137 } // Internal
138
139 } // Dali