1 #ifndef DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H
2 #define DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/internal/system/common/performance-marker.h>
26 #include <dali/internal/system/common/frame-time-stats.h>
27 #include <dali/internal/system/common/performance-interface.h>
28 #include <dali/internal/system/common/stat-context-log-interface.h>
40 * Stores and prints statistics for a particular logging context.
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
58 StatContext( unsigned int id,
59 const char* const contextName,
60 PerformanceMarker::MarkerFilter contextType,
61 unsigned int logFrequencySeconds,
62 StatContextLogInterface& logInterface );
66 * @brief Non-virtual destructor, not intended as a base class
71 * @return Return the context ID
73 unsigned int GetId() const;
76 * @return the context name
78 const char* GetName() const;
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
87 const char* GetMarkerDescription( PerformanceInterface::MarkerType type ) const;
90 * @brief Set the frequency for logging
92 * @param[in] logFrequencySeconds The log frequency to set in seconds
94 void SetLogFrequency( unsigned int logFrequencySeconds );
97 * @brief enable/disable logging
99 * @param[in] enableLogging Flag to spePerformancecify enabling/disabling
101 void EnableLogging( bool enableLogging );
104 * @brief Process a custom marker from the application
106 * @param[in] marker The marker to log
108 void ProcessCustomMarker( const PerformanceMarker& marker );
111 * @brief Process a internal marker from DALi (V_SYNC/ UPDATE /RENDER/ EVENT )
113 * @param[in] marker The marker to log
115 void ProcessInternalMarker( const PerformanceMarker& marker );
120 * @brief Record marker
122 * @param[in] marker to record
124 void RecordMarker( const PerformanceMarker& marker );
127 * @brief Called when V-SYNC occurs to indicate a frame tick
128 * @param[in] marker the marker containing a v-sync
130 void FrameTick( const PerformanceMarker& marker );
133 * @brief Helper to print to console
140 StatContext(); ///< undefined default constructor
142 StatContext( const StatContext& ); ///< undefined copy constructor
144 StatContext& operator=( const StatContext& ); ///< undefined assignment operator
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
164 } // namespace Internal
166 } // namespace Adaptor
170 #endif // DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H