[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / performance-server.h
1 #ifndef DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H
2 #define DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H
3
4 /*
5  * Copyright (c) 2021 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 INCLDUES
22 #include <dali/devel-api/threading/mutex.h>
23 #include <dali/public-api/common/dali-vector.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/adaptor/common/adaptor-internal-services.h>
27 #include <dali/internal/network/common/network-performance-server.h>
28 #include <dali/internal/system/common/frame-time-stats.h>
29 #include <dali/internal/system/common/performance-marker.h>
30 #include <dali/internal/system/common/stat-context-manager.h>
31
32 namespace Dali
33 {
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 class EnvironmentOptions;
39 class StatContext;
40 /**
41  * Concrete implementation of performance interface.
42  * Adaptor classes should never include this file, they
43  * just need to include the abstract class performance-interface.h
44  */
45 class PerformanceServer : public PerformanceInterface, public StatContextLogInterface
46 {
47 public:
48   /**
49    * @brief Constructor
50    * @param[in] adaptorServices adaptor internal services
51    * @param[in] environmentOptions environment options
52    */
53   PerformanceServer(AdaptorInternalServices&  adaptorServices,
54                     const EnvironmentOptions& environmentOptions);
55
56   /**
57    * Destructor
58    */
59   virtual ~PerformanceServer();
60
61   /**
62    * @copydoc PerformanceLogger::AddContext()
63    */
64   ContextId AddContext(const char* name) override;
65
66   /**
67    * @copydoc PerformanceLogger::GetContextId()
68    */
69   virtual ContextId GetContextId( const char* name );
70
71   /**
72    * @copydoc PerformanceLogger::RemoveContext()
73    */
74   void RemoveContext(ContextId contextId) override;
75
76   /**
77    * @copydoc PerformanceInterface::AddMarker( MarkerType markerType )
78    */
79   void AddMarker(MarkerType markerType) override;
80
81   /**
82    * @copydoc PerformanceLogger::AddMarker( MarkerType markerType, ContextId contextId )
83    */
84   void AddMarker(MarkerType markerType, ContextId contextId) override;
85
86   /**
87    * @copydoc PerformanceInterface::SetLogging()
88    */
89   virtual void SetLogging(unsigned int statisticsLogOptions,
90                           unsigned int timeStampOutput,
91                           unsigned int logFrequency);
92
93   /**
94    * @copydoc PerformanceLogger::SetLoggingFrequency()
95    */
96   void SetLoggingFrequency(unsigned int logFrequency, ContextId contextId) override;
97
98   /**
99    * @copydoc PerformanceLogger::EnableLogging()
100    */
101   void EnableLogging(bool enable, ContextId contextId) override;
102
103 public: //StatLogInterface
104   /**
105    * @copydoc StatLogInterface::LogContextStatistics()
106    */
107   void LogContextStatistics(const char* const text) override;
108
109 private:
110   /**
111    * @brief log the marker out to kernel/ DALi log
112    * @param[in] marker performance marker
113    * @param[in] description marker description
114    */
115   void LogMarker(const PerformanceMarker& marker, const char* const description);
116
117 private:
118   const EnvironmentOptions& mEnvironmentOptions; ///< environment options
119   TraceInterface&           mKernelTrace;        ///< kernel trace interface
120   TraceInterface&           mSystemTrace;        ///< system trace interface
121   Dali::Mutex               mLogMutex;           ///< mutex
122
123 #if defined(NETWORK_LOGGING_ENABLED)
124   NetworkPerformanceServer mNetworkServer;         ///< network server
125   bool                     mNetworkControlEnabled; ///< Whether network control is enabled
126 #endif
127
128   StatContextManager mStatContextManager;       ///< Stat context manager
129   unsigned int       mStatisticsLogBitmask;     ///< statistics log level
130   unsigned int       mPerformanceOutputBitmask; ///< performance marker output
131
132   bool mLoggingEnabled : 1;       ///< whether logging update / render to a log is enabled
133   bool mLogFunctionInstalled : 1; ///< whether the log function is installed
134 };
135
136 } // namespace Adaptor
137
138 } // namespace Internal
139
140 } // namespace Dali
141
142 #endif // DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H