d31429197e297ce1381b45e900b78539b0158f0e
[platform/core/uifw/dali-adaptor.git] / adaptors / base / thread-synchronization-debug.h
1 #ifndef __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
2 #define __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace Adaptor
31 {
32
33 namespace
34 {
35 #ifdef DEBUG_ENABLED
36
37 #define ENABLE_LOG_IN_COLOR 1
38 #define ENABLE_VSYNC_COUNTER_LOGGING 1
39 #define ENABLE_UPDATE_COUNTER_LOGGING 1
40 #define ENABLE_VSYNC_THREAD_LOGGING 1
41 #define ENABLE_UPDATE_THREAD_LOGGING 1
42 #define ENABLE_RENDER_THREAD_LOGGING 1
43 #define ENABLE_EVENT_LOGGING 1
44
45 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, true, "LOG_THREAD_SYNC" );
46
47 #define LOG_THREAD_SYNC(level, color, format, args...) \
48     if( gLogFilter && gLogFilter->IsEnabledFor( level ) ) { Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ## args, COLOR_CLEAR ); }
49
50 #define LOG_THREAD_SYNC_TRACE(color) \
51     Dali::Integration::Log::TraceObj debugTraceObj( ( gLogFilter && gLogFilter->IsEnabledFor( Debug::Concise ) ) ? gLogFilter : NULL, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR )
52
53 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...) \
54     Dali::Integration::Log::TraceObj debugTraceObj( ( gLogFilter && gLogFilter->IsEnabledFor( Debug::Concise ) ) ? gLogFilter : NULL, "%s%s: " format "%s", color, __FUNCTION__, ## args, COLOR_CLEAR )
55
56 #else // DEBUG_ENABLED
57
58 #define LOG_THREAD_SYNC(color, format, args...)
59 #define LOG_THREAD_SYNC_TRACE(color)
60 #define LOG_THREAD_SYNC_TRACE_FMT(color, format, args...)
61
62 #endif // DEBUG_ENABLED
63
64 #ifdef ENABLE_LOG_IN_COLOR
65 #define COLOR_RED            "\033[31m"
66 #define COLOR_YELLOW         "\033[33m"
67 #define COLOR_BLUE           "\033[34m"
68 #define COLOR_LIGHT_RED      "\033[91m"
69 #define COLOR_LIGHT_YELLOW   "\033[93m"
70 #define COLOR_LIGHT_BLUE     "\033[94m"
71 #define COLOR_WHITE          "\033[97m"
72 #define COLOR_CLEAR          "\033[0m"
73 #else
74 #define COLOR_RED
75 #define COLOR_YELLOW
76 #define COLOR_BLUE
77 #define COLOR_LIGHT_RED
78 #define COLOR_LIGHT_YELLOW
79 #define COLOR_LIGHT_BLUE
80 #define COLOR_WHITE
81 #define COLOR_CLEAR
82 #endif
83
84 #ifdef ENABLE_VSYNC_COUNTER_LOGGING
85 #define LOG_VSYNC_COUNTER_VSYNC(format, args...)    LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ## args)
86 #define LOG_VSYNC_COUNTER_UPDATE(format, args...)   LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ## args)
87 #else
88 #define LOG_VSYNC_COUNTER_VSYNC(format, args...)
89 #define LOG_VSYNC_COUNTER_UPDATE(format, args...)
90 #endif
91
92 #ifdef ENABLE_UPDATE_COUNTER_LOGGING
93 #define LOG_UPDATE_COUNTER_UPDATE(format, args...)  LOG_THREAD_SYNC(Debug::Verbose, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
94 #define LOG_UPDATE_COUNTER_RENDER(format, args...)  LOG_THREAD_SYNC(Debug::Verbose, COLOR_LIGHT_BLUE, "%s: " format, __FUNCTION__, ## args)
95 #else
96 #define LOG_UPDATE_COUNTER_UPDATE(format, args...)
97 #define LOG_UPDATE_COUNTER_RENDER(format, args...)
98 #endif
99
100 #ifdef ENABLE_VSYNC_THREAD_LOGGING
101 #define LOG_VSYNC(format, args...)             LOG_THREAD_SYNC(Debug::General, COLOR_RED, "%s: " format, __FUNCTION__, ## args)
102 #define LOG_VSYNC_TRACE                        LOG_THREAD_SYNC_TRACE(COLOR_RED)
103 #define LOG_VSYNC_TRACE_FMT(format, args...)   LOG_THREAD_SYNC_TRACE_FMT(COLOR_RED, format, ## args)
104 #else
105 #define LOG_VSYNC(format, args...)
106 #define LOG_VSYNC_TRACE
107 #define LOG_VSYNC_TRACE_FMT(format, args...)
108 #endif
109
110 #ifdef ENABLE_UPDATE_THREAD_LOGGING
111 #define LOG_UPDATE(format, args...)            LOG_THREAD_SYNC(Debug::General, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## args)
112 #define LOG_UPDATE_TRACE                       LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
113 #define LOG_UPDATE_TRACE_FMT(format, args...)  LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ## args)
114 #else
115 #define LOG_UPDATE(format, args...)
116 #define LOG_UPDATE_TRACE
117 #define LOG_UPDATE_TRACE_FMT(format, args...)
118 #endif
119
120 #ifdef ENABLE_RENDER_THREAD_LOGGING
121 #define LOG_RENDER(format, args...)            LOG_THREAD_SYNC(Debug::General, COLOR_BLUE, "%s: " format, __FUNCTION__, ## args)
122 #define LOG_RENDER_TRACE                       LOG_THREAD_SYNC_TRACE(COLOR_BLUE)
123 #define LOG_RENDER_TRACE_FMT(format, args...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_BLUE, format, ## args)
124 #else
125 #define LOG_RENDER(format, args...)
126 #define LOG_RENDER_TRACE
127 #define LOG_RENDER_TRACE_FMT(format, args...)
128 #endif
129
130 #ifdef ENABLE_EVENT_LOGGING
131 #define LOG_EVENT(format, args...)             LOG_THREAD_SYNC(Debug::Concise, COLOR_WHITE, "%s: " format, __FUNCTION__, ## args)
132 #define LOG_EVENT_TRACE                        LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
133 #define LOG_EVENT_TRACE_FMT(format, args...)   LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ## args)
134 #else
135 #define LOG_EVENT(format, args...)
136 #define LOG_EVENT_TRACE
137 #define LOG_EVENT_TRACE_FMT(format, args...)
138 #endif
139 } // unnamed namespace
140
141 } // namespace Adaptor
142
143 } // namespace Internal
144
145 } // namespace Dali
146
147 #endif // __DALI_INTERNAL_THREAD_SYNCHRONIZATION_DEBUG_H__