Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-adaptor.git] / adaptors / base / interfaces / performance-interface.h
1 #ifndef __DALI_INTERNAL_BASE_PERFORMANCE_INTERFACE_H__
2 #define __DALI_INTERNAL_BASE_PERFORMANCE_INTERFACE_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 namespace Dali
22 {
23
24 namespace Internal
25 {
26
27 namespace Adaptor
28 {
29
30 /**
31  * Abstract Performance Interface.
32  * Used by the Adaptor to store performance metrics.
33  *
34  */
35 class PerformanceInterface
36 {
37 public:
38
39   typedef unsigned short ContextId;   ///< Type to represent a context ID
40
41   /**
42    * bitmask of logging options
43    */
44   enum LogLevel
45   {
46     DISABLED             = 0,
47     ENABLED              = 1 << 0, ///< Bit 0, log all
48     LOG_UPDATE_RENDER    = 1 << 1, ///< Bit 1, log update and render times
49     LOG_EVENT_PROCESS    = 1 << 2, ///< Bit 2, log event process times
50     LOG_EVENTS_TO_KERNEL = 1 << 3  ///< Bit 3, log all events to kernel trace
51   };
52
53   /**
54    * enum for difference performance markers.
55    * Please modify the name lookup table in performance-interface.cpp
56    * file if adding new markers.
57    */
58   enum MarkerType
59   {
60     VSYNC     = 0,        ///< V-Sync
61     UPDATE_START ,        ///< Update start
62     UPDATE_END   ,        ///< Update end
63     RENDER_START ,        ///< Render start
64     RENDER_END   ,        ///< Render end
65     SWAP_START   ,        ///< SwapBuffers Start
66     SWAP_END     ,        ///< SwapBuffers End
67     PROCESS_EVENTS_START, ///< Process events start (e.g. touch event)
68     PROCESS_EVENTS_END,   ///< Process events end
69     PAUSED       ,        ///< Pause start
70     RESUME       ,        ///< Resume start
71     START        ,        ///< The start of custom tracking
72     END                   ///< The end of custom tracking
73   };
74
75   /**
76    * Constructor.
77    */
78   PerformanceInterface() {}
79
80   /**
81    * Virtual destructor
82    */
83   virtual ~PerformanceInterface() {};
84
85   /**
86    * Add a new context with a given name
87    *
88    * @param[in] name The name of the context
89    * @return Return the unique id for this context
90    */
91   virtual ContextId AddContext( const char* name ) = 0;
92
93   /**
94    * Remove a context from use
95    *
96    * @param[in] contextId The ID of the context to remove
97    */
98   virtual void RemoveContext( ContextId contextId ) = 0;
99
100   /**
101    * Add a performance marker
102    * This function can be called from ANY THREAD.
103    * The default context 0 Event/Update/Render is assumed.
104    * @param markerType performance marker type
105    */
106   virtual void AddMarker( MarkerType markerType ) = 0;
107
108   /**
109    * Add a performance marker
110    * This function can be called from ANY THREAD.
111    * @param markerType performance marker type
112    * @param contextId The context of the marker. This must be one generated by AddContext.
113    */
114   virtual void AddMarker( MarkerType markerType, ContextId contextId ) = 0;
115
116   /**
117    * Set the logging level and frequency
118    * @param level 0 = disabled, 1 = enabled
119    * @param logFrequency how often to log out in seconds
120    */
121   virtual void SetLogging( unsigned int level, unsigned int logFrequency) = 0;
122
123   /**
124    * Set the logging frequency
125    *
126    * @param logFrequency how often to log out in seconds
127    */
128   virtual void SetLoggingFrequency( unsigned int logFrequency, ContextId contextId ) = 0;
129
130   /**
131    * Set logging on or off for a particular context
132    *
133    * @param[in] enable Enable logging or not
134    * @param[in] contextId The id of the context to log. This must be one generated by AddContext.
135    */
136   virtual void EnableLogging( bool enable, ContextId contextId ) = 0;
137
138 private:
139
140   // Undefined copy constructor.
141   PerformanceInterface( const PerformanceInterface& );
142
143   // Undefined assignment operator.
144   PerformanceInterface& operator=( const PerformanceInterface& );
145
146 };
147
148 } // namespace Internal
149
150 } // namespace Adaptor
151
152 } // namespace Dali
153
154 #endif