Added new environment options for pan prediction
[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 logPerformanceLevel performance logging, 0 = disabled,  1+ =  enabled
54    * @param logPanGestureLevel pan-gesture logging, 0 = disabled,  1 = enabled
55    */
56   void SetLogOptions( const Dali::Integration::Log::LogFunction& logFunction,
57                        unsigned int logFrameRateFrequency,
58                        unsigned int logupdateStatusFrequency,
59                        unsigned int logPerformanceLevel,
60                        unsigned int logPanGestureLevel );
61
62   /**
63    * Install the log function for the current thread.
64    */
65   void InstallLogFunction() const;
66
67   /**
68    * Un-install the log function for the current thread.
69    */
70   void UnInstallLogFunction() const;
71
72   /**
73    * @return frequency of how often FPS is logged out (e.g. 0 = off, 2 = every 2 seconds).
74    */
75   unsigned int GetFrameRateLoggingFrequency() const;
76
77   /**
78    * @return frequency of how often Update Status is logged out (e.g. 0 = off, 60 = log every 60 frames = 1 second @ 60FPS).
79    */
80   unsigned int GetUpdateStatusLoggingFrequency() const;
81
82   /**
83    * @return logPerformanceLevel performance log level ( 0 = off )
84    */
85   unsigned int GetPerformanceLoggingLevel() const;
86
87   /**
88    * @return pan-gesture logging level ( 0 == off )
89    */
90   unsigned int GetPanGestureLoggingLevel() const;
91
92   /**
93    * @return pan-gesture prediction mode ( -1 means not set so no prediction, 0 = no prediction )
94    */
95   int GetPanGesturePredictionMode() const;
96
97   /**
98    * @return pan-gesture prediction amount
99    */
100   int GetPanGesturePredictionAmount() const;
101
102   /**
103    * @return maximum pan-gesture prediction amount
104    */
105   int GetPanGestureMaximumPredictionAmount() const;
106
107   /**
108    * @return minimum pan-gesture prediction amount
109    */
110   int GetPanGestureMinimumPredictionAmount() const;
111
112   /**
113    * @return pan-gesture prediction amount adjustment
114    */
115   int GetPanGesturePredictionAmountAdjustment() const;
116
117   /**
118    * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing )
119    */
120   int GetPanGestureSmoothingMode() const;
121
122   /**
123    * @return pan-gesture smoothing amount
124    */
125   float GetPanGestureSmoothingAmount() const;
126
127   /**
128    * @return The minimum distance before a pan can be started (-1 means it's not set)
129    */
130   int GetMinimumPanDistance() const;
131
132   /**
133    * @return The minimum events before a pan can be started (-1 means it's not set)
134    */
135   int GetMinimumPanEvents() const;
136
137   /**
138    * @brief Sets the mode used to predict pan gesture movement
139    *
140    * @param[in] mode The prediction mode to use
141    */
142   void SetPanGesturePredictionMode( unsigned int mode );
143
144   /**
145    * @brief Sets the prediction amount of the pan gesture
146    *
147    * @param[in] amount The prediction amount in milliseconds
148    */
149   void SetPanGesturePredictionAmount( unsigned int amount );
150
151   /**
152    * @brief Sets the upper bound of the prediction amount for clamping
153    *
154    * @param[in] amount The prediction amount in milliseconds
155    */
156   void SetPanGestureMaximumPredictionAmount( unsigned int amount );
157
158   /**
159    * @brief Sets the lower bound of the prediction amount for clamping
160    *
161    * @param[in] amount The prediction amount in milliseconds
162    */
163   void SetPanGestureMinimumPredictionAmount( unsigned int amount );
164
165   /**
166    * @brief Sets the prediction amount to adjust when the pan velocity is changed.
167    * If the pan velocity is accelerating, the prediction amount will be increased
168    * by the specified amount until it reaches the upper bound. If the pan velocity
169    * is decelerating, the prediction amount will be decreased by the specified
170    * amount until it reaches the lower bound.
171    *
172    * @param[in] amount The prediction amount in milliseconds
173    */
174   void SetPanGesturePredictionAmountAdjustment( unsigned int amount );
175
176   /**
177    * @brief Called to set how pan gestures smooth input
178    *
179    * @param[in] mode The smoothing mode to use
180    */
181   void SetPanGestureSmoothingMode( unsigned int mode );
182
183   /**
184    * @brief Sets the mode used to smooth pan gesture movement properties calculated on the Update thread
185    *
186    * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
187    */
188   void SetPanGestureSmoothingAmount( float amount );
189
190   /**
191    * @brief Sets the minimum distance required before a pan starts
192    *
193    * @param[in] distance The minimum distance before a pan starts
194    */
195   void SetMinimumPanDistance( int distance );
196
197   /**
198    * @brief Sets the minimum number of events required before a pan starts
199    *
200    * @param[in] events The minimum events before a pan starts
201    */
202   void SetMinimumPanEvents( int events );
203
204   /**
205    * @brief Sets how often the gles call logging occurs
206    *
207    * @param[in] time the number of seconds between logging output
208    */
209   void SetGlesCallTime( int time );
210
211   /**
212    * @brief Get the graphics status time
213    */
214   int GetGlesCallTime();
215
216
217 private:
218
219   unsigned int mFpsFrequency;                     ///< how often fps is logged out in seconds
220   unsigned int mUpdateStatusFrequency;            ///< how often update status is logged out in frames
221   unsigned int mPerformanceLoggingLevel;          ///< performance log level
222   unsigned int mPanGestureLoggingLevel;           ///< pan-gesture log level
223   int mPanGesturePredictionMode;                  ///< prediction mode for pan gestures
224   int mPanGesturePredictionAmount;                ///< prediction amount for pan gestures
225   int mPanGestureMaxPredictionAmount;             ///< maximum prediction amount for pan gestures
226   int mPanGestureMinPredictionAmount;             ///< minimum prediction amount for pan gestures
227   int mPanGesturePredictionAmountAdjustment;      ///< adjustment of prediction amount for pan gestures
228   int mPanGestureSmoothingMode;                  ///< prediction mode for pan gestures
229   float mPanGestureSmoothingAmount;              ///< prediction amount for pan gestures
230   int mPanMinimumDistance;                        ///< minimum distance required before pan starts
231   int mPanMinimumEvents;                          ///< minimum events required before pan starts
232   int mGlesCallTime;                              ///< time in seconds between status updates
233
234   Dali::Integration::Log::LogFunction mLogFunction;
235
236   // Undefined copy constructor.
237   EnvironmentOptions( const EnvironmentOptions& );
238
239   // Undefined assignment operator.
240   EnvironmentOptions& operator=( const EnvironmentOptions& );
241
242 };
243
244 } // Adaptor
245 } // Internal
246 } // Dali
247
248 #endif // __DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H__