Implemented Upload methods in Texture to upload data from PixelData objects
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-debug.cpp
1 /*
2  * Copyright (c) 2015 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-item.h>
27 #include <dali/internal/render/common/render-list.h>
28 #include <dali/internal/render/common/render-instruction.h>
29
30 using Dali::Internal::SceneGraph::RenderList;
31
32 namespace Dali
33 {
34
35 namespace Internal
36 {
37
38 namespace Render
39 {
40
41 void PrintFrameStart( BufferIndex bufferIndex )
42 {
43   DALI_LOG_RENDER_INFO( "RENDER START - bufferIndex: %d\n", bufferIndex );
44 }
45
46 void PrintFrameEnd()
47 {
48   DALI_LOG_RENDER_INFO( "RENDER END\n\n" );
49 }
50
51 void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index )
52 {
53   const char* target = (0 != instruction.mOffscreenTextureId) ? "FrameBuffer" : "Screen";
54
55   std::stringstream debugStream;
56   debugStream << "Rendering to " << target << ", View: " << *(instruction.GetViewMatrix(index)) << " Projection: " << *(instruction.GetProjectionMatrix(index));
57
58   if( instruction.mIsViewportSet )
59   {
60     debugStream << " Viewport: " << instruction.mViewport.x << "," << instruction.mViewport.y << " " << instruction.mViewport.width << "x" << instruction.mViewport.height;
61   }
62
63   if( instruction.mIsClearColorSet )
64   {
65     debugStream << " ClearColor: " << instruction.mClearColor;
66   }
67
68   std::string debugString( debugStream.str() );
69   DALI_LOG_RENDER_INFO( "   %s\n", debugString.c_str() );
70 }
71
72 void PrintRenderList( const RenderList& list )
73 {
74   unsigned int flags = list.GetFlags();
75
76   std::stringstream debugStream;
77   debugStream << "Rendering items";
78
79   if( flags )
80   {
81     debugStream << " with:";
82
83     if( flags & RenderList::STENCIL_BUFFER_ENABLED )
84     {
85       debugStream << " STENCIL_TEST";
86     }
87
88     if( flags & RenderList::STENCIL_WRITE )
89     {
90       debugStream << " STENCIL_WRITE";
91     }
92
93     if( flags & RenderList::STENCIL_CLEAR )
94     {
95       debugStream << " STENCIL_CLEAR";
96     }
97   }
98   else
99   {
100     debugStream << " without any STENCIL settings";
101   }
102
103   if( list.IsClipping() )
104   {
105     debugStream << ", ClippingBox: " << list.GetClippingBox().x << "," << list.GetClippingBox().y << " " << list.GetClippingBox().width << "x" << list.GetClippingBox().height;
106   }
107
108   std::string debugString( debugStream.str() );
109   DALI_LOG_RENDER_INFO( "      %s\n", debugString.c_str() );
110 }
111
112 void PrintRenderItem( const SceneGraph::RenderItem& item )
113 {
114   std::stringstream debugStream;
115   debugStream << "Rendering item, ModelView: " << item.mModelViewMatrix;
116
117   std::string debugString( debugStream.str() );
118   DALI_LOG_RENDER_INFO( "         %s\n", debugString.c_str() );
119 }
120
121 void PrintRendererCount( unsigned int frameCount, unsigned int rendererCount )
122 {
123   if( frameCount % 120 == 30 ) // Print every 2 seconds reg
124   {
125     Debug::LogMessage( Debug::DebugInfo, "Renderer Total # renderers: %u\n", rendererCount );
126   }
127 }
128
129 } // Render
130
131 } // Internal
132
133 } // Dali