Merge "Set proper locale to harfbuzz" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / base / performance-logging / statistics / stat-context.h
1 #ifndef __DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H__
2 #define __DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_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 <string>
23
24 // INTERNAL INCLUDES
25 #include <base/performance-logging/performance-marker.h>
26 #include <base/performance-logging/frame-time-stats.h>
27 #include <base/interfaces/performance-interface.h>
28 #include <base/performance-logging/statistics/stat-context-log-interface.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39 /**
40  * Stores and prints statistics for a particular logging context.
41  *
42  */
43 class StatContext
44 {
45
46 public:
47
48     /**
49      * @brief Constructor
50      *
51      * @param[in] id The ID to give the context
52      * @param[in] contextName Name of the context to print in console
53      * @param[in] contextType the type of events to filter ( e.g. event, update, render or custom)
54      * @param[in] logFrequencySeconds frequency to log in seconds
55      * @param[in] logInterface interface to log out to
56      *
57      */
58     StatContext( unsigned int id,
59                  const char* const contextName,
60                  PerformanceMarker::MarkerFilter contextType,
61                  unsigned int logFrequencySeconds,
62                  StatContextLogInterface& logInterface );
63
64
65     /**
66      * @brief Non-virtual destructor, not intended as a base class
67      */
68     ~StatContext();
69
70     /**
71      * @return Return the context ID
72      */
73     unsigned int GetId() const;
74
75     /**
76      * @return the context name
77      */
78     const char* GetName() const;
79
80     /**
81      *
82      * For logging we want to output the name of the context with either
83      * START / END appended to the end. E.g. MY_MARKER_START
84      * @param[in] type marker type, for a customer marker this will be either START or END
85      * @return the full description for a marker
86      */
87     const char* GetMarkerDescription( PerformanceInterface::MarkerType type ) const;
88
89     /**
90      * @brief Set the frequency for logging
91      *
92      * @param[in] logFrequencySeconds The log frequency to set in seconds
93      */
94     void SetLogFrequency( unsigned int logFrequencySeconds );
95
96     /**
97      * @brief enable/disable logging
98      *
99      * @param[in] enableLogging Flag to spePerformancecify enabling/disabling
100      */
101     void EnableLogging( bool enableLogging );
102
103     /**
104      * @brief  Process a custom marker from the application
105      *
106      * @param[in] marker The marker to log
107      */
108     void ProcessCustomMarker( const PerformanceMarker& marker );
109
110     /**
111      * @brief Process a internal marker from DALi (V_SYNC/ UPDATE /RENDER/ EVENT )
112      *
113      * @param[in] marker The marker to log
114      */
115     void ProcessInternalMarker( const PerformanceMarker& marker );
116
117   private:
118
119     /**
120      * @brief Record marker
121      *
122      * @param[in] marker to record
123      */
124     void RecordMarker( const PerformanceMarker& marker );
125
126     /**
127      * @brief Called when V-SYNC occurs to indicate a frame tick
128      * @param[in] marker the marker containing a v-sync
129      */
130     void FrameTick( const PerformanceMarker& marker );
131
132     /**
133      * @brief Helper to print to console
134      */
135     void LogMarker();
136
137
138   private:
139
140     StatContext();                                ///< undefined default constructor
141
142     StatContext( const StatContext& );            ///< undefined copy constructor
143
144     StatContext& operator=( const StatContext& ); ///< undefined assignment operator
145
146   private:
147
148     PerformanceMarker mInitialMarker;             ///< Used to store initial time
149     FrameTimeStats mStats;                        ///< Frame time stats to accumulate
150     const char* const mName;                      ///< Name of the context
151     char* mTempLogBuffer;                         ///< Temporary log buffer
152     StatContextLogInterface& mLogInterface;       ///< Log interface
153     const std::string mNamePlusStart;             ///< Name of the context + _START
154     const std::string mNamePlusEnd;                ///< Name of the context + _END
155     unsigned int mId;                             ///< The ID of the context
156     unsigned int mLogFrequencyMicroseconds;       ///< if logging is enabled, what frequency to log out at in micro-seconds
157     PerformanceMarker::MarkerFilter mFilterType;  ///< type of events the context is filtering
158     bool mLoggingEnabled:1;                       ///< Whether to print the log for this context or not
159     bool mInitialMarkerSet:1;                     ///< Whether the initial marker has been set
160
161 };
162
163
164 } // namespace Internal
165
166 } // namespace Adaptor
167
168 } // namespace Dali
169
170 #endif