From 94d03d1297d87ebe8f2680cd743df1aeed61a4a3 Mon Sep 17 00:00:00 2001 From: Julien Heanley Date: Thu, 26 Jun 2014 10:04:17 +0100 Subject: [PATCH] Pan Gesture Smoothing - Added APIs to change smoothing mode and amount DALI_PAN_SMOOTHING_MODE - Currently only 0 for off and 1 for a simple smoothing technique DALI_PAN_SMOOTHING_AMOUNT - From 0.0f for no smoothing to 1.0f for full smoothing [problem] Predicted panning is a little jittery at times [cause] Any slight error in touch data could skew the calculations a little [solution] Added smoothing phase Change-Id: Ifc573419a63904fdadbc169fbeefd9dcae27dc0b Signed-off-by: Adeel Kazmi --- adaptors/base/environment-options.cpp | 28 +++++++++++++++++--- adaptors/base/environment-options.h | 34 ++++++++++++++++++++++--- adaptors/base/environment-variables.h | 4 +++ adaptors/tizen/internal/common/adaptor-impl.cpp | 23 +++++++++++++++-- 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/adaptors/base/environment-options.cpp b/adaptors/base/environment-options.cpp index 764a159..6ef540b 100644 --- a/adaptors/base/environment-options.cpp +++ b/adaptors/base/environment-options.cpp @@ -34,6 +34,8 @@ EnvironmentOptions::EnvironmentOptions() mPanGestureLoggingLevel(0), mPanGesturePredictionMode(-1), mPanGesturePredictionAmount(-1.0f), ///< only sets value in pan gesture if greater than 0 + mPanGestureSmoothingMode(-1), + mPanGestureSmoothingAmount(-1.0f), mPanMinimumDistance(-1), mPanMinimumEvents(-1), mLogFunction( NULL ) @@ -87,7 +89,7 @@ unsigned int EnvironmentOptions::GetPanGestureLoggingLevel() const return mPanGestureLoggingLevel; } -int EnvironmentOptions::GetPanGestureSmoothingMode() const +int EnvironmentOptions::GetPanGesturePredictionMode() const { return mPanGesturePredictionMode; } @@ -97,6 +99,16 @@ float EnvironmentOptions::GetPanGesturePredictionAmount() const return mPanGesturePredictionAmount; } +int EnvironmentOptions::GetPanGestureSmoothingMode() const +{ + return mPanGestureSmoothingMode; +} + +float EnvironmentOptions::GetPanGestureSmoothingAmount() const +{ + return mPanGestureSmoothingAmount; +} + int EnvironmentOptions::GetMinimumPanDistance() const { return mPanMinimumDistance; @@ -107,16 +119,26 @@ int EnvironmentOptions::GetMinimumPanEvents() const return mPanMinimumEvents; } -void EnvironmentOptions::SetPanGesturePredictionMode(unsigned int mode) +void EnvironmentOptions::SetPanGesturePredictionMode( unsigned int mode ) { mPanGesturePredictionMode = mode; } -void EnvironmentOptions::SetPanGesturePredictionAmount(unsigned int amount) +void EnvironmentOptions::SetPanGesturePredictionAmount( unsigned int amount ) { mPanGesturePredictionAmount = amount; } +void EnvironmentOptions::SetPanGestureSmoothingMode( unsigned int mode ) +{ + mPanGestureSmoothingMode = mode; +} + +void EnvironmentOptions::SetPanGestureSmoothingAmount( float amount ) +{ + mPanGestureSmoothingAmount = amount; +} + void EnvironmentOptions::SetMinimumPanDistance( int distance ) { mPanMinimumDistance = distance; diff --git a/adaptors/base/environment-options.h b/adaptors/base/environment-options.h index 1ff9a8b..2ba26d0 100644 --- a/adaptors/base/environment-options.h +++ b/adaptors/base/environment-options.h @@ -90,9 +90,9 @@ public: unsigned int GetPanGestureLoggingLevel() const; /** - * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing ) + * @return pan-gesture prediction mode ( -1 means not set so no prediction, 0 = no prediction ) */ - int GetPanGestureSmoothingMode() const; + int GetPanGesturePredictionMode() const; /** * @return pan-gesture prediction amount @@ -100,6 +100,16 @@ public: float GetPanGesturePredictionAmount() const; /** + * @return pan-gesture smoothing mode ( -1 means not set so no smoothing, 0 = no smoothing ) + */ + int GetPanGestureSmoothingMode() const; + + /** + * @return pan-gesture smoothing amount + */ + float GetPanGestureSmoothingAmount() const; + + /** * @return The minimum distance before a pan can be started (-1 means it's not set) */ int GetMinimumPanDistance() const; @@ -114,14 +124,28 @@ public: * * @param[in] mode The smoothing mode to use */ - void SetPanGesturePredictionMode(unsigned int mode); + void SetPanGesturePredictionMode( unsigned int mode ); /** * @brief Sets the prediction amount of the pan gesture * * @param[in] amount The prediction amount in milliseconds */ - void SetPanGesturePredictionAmount(unsigned int amount); + void SetPanGesturePredictionAmount( unsigned int amount ); + + /** + * @brief Called to set how pan gestures smooth input + * + * @param[in] mode The smoothing mode to use + */ + void SetPanGestureSmoothingMode( unsigned int mode ); + + /** + * @brief Sets the prediction amount of the pan gesture + * + * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing + */ + void SetPanGestureSmoothingAmount( float amount ); /** * @brief Sets the minimum distance required before a pan starts @@ -145,6 +169,8 @@ private: unsigned int mPanGestureLoggingLevel; ///< pan-gesture log level int mPanGesturePredictionMode; ///< prediction mode for pan gestures float mPanGesturePredictionAmount; ///< prediction amount for pan gestures + int mPanGestureSmoothingMode; ///< prediction mode for pan gestures + float mPanGestureSmoothingAmount; ///< prediction amount for pan gestures int mPanMinimumDistance; ///< minimum distance required before pan starts int mPanMinimumEvents; ///< minimum events required before pan starts diff --git a/adaptors/base/environment-variables.h b/adaptors/base/environment-variables.h index f240292..dbe7513 100644 --- a/adaptors/base/environment-variables.h +++ b/adaptors/base/environment-variables.h @@ -35,6 +35,10 @@ namespace Adaptor #define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT" +#define DALI_ENV_PAN_SMOOTHING_MODE "DALI_PAN_SMOOTHING_MODE" + +#define DALI_ENV_PAN_SMOOTHING_AMOUNT "DALI_PAN_SMOOTHING_AMOUNT" + #define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE" #define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS" diff --git a/adaptors/tizen/internal/common/adaptor-impl.cpp b/adaptors/tizen/internal/common/adaptor-impl.cpp index 6e09188..16c53e0 100644 --- a/adaptors/tizen/internal/common/adaptor-impl.cpp +++ b/adaptors/tizen/internal/common/adaptor-impl.cpp @@ -154,6 +154,17 @@ void Adaptor::ParseEnvironmentOptions() } mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount); } + int smoothingMode; + if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) ) + { + mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode); + } + float smoothingAmount = 1.0f; + if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) ) + { + smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f); + mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount); + } int minimumDistance(-1); if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance )) @@ -210,14 +221,22 @@ void Adaptor::Initialize() { Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE ); } - if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 ) + if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 ) { - Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGestureSmoothingMode()); + Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode()); } if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0.0f ) { Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount()); } + if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 ) + { + Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode()); + } + if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f ) + { + Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount()); + } } Adaptor::~Adaptor() -- 2.7.4