Improved performance logging
[platform/core/uifw/dali-adaptor.git] / adaptors / base / environment-options.h
1 #ifndef __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H__
2 #define __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_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 #include <dali/integration-api/debug.h>
22
23 namespace Dali
24 {
25 namespace Internal
26 {
27 namespace Adaptor
28 {
29
30 /**
31  * Contains environment options which define settings and the ability to install a log function.
32  */
33 class EnvironmentOptions
34 {
35
36 public:
37
38   /**
39    * Constructor
40    */
41   EnvironmentOptions();
42
43   /**
44    * non-virtual destructor, not intended as a base class
45    */
46   ~EnvironmentOptions();
47
48   /**
49    * @param logFunction logging function
50    * @param logFilterOptions bitmask of the logging options defined in intergration/debug.h (e.g.
51    * @param logFrameRateFrequency frequency of how often FPS is logged out (e.g. 0 = off, 2 = every 2 seconds).
52    * @param logupdateStatusFrequency frequency of how often the update status is logged in number of frames
53    * @param logPerformanceStats performance statistics logging, 0 = disabled,  1+ =  enabled
54    * @param logPerformanceStatsFrequency statistics logging frequency in seconds
55    * @param performanceTimeStampOutput where to output performance related time stamps to
56    * @param logPanGestureLevel pan-gesture logging, 0 = disabled,  1 = enabled
57    */
58   void SetLogOptions( const Dali::Integration::Log::LogFunction& logFunction,
59                        unsigned int logFrameRateFrequency,
60                        unsigned int logupdateStatusFrequency,
61                        unsigned int logPerformanceStats,
62                        unsigned int logPerformanceStatsFrequency,
63                        unsigned int performanceTimeStampOutput,
64                        unsigned int logPanGestureLevel );
65
66   /**
67    * Install the log function for the current thread.
68    */
69   void InstallLogFunction() const;
70
71   /**
72    * Un-install the log function for the current thread.
73    */
74   void UnInstallLogFunction() const;
75
76   /**
77    * @return frequency of how often FPS is logged out (e.g. 0 = off, 2 = every 2 seconds).
78    */
79   unsigned int GetFrameRateLoggingFrequency() const;
80
81   /**
82    * @return frequency of how often Update Status is logged out (e.g. 0 = off, 60 = log every 60 frames = 1 second @ 60FPS).
83    */
84   unsigned int GetUpdateStatusLoggingFrequency() const;
85
86   /**
87    * @return performance statistics log level ( 0 == off )
88    */
89   unsigned int GetPerformanceStatsLoggingOptions() const;
90
91   /**
92    * @return performance statistics log frequency in seconds
93    */
94   unsigned int GetPerformanceStatsLoggingFrequency() const;
95
96   /**
97    * @return performance time stamp output ( 0 == off)
98    */
99   unsigned int GetPerformanceTimeStampOutput() const;
100
101   /**
102    * @return pan-gesture logging level ( 0 == off )
103    */
104   unsigned int GetPanGestureLoggingLevel() const;
105
106   /**
107    * @return pan-gesture prediction mode ( -1 means not set so no prediction, 0 = no prediction )
108    */
109   int GetPanGesturePredictionMode() const;
110
111   /**
112    * @return pan-gesture prediction amount
113    */
114   int GetPanGesturePredictionAmount() const;
115
116   /**
117    * @return maximum pan-gesture prediction amount
118    */
119   int GetPanGestureMaximumPredictionAmount() const;
120
121   /**
122    * @return minimum pan-gesture prediction amount
123    */
124   int GetPanGestureMinimumPredictionAmount() const;
125
126   /**
127    * @return pan-gesture prediction amount adjustment
128    */
129   int GetPanGesturePredictionAmountAdjustment() const;
130
131   /**
132    * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing )
133    */
134   int GetPanGestureSmoothingMode() const;
135
136   /**
137    * @return pan-gesture smoothing amount
138    */
139   float GetPanGestureSmoothingAmount() const;
140
141   /**
142    * @return The minimum distance before a pan can be started (-1 means it's not set)
143    */
144   int GetMinimumPanDistance() const;
145
146   /**
147    * @return The minimum events before a pan can be started (-1 means it's not set)
148    */
149   int GetMinimumPanEvents() const;
150
151   /**
152    * @brief Sets the mode used to predict pan gesture movement
153    *
154    * @param[in] mode The prediction mode to use
155    */
156   void SetPanGesturePredictionMode( unsigned int mode );
157
158   /**
159    * @brief Sets the prediction amount of the pan gesture
160    *
161    * @param[in] amount The prediction amount in milliseconds
162    */
163   void SetPanGesturePredictionAmount( unsigned int amount );
164
165   /**
166    * @brief Sets the upper bound of the prediction amount for clamping
167    *
168    * @param[in] amount The prediction amount in milliseconds
169    */
170   void SetPanGestureMaximumPredictionAmount( unsigned int amount );
171
172   /**
173    * @brief Sets the lower bound of the prediction amount for clamping
174    *
175    * @param[in] amount The prediction amount in milliseconds
176    */
177   void SetPanGestureMinimumPredictionAmount( unsigned int amount );
178
179   /**
180    * @brief Sets the prediction amount to adjust when the pan velocity is changed.
181    * If the pan velocity is accelerating, the prediction amount will be increased
182    * by the specified amount until it reaches the upper bound. If the pan velocity
183    * is decelerating, the prediction amount will be decreased by the specified
184    * amount until it reaches the lower bound.
185    *
186    * @param[in] amount The prediction amount in milliseconds
187    */
188   void SetPanGesturePredictionAmountAdjustment( unsigned int amount );
189
190   /**
191    * @brief Called to set how pan gestures smooth input
192    *
193    * @param[in] mode The smoothing mode to use
194    */
195   void SetPanGestureSmoothingMode( unsigned int mode );
196
197   /**
198    * @brief Sets the mode used to smooth pan gesture movement properties calculated on the Update thread
199    *
200    * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
201    */
202   void SetPanGestureSmoothingAmount( float amount );
203
204   /**
205    * @brief Sets the minimum distance required before a pan starts
206    *
207    * @param[in] distance The minimum distance before a pan starts
208    */
209   void SetMinimumPanDistance( int distance );
210
211   /**
212    * @brief Sets the minimum number of events required before a pan starts
213    *
214    * @param[in] events The minimum events before a pan starts
215    */
216   void SetMinimumPanEvents( int events );
217
218   /**
219    * @brief Sets how often the gles call logging occurs
220    *
221    * @param[in] time the number of seconds between logging output
222    */
223   void SetGlesCallTime( int time );
224
225   /**
226    * @brief Get the graphics status time
227    */
228   int GetGlesCallTime() const;
229
230   /**
231    * @return true if performance server is required
232    */
233   bool PerformanceServerRequired() const;
234
235 private:
236
237   unsigned int mFpsFrequency;                     ///< how often fps is logged out in seconds
238   unsigned int mUpdateStatusFrequency;            ///< how often update status is logged out in frames
239   unsigned int mPerformanceStatsLevel;            ///< performance statistics logging bitmask
240   unsigned int mPerformanceStatsFrequency;        ///< performance statistics logging frequency (seconds)
241   unsigned int mPerformanceTimeStampOutput;       ///< performance time stamp output ( bitmask)
242   unsigned int mPanGestureLoggingLevel;           ///< pan-gesture log level
243   int mPanGesturePredictionMode;                  ///< prediction mode for pan gestures
244   int mPanGesturePredictionAmount;                ///< prediction amount for pan gestures
245   int mPanGestureMaxPredictionAmount;             ///< maximum prediction amount for pan gestures
246   int mPanGestureMinPredictionAmount;             ///< minimum prediction amount for pan gestures
247   int mPanGesturePredictionAmountAdjustment;      ///< adjustment of prediction amount for pan gestures
248   int mPanGestureSmoothingMode;                  ///< prediction mode for pan gestures
249   float mPanGestureSmoothingAmount;              ///< prediction amount for pan gestures
250   int mPanMinimumDistance;                        ///< minimum distance required before pan starts
251   int mPanMinimumEvents;                          ///< minimum events required before pan starts
252   int mGlesCallTime;                              ///< time in seconds between status updates
253
254   Dali::Integration::Log::LogFunction mLogFunction;
255
256   // Undefined copy constructor.
257   EnvironmentOptions( const EnvironmentOptions& );
258
259   // Undefined assignment operator.
260   EnvironmentOptions& operator=( const EnvironmentOptions& );
261
262 };
263
264 } // Adaptor
265 } // Internal
266 } // Dali
267
268 #endif // __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H__