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