Merge branch 'master' into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / base / performance-logging / performance-server.h
1 #ifndef __DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H__
2 #define __DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H__
3
4 /*
5  * Copyright (c) 2014 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 // INTERNAL INCLUDES
22 #include <base/performance-logging/frame-time-stats.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <base/interfaces/adaptor-internal-services.h>
25
26 // EXTERNAL INCLUDES
27 #include <boost/thread/mutex.hpp>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 class EnvironmentOptions;
39 /**
40  * Concrete implementation of performance interface.
41  * Adaptor classes should never include this file, they
42  * just need to include the abstract class performance-interface.h
43  */
44 class PerformanceServer : public PerformanceInterface
45 {
46
47 public:
48
49   /**
50    * Constructor
51    * @param adaptorServices adaptor internal services
52    * @param environmentOptions environment options
53    */
54   PerformanceServer( AdaptorInternalServices& adaptorServices,
55                      const EnvironmentOptions& environmentOptions );
56
57   /**
58    * Destructor
59    */
60   virtual ~PerformanceServer();
61
62   /**
63    * @copydoc PerformanceInterface::AddMarker()
64    */
65   virtual void AddMarker( PerformanceMarker::MarkerType markerType);
66
67   /**
68    * @copydoc PerformanceInterface::SetLogging()
69    */
70   virtual void SetLogging( unsigned int level, unsigned int interval);
71
72
73 private:
74
75   /**
76    * Helper
77    */
78   void AddMarkerToLog( PerformanceMarker marker );
79
80   /**
81    * Helper
82    */
83   void LogMarker(const char* name, const FrameTimeStats& frameStats);
84
85   /**
86    * log markers out
87    */
88   void LogMarkers();
89
90 private:
91
92   bool mLoggingEnabled:1;         ///< whether logging update / render to a log is enabled
93   bool mLogFunctionInstalled:1;   ///< whether the log function is installed
94   unsigned int mLogLevel;         ///< log level
95
96   unsigned int mLogFrequencyMicroseconds; ///< if logging is enabled, what frequency to log out at in micro-seconds
97
98   FrameTimeStats mUpdateStats;    ///< update time statistics
99   FrameTimeStats mRenderStats;    ///< render time statistics
100   FrameTimeStats mEventStats;     ///< event time statistics
101
102   Integration::PlatformAbstraction& mPlatformAbstraction; ///< platform abstraction
103
104   typedef Dali::Vector<PerformanceMarker > MarkerVector;
105   MarkerVector mMarkers;              ///< vector of markers
106   boost::mutex mDataMutex;            ///< mutex
107   const EnvironmentOptions& mEnvironmentOptions;      ///< environment options
108   KernelTraceInterface& mKernelTrace; ///< kernel trace interface
109
110 };
111
112
113 } // namespace Internal
114
115 } // namespace Adaptor
116
117 } // namespace Dali
118
119 #endif