(EnvironmentVariables)Added getter functions that take value by reference and return...
authorJulien Heanley <j.heanley@partner.samsung.com>
Wed, 23 Apr 2014 07:55:19 +0000 (08:55 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 10 Jun 2014 15:41:48 +0000 (16:41 +0100)
[Issue#]   N/A
[Problem]  Had to set default value for prediction mode in tizen specific adaptor
[Cause]
[Solution] Only set pan prediction mode if variable has been set

Change-Id: I802ac63bbcaa76281d3e9da7aca4f477cbb2af1c

adaptors/base/environment-options.cpp
adaptors/base/environment-options.h
adaptors/tizen/internal/common/adaptor-impl.cpp

index 30c999e..7740908 100644 (file)
@@ -32,6 +32,7 @@ EnvironmentOptions::EnvironmentOptions()
   mUpdateStatusFrequency(0),
   mPerformanceLoggingLevel(0),
   mPanGestureLoggingLevel(0),
+  mPanGesturePredictionMode(-1),
   mLogFunction( NULL )
 {
 }
index 625cb06..3cb893c 100644 (file)
@@ -107,7 +107,7 @@ private:
   unsigned int mUpdateStatusFrequency;            ///< how often update status is logged out in frames
   unsigned int mPerformanceLoggingLevel;          ///< performance log level
   unsigned int mPanGestureLoggingLevel;           ///< pan-gesture log level
-  unsigned int mPanGesturePredictionMode;         ///< prediction mode for pan gestures
+  int mPanGesturePredictionMode;                  ///< prediction mode for pan gestures
 
   Dali::Integration::Log::LogFunction mLogFunction;
 
index b47e5d1..e56de30 100644 (file)
@@ -76,6 +76,41 @@ unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int d
   unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
   return intValue;
 }
+
+bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
+{
+  const char* variableParameter = std::getenv(variable);
+
+  if( !variableParameter )
+  {
+    return false;
+  }
+  // if the parameter exists convert it to an integer, else return the default value
+  intValue = atoi(variableParameter);
+  return true;
+}
+
+bool GetBooleanEnvironmentVariable( const char* variable, bool& boolValue )
+{
+  const char* variableParameter = std::getenv(variable);
+
+  boolValue = variableParameter ? true : false;
+  return boolValue;
+}
+
+bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
+{
+  const char* variableParameter = std::getenv(variable);
+
+  if( !variableParameter )
+  {
+    return false;
+  }
+  // if the parameter exists convert it to an integer, else return the default value
+  floatValue = atof(variableParameter);
+  return true;
+}
+
 } // unnamed namespace
 
 Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout )
@@ -103,7 +138,12 @@ void Adaptor::ParseEnvironmentOptions()
   Dali::Integration::Log::LogFunction  logFunction(Dali::SlpPlatform::LogMessage);
 
   mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceLevel, logPanGesture );
-  mEnvironmentOptions.SetPanGesturePredictionMode(GetIntegerEnvironmentVariable( DALI_ENV_PAN_PREDICTION_MODE, 1));
+
+  int predictionMode;
+  if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
+  {
+    mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
+  }
 
   mEnvironmentOptions.InstallLogFunction();
 }
@@ -148,7 +188,10 @@ void Adaptor::Initialize()
   {
     Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
   }
-  Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
+  if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
+  {
+    Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
+  }
 }
 
 Adaptor::~Adaptor()