Dali 3D User Interface Engine
environment-options.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
19 #include "environment-options.h"
20 
21 // EXTERNAL INCLUDES
22 #include <cstdlib>
25 
26 // INTERNAL INCLUDES
28 
29 namespace Dali
30 {
31 
32 namespace Internal
33 {
34 
35 namespace Adaptor
36 {
37 
38 namespace
39 {
40 const unsigned int DEFAULT_STATISTICS_LOG_FREQUENCY = 2;
41 
42 unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
43 {
44  const char* variableParameter = std::getenv(variable);
45 
46  // if the parameter exists convert it to an integer, else return the default value
47  unsigned int intValue = variableParameter ? std::atoi(variableParameter) : defaultValue;
48  return intValue;
49 }
50 
51 bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
52 {
53  const char* variableParameter = std::getenv(variable);
54 
55  if( !variableParameter )
56  {
57  return false;
58  }
59  // if the parameter exists convert it to an integer, else return the default value
60  intValue = std::atoi(variableParameter);
61  return true;
62 }
63 
64 bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
65 {
66  const char* variableParameter = std::getenv(variable);
67 
68  if( !variableParameter )
69  {
70  return false;
71  }
72  // if the parameter exists convert it to an integer, else return the default value
73  floatValue = std::atof(variableParameter);
74  return true;
75 }
76 
77 const char * GetCharEnvironmentVariable( const char * variable )
78 {
79  return std::getenv( variable );
80 }
81 
82 } // unnamed namespace
83 
85 : mWindowName(),
86  mWindowClassName(),
87  mNetworkControl(0),
88  mFpsFrequency(0),
89  mUpdateStatusFrequency(0),
90  mObjectProfilerInterval( 0 ),
91  mPerformanceStatsLevel(0),
92  mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY ),
93  mPerformanceTimeStampOutput(0),
94  mPanGestureLoggingLevel(0),
95  mPanGesturePredictionMode(-1),
96  mPanGesturePredictionAmount(-1),
97  mPanGestureMaxPredictionAmount(-1),
98  mPanGestureMinPredictionAmount(-1),
99  mPanGesturePredictionAmountAdjustment(-1),
100  mPanGestureSmoothingMode(-1),
101  mPanGestureSmoothingAmount(-1.0f),
102  mPanMinimumDistance(-1),
103  mPanMinimumEvents(-1),
104  mGlesCallTime(0),
105  mWindowWidth( 0 ),
106  mWindowHeight( 0 ),
107  mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ),
108  mRenderRefreshRate( 1 ),
109  mLogFunction( NULL )
110 {
112 }
113 
115 {
116 }
117 
119 {
120  mLogFunction = logFunction;
121 }
122 
124 {
126 }
127 
129 {
131 }
132 
134 {
135  return mNetworkControl;
136 }
138 {
139  return mFpsFrequency;
140 }
141 
143 {
144  return mUpdateStatusFrequency;
145 }
146 
148 {
150 }
151 
153 {
154  return mPerformanceStatsLevel;
155 }
157 {
159 }
161 {
163 }
164 
166 {
168 }
169 
171 {
173 }
174 
176 {
178 }
179 
181 {
183 }
184 
186 {
188 }
189 
191 {
193 }
194 
196 {
198 }
199 
201 {
203 }
204 
206 {
207  return mPanMinimumDistance;
208 }
209 
211 {
212  return mPanMinimumEvents;
213 }
214 
216 {
217  return mWindowWidth;
218 }
219 
221 {
222  return mWindowHeight;
223 }
224 
226 {
227  return mGlesCallTime;
228 }
229 
230 const std::string& EnvironmentOptions::GetWindowName() const
231 {
232  return mWindowName;
233 }
234 
235 const std::string& EnvironmentOptions::GetWindowClassName() const
236 {
237  return mWindowClassName;
238 }
239 
241 {
242  return mThreadingMode;
243 }
244 
246 {
247  return mRenderRefreshRate;
248 }
249 
251 {
252  return ( ( GetPerformanceStatsLoggingOptions() > 0) ||
253  ( GetPerformanceTimeStampOutput() > 0 ) ||
254  ( GetNetworkControlMode() > 0) );
255 }
256 
258 {
259  // get logging options
268 
269  int predictionMode;
271  {
272  mPanGesturePredictionMode = predictionMode;
273  }
274  int predictionAmount(-1);
276  {
277  if( predictionAmount < 0 )
278  {
279  // do not support times in the past
280  predictionAmount = 0;
281  }
282  mPanGesturePredictionAmount = predictionAmount;
283  }
284  int minPredictionAmount(-1);
286  {
287  if( minPredictionAmount < 0 )
288  {
289  // do not support times in the past
290  minPredictionAmount = 0;
291  }
292  mPanGestureMinPredictionAmount = minPredictionAmount;
293  }
294  int maxPredictionAmount(-1);
296  {
297  if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
298  {
299  // maximum amount should not be smaller than minimum amount
300  maxPredictionAmount = minPredictionAmount;
301  }
302  mPanGestureMaxPredictionAmount = maxPredictionAmount;
303  }
304  int predictionAmountAdjustment(-1);
306  {
307  if( predictionAmountAdjustment < 0 )
308  {
309  // negative amount doesn't make sense
310  predictionAmountAdjustment = 0;
311  }
312  mPanGesturePredictionAmountAdjustment = predictionAmountAdjustment;
313  }
314  int smoothingMode;
316  {
317  mPanGestureSmoothingMode = smoothingMode;
318  }
319  float smoothingAmount = 1.0f;
321  {
322  smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
323  mPanGestureSmoothingAmount = smoothingAmount;
324  }
325 
326  int minimumDistance(-1);
328  {
329  mPanMinimumDistance = minimumDistance;
330  }
331 
332  int minimumEvents(-1);
334  {
335  mPanMinimumEvents = minimumEvents;
336  }
337 
338  int glesCallTime(0);
340  {
341  mGlesCallTime = glesCallTime;
342  }
343 
344  int windowWidth(0), windowHeight(0);
346  {
347  mWindowWidth = windowWidth;
348  mWindowHeight = windowHeight;
349  }
350 
351  const char * windowName = GetCharEnvironmentVariable( DALI_WINDOW_NAME );
352  if ( windowName )
353  {
354  mWindowName = windowName;
355  }
356 
357  const char * windowClassName = GetCharEnvironmentVariable( DALI_WINDOW_CLASS_NAME );
358  if ( windowClassName )
359  {
360  mWindowClassName = windowClassName;
361  }
362 
363  int threadingMode(0);
364  if ( GetIntegerEnvironmentVariable( DALI_THREADING_MODE, threadingMode ) )
365  {
366  switch( threadingMode )
367  {
371  {
372  mThreadingMode = static_cast< ThreadingMode::Type >( threadingMode );
373  break;
374  }
375  }
376  }
377 
378  int renderRefreshRate(0);
379  if ( GetIntegerEnvironmentVariable( DALI_REFRESH_RATE, renderRefreshRate ) )
380  {
381  // Only change it if it's valid
382  if( renderRefreshRate > 1 )
383  {
384  mRenderRefreshRate = renderRefreshRate;
385  }
386  }
387 }
388 
389 } // Adaptor
390 
391 } // Internal
392 
393 } // Dali
Dali Docs Home
Read more about Dali