From 6dd60757348339ece6882a62a5b9057ba460c88f Mon Sep 17 00:00:00 2001 From: Julien Heanley Date: Wed, 23 Apr 2014 08:55:19 +0100 Subject: [PATCH] (EnvironmentVariables)Added getter functions that take value by reference and return whether it was even set [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 | 1 + adaptors/base/environment-options.h | 2 +- adaptors/tizen/internal/common/adaptor-impl.cpp | 47 +++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/adaptors/base/environment-options.cpp b/adaptors/base/environment-options.cpp index 30c999e..7740908 100644 --- a/adaptors/base/environment-options.cpp +++ b/adaptors/base/environment-options.cpp @@ -32,6 +32,7 @@ EnvironmentOptions::EnvironmentOptions() mUpdateStatusFrequency(0), mPerformanceLoggingLevel(0), mPanGestureLoggingLevel(0), + mPanGesturePredictionMode(-1), mLogFunction( NULL ) { } diff --git a/adaptors/base/environment-options.h b/adaptors/base/environment-options.h index 625cb06..3cb893c 100644 --- a/adaptors/base/environment-options.h +++ b/adaptors/base/environment-options.h @@ -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; diff --git a/adaptors/tizen/internal/common/adaptor-impl.cpp b/adaptors/tizen/internal/common/adaptor-impl.cpp index b47e5d1..e56de30 100644 --- a/adaptors/tizen/internal/common/adaptor-impl.cpp +++ b/adaptors/tizen/internal/common/adaptor-impl.cpp @@ -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() -- 2.7.4