Memory Pool Logging
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / environment-options.h
1 #ifndef DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H
2 #define DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H
3
4 /*
5  * Copyright (c) 2022 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 INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <memory>
24
25 // INTERNAL INCLUDES
26 #include <dali/integration-api/adaptor-framework/log-factory-interface.h>
27 #include <dali/internal/adaptor/common/threading-mode.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Adaptor
34 {
35 class TraceManager;
36 class PerformanceInterface;
37
38 /**
39  * This class provides the environment options which define settings as well as
40  * the ability to install a log function.
41  *
42  */
43 class EnvironmentOptions : public Dali::LogFactoryInterface
44 {
45 public:
46   /**
47    * Constructor
48    */
49   EnvironmentOptions();
50
51   /**
52    * Virtual Destructor for interface cleanup
53    */
54   virtual ~EnvironmentOptions();
55
56   /**
57    * Create a TraceManager which is used for tracing.
58    * @param PerformanceInterface for using network logging for tracing on Ubuntu
59    */
60   void CreateTraceManager(PerformanceInterface* performanceInterface);
61
62   /**
63    * Initialize TraceManager by installing Trace function.
64    */
65   void InstallTraceFunction() const;
66
67   /**
68    * @param logFunction logging function
69    */
70   void SetLogFunction(const Dali::Integration::Log::LogFunction& logFunction);
71
72   /**
73    * Install the log function for the current thread.
74    */
75   void InstallLogFunction() const override;
76
77   /**
78    * Un-install the log function for the current thread.
79    */
80   void UnInstallLogFunction() const;
81
82   /**
83    * @return whether network control is enabled or not ( 0 = off, 1 = on )
84    */
85   unsigned int GetNetworkControlMode() const;
86
87   /**
88    * @return frequency of how often FPS is logged out (e.g. 0 = off, 2 = every 2 seconds).
89    */
90   unsigned int GetFrameRateLoggingFrequency() const;
91
92   /**
93    * @return frequency of how often Update Status is logged out (e.g. 0 = off, 60 = log every 60 frames = 1 second @ 60FPS).
94    */
95   unsigned int GetUpdateStatusLoggingFrequency() const;
96
97   /**
98    * @return object profiler status interval ( 0 == off )
99    */
100   unsigned int GetObjectProfilerInterval() const;
101
102   /**
103    * @return memory pool status interval (0==off)
104    */
105   unsigned int GetMemoryPoolInterval() const;
106
107   /**
108    * @return performance statistics log level ( 0 == off )
109    */
110   unsigned int GetPerformanceStatsLoggingOptions() const;
111
112   /**
113    * @return performance statistics log frequency in seconds
114    */
115   unsigned int GetPerformanceStatsLoggingFrequency() const;
116
117   /**
118    * @return performance time stamp output ( 0 == off)
119    */
120   unsigned int GetPerformanceTimeStampOutput() const;
121
122   /**
123    * @return pan-gesture logging level ( 0 == off )
124    */
125   unsigned int GetPanGestureLoggingLevel() const;
126
127   /**
128    * @return pan-gesture prediction mode ( -1 means not set so no prediction, 0 = no prediction )
129    */
130   int GetPanGesturePredictionMode() const;
131
132   /**
133    * @return pan-gesture prediction amount
134    */
135   int GetPanGesturePredictionAmount() const;
136
137   /**
138    * @return maximum pan-gesture prediction amount
139    */
140   int GetPanGestureMaximumPredictionAmount() const;
141
142   /**
143    * @return minimum pan-gesture prediction amount
144    */
145   int GetPanGestureMinimumPredictionAmount() const;
146
147   /**
148    * @brief Gets the prediction amount to adjust when the pan velocity is changed.
149    *
150    * If the pan velocity is accelerating, the prediction amount will be increased
151    * by the specified amount until it reaches the upper bound. If the pan velocity
152    * is decelerating, the prediction amount will be decreased by the specified
153    * amount until it reaches the lower bound.
154    *
155    * @return pan-gesture prediction amount adjustment
156    */
157   int GetPanGesturePredictionAmountAdjustment() const;
158
159   /**
160    * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing )
161    */
162   int GetPanGestureSmoothingMode() const;
163
164   /**
165    * @return pan-gesture smoothing amount
166    */
167   float GetPanGestureSmoothingAmount() const;
168
169   /**
170    * @return pan-gesture use actual times is true if real gesture and frame times are to be used.
171    */
172   int GetPanGestureUseActualTimes() const;
173
174   /**
175    * @return pan-gesture interpolation time range is the time range (ms) of past points to use (with weights) when interpolating.
176    */
177   int GetPanGestureInterpolationTimeRange() const;
178
179   /**
180    * @return pan-gesture scalar only prediction, when enabled, ignores acceleration.
181    */
182   int GetPanGestureScalarOnlyPredictionEnabled() const;
183
184   /**
185    * @return pan-gesture two point prediction combines two interpolated points to get more steady acceleration and velocity values.
186    */
187   int GetPanGestureTwoPointPredictionEnabled() const;
188
189   /**
190    * @return pan-gesture two point interpolate past time is the time delta (ms) in the past to interpolate the second point.
191    */
192   int GetPanGestureTwoPointInterpolatePastTime() const;
193
194   /**
195    * @return pan-gesture two point velocity bias is the ratio of first and second points to use for velocity.
196    * 0.0f = 100% of first point. 1.0f = 100% of second point.
197    */
198   float GetPanGestureTwoPointVelocityBias() const;
199
200   /**
201    * @return pan-gesture two point acceleration bias is the ratio of first and second points to use for acceleration.
202    * 0.0f = 100% of first point. 1.0f = 100% of second point.
203    */
204   float GetPanGestureTwoPointAccelerationBias() const;
205
206   /**
207    * @return pan-gesture multitap smoothing range is the range in time (ms) of points in the history to smooth the final output against.
208    */
209   int GetPanGestureMultitapSmoothingRange() const;
210
211   /**
212    * @return The minimum distance before a pan can be started (-1 means it's not set)
213    */
214   int GetMinimumPanDistance() const;
215
216   /**
217    * @return The minimum events before a pan can be started (-1 means it's not set)
218    */
219   int GetMinimumPanEvents() const;
220
221   /**
222    * @return The minimum pixels before a pinch can be started (-1 means it's not set)
223    */
224   float GetMinimumPinchDistance() const;
225
226   /**
227    * @return The minimum touch events required before a pinch can be started (-1 means it's not set)
228    */
229   int GetMinimumPinchTouchEvents() const;
230
231   /**
232    * @return The minimum touch events required after a pinch started (-1 means it's not set)
233    */
234   int GetMinimumPinchTouchEventsAfterStart() const;
235
236   /**
237    * @return The minimum touch events required before a rotation can be started (-1 means it's not set)
238    */
239   int GetMinimumRotationTouchEvents() const;
240
241   /**
242    * @return The minimum touch events required after a rotation started (-1 means it's not set)
243    */
244   int GetMinimumRotationTouchEventsAfterStart() const;
245
246   /**
247    * @return The minimum holding time required to be recognized as a long press gesture (milliseconds)
248    */
249   int GetLongPressMinimumHoldingTime() const;
250
251   /**
252    * @return The maximum allowed time required to be recognized as a multi tap gesture (millisecond)
253    */
254   int GetTapMaximumAllowedTime() const;
255
256   /**
257    * @return The width of the window
258    */
259   unsigned int GetWindowWidth() const;
260
261   /**
262    * @return The height of the window
263    */
264   unsigned int GetWindowHeight() const;
265
266   /**
267    * @brief Get the graphics status time
268    */
269   int GetGlesCallTime() const;
270
271   /**
272    * @brief Get whether or not to accumulate gles call statistics
273    */
274   bool GetGlesCallAccumulate() const;
275
276   /**
277    * @return true if performance server is required
278    */
279   bool PerformanceServerRequired() const;
280
281   /**
282    * @return Gets the window name.
283    */
284   const std::string& GetWindowName() const;
285
286   /**
287    * @return Gets the window class.
288    */
289   const std::string& GetWindowClassName() const;
290
291   /**
292    * @return The thread mode that DALi should use.
293    */
294   ThreadingMode::Type GetThreadingMode() const;
295
296   /**
297    * @return The render refresh rate.
298    */
299   unsigned int GetRenderRefreshRate() const;
300
301   /**
302    * @return The number of samples required in multisample buffers
303    */
304   int GetMultiSamplingLevel() const;
305
306   /**
307    * @return The maximum texture size
308    */
309   unsigned int GetMaxTextureSize() const;
310
311   /**
312    * @brief Retrieves the interval of frames to be rendered into the Frame Buffer Object and the Frame Buffer.
313    *
314    * @return The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
315    */
316   unsigned int GetRenderToFboInterval() const;
317
318   /**
319    * @return Whether the depth buffer is required.
320    */
321   bool DepthBufferRequired() const;
322
323   /**
324    * @return Whether the stencil buffer is required.
325    */
326   bool StencilBufferRequired() const;
327
328   /**
329    * @return Whether the partial update is required.
330    */
331   bool PartialUpdateRequired() const;
332
333   /// Deleted copy constructor.
334   EnvironmentOptions(const EnvironmentOptions&) = delete;
335
336   /// Deleted move constructor.
337   EnvironmentOptions(const EnvironmentOptions&&) = delete;
338
339   /// Deleted assignment operator.
340   EnvironmentOptions& operator=(const EnvironmentOptions&) = delete;
341
342   /// Deleted move assignment operator.
343   EnvironmentOptions& operator=(const EnvironmentOptions&&) = delete;
344
345 private: // Internal
346   /**
347    * Parses the environment options.
348    * Called from the constructor
349    */
350   void ParseEnvironmentOptions();
351
352 private: // Data
353   Dali::Integration::Log::LogFunction mLogFunction;
354
355   std::string mWindowName;      ///< name of the window
356   std::string mWindowClassName; ///< name of the class the window belongs to
357
358   unsigned int mNetworkControl;             ///< whether network control is enabled
359   unsigned int mFpsFrequency;               ///< how often fps is logged out in seconds
360   unsigned int mUpdateStatusFrequency;      ///< how often update status is logged out in frames
361   unsigned int mObjectProfilerInterval;     ///< how often object counts are logged out in seconds
362   uint32_t     mMemoryPoolInterval;         ///< how often memory pool capacities are logged out in seconds
363   unsigned int mPerformanceStatsLevel;      ///< performance statistics logging bitmask
364   unsigned int mPerformanceStatsFrequency;  ///< performance statistics logging frequency (seconds)
365   unsigned int mPerformanceTimeStampOutput; ///< performance time stamp output ( bitmask)
366   unsigned int mPanGestureLoggingLevel;     ///< pan-gesture log level
367   unsigned int mWindowWidth;                ///< width of the window
368   unsigned int mWindowHeight;               ///< height of the window
369   unsigned int mRenderRefreshRate;          ///< render refresh rate
370   unsigned int mMaxTextureSize;             ///< The maximum texture size that GL can handle
371   unsigned int mRenderToFboInterval;        ///< The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
372
373   int   mPanGesturePredictionMode;              ///< prediction mode for pan gestures
374   int   mPanGesturePredictionAmount;            ///< prediction amount for pan gestures
375   int   mPanGestureMaxPredictionAmount;         ///< maximum prediction amount for pan gestures
376   int   mPanGestureMinPredictionAmount;         ///< minimum prediction amount for pan gestures
377   int   mPanGesturePredictionAmountAdjustment;  ///< adjustment of prediction amount for pan gestures
378   int   mPanGestureSmoothingMode;               ///< prediction mode for pan gestures
379   float mPanGestureSmoothingAmount;             ///< prediction amount for pan gestures
380   int   mPanGestureUseActualTimes;              ///< Disable to optionally override actual times if they make results worse.
381   int   mPanGestureInterpolationTimeRange;      ///< Time into past history (ms) to use points to interpolate the first point.
382   int   mPanGestureScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
383   int   mPanGestureTwoPointPredictionEnabled;   ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
384   int   mPanGestureTwoPointInterpolatePastTime; ///< The target time in the past to generate the second interpolated point.
385   float mPanGestureTwoPointVelocityBias;        ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
386   float mPanGestureTwoPointAccelerationBias;    ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
387   int   mPanGestureMultitapSmoothingRange;      ///< The range in time (ms) of points in the history to smooth the final output against.
388   int   mPanMinimumDistance;                    ///< minimum distance required before pan starts
389   int   mPanMinimumEvents;                      ///< minimum events required before pan starts
390   float mPinchMinimumDistance;                  ///< minimum number of pixels moved before a pinch starts
391   int   mPinchMinimumTouchEvents;               ///< minimum events required before a pinch starts
392   int   mPinchMinimumTouchEventsAfterStart;     ///< minimum events required after a pinch started
393   int   mRotationMinimumTouchEvents;            ///< minimum events required before a rotation starts
394   int   mRotationMinimumTouchEventsAfterStart;  ///< minimum events required after a rotation started
395   int   mLongPressMinimumHoldingTime;           ///< minimum holding time required to be recognized as a long press gesture (millisecond)
396   int   mTapMaximumAllowedTime;                 ///< maximum allowed time required to be recognized as a multi tap gesture (millisecond)
397   int   mGlesCallTime;                          ///< time in seconds between status updates
398   int   mMultiSamplingLevel;                    ///< The number of samples required in multisample buffers
399
400   ThreadingMode::Type mThreadingMode; ///< threading mode
401
402   bool mGlesCallAccumulate;    ///< Whether or not to accumulate gles call statistics
403   bool mDepthBufferRequired;   ///< Whether the depth buffer is required
404   bool mStencilBufferRequired; ///< Whether the stencil buffer is required
405   bool mPartialUpdateRequired; ///< Whether the partial update is required
406
407   std::unique_ptr<TraceManager> mTraceManager; ///< TraceManager
408 };
409
410 } // namespace Adaptor
411 } // namespace Internal
412 } // namespace Dali
413
414 #endif // DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H