From 4b464f187d39773bb79bd1b00a531af113e0dafd Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Tue, 28 Feb 2017 15:24:04 +0900 Subject: [PATCH] [3.0] pan-gesture code refactor and environment variables Change-Id: Idc6902b3f9a3d0e4b847940851aa851af60dc98e --- adaptors/base/environment-options.cpp | 140 ++++++++++++++++++++++++++++++---- adaptors/base/environment-options.h | 50 ++++++++++++ adaptors/base/environment-variables.h | 45 ++++++----- adaptors/common/adaptor-impl.cpp | 32 ++++++++ 4 files changed, 233 insertions(+), 34 deletions(-) diff --git a/adaptors/base/environment-options.cpp b/adaptors/base/environment-options.cpp index a029a30..0866eeb 100644 --- a/adaptors/base/environment-options.cpp +++ b/adaptors/base/environment-options.cpp @@ -84,23 +84,31 @@ const char * GetCharEnvironmentVariable( const char * variable ) EnvironmentOptions::EnvironmentOptions() : mWindowName(), mWindowClassName(), - mNetworkControl(0), - mFpsFrequency(0), - mUpdateStatusFrequency(0), + mNetworkControl( 0 ), + mFpsFrequency( 0 ), + mUpdateStatusFrequency( 0 ), mObjectProfilerInterval( 0 ), - mPerformanceStatsLevel(0), + mPerformanceStatsLevel( 0 ), mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY ), - mPerformanceTimeStampOutput(0), - mPanGestureLoggingLevel(0), - mPanGesturePredictionMode(-1), - mPanGesturePredictionAmount(-1), ///< only sets value in pan gesture if greater than 0 - mPanGestureMaxPredictionAmount(-1), - mPanGestureMinPredictionAmount(-1), - mPanGesturePredictionAmountAdjustment(-1), - mPanGestureSmoothingMode(-1), - mPanGestureSmoothingAmount(-1.0f), - mPanMinimumDistance(-1), - mPanMinimumEvents(-1), + mPerformanceTimeStampOutput( 0 ), + mPanGestureLoggingLevel( 0 ), + mPanGesturePredictionMode( -1 ), + mPanGesturePredictionAmount( -1 ), ///< only sets value in pan gesture if greater than 0 + mPanGestureMaxPredictionAmount( -1 ), + mPanGestureMinPredictionAmount( -1 ), + mPanGesturePredictionAmountAdjustment( -1 ), + mPanGestureSmoothingMode( -1 ), + mPanGestureSmoothingAmount( -1.0f ), + mPanGestureUseActualTimes( -1 ), + mPanGestureInterpolationTimeRange( -1 ), + mPanGestureScalarOnlyPredictionEnabled( -1 ), + mPanGestureTwoPointPredictionEnabled( -1 ), + mPanGestureTwoPointInterpolatePastTime( -1 ), + mPanGestureTwoPointVelocityBias( -1.0f ), + mPanGestureTwoPointAccelerationBias( -1.0f ), + mPanGestureMultitapSmoothingRange( -1 ), + mPanMinimumDistance( -1 ), + mPanMinimumEvents( -1 ), mGlesCallTime( 0 ), mWindowWidth( 0 ), mWindowHeight( 0 ), @@ -203,6 +211,46 @@ float EnvironmentOptions::GetPanGestureSmoothingAmount() const return mPanGestureSmoothingAmount; } +int EnvironmentOptions::GetPanGestureUseActualTimes() const +{ + return mPanGestureUseActualTimes; +} + +int EnvironmentOptions::GetPanGestureInterpolationTimeRange() const +{ + return mPanGestureInterpolationTimeRange; +} + +int EnvironmentOptions::GetPanGestureScalarOnlyPredictionEnabled() const +{ + return mPanGestureScalarOnlyPredictionEnabled; +} + +int EnvironmentOptions::GetPanGestureTwoPointPredictionEnabled() const +{ + return mPanGestureTwoPointPredictionEnabled; +} + +int EnvironmentOptions::GetPanGestureTwoPointInterpolatePastTime() const +{ + return mPanGestureTwoPointInterpolatePastTime; +} + +float EnvironmentOptions::GetPanGestureTwoPointVelocityBias() const +{ + return mPanGestureTwoPointVelocityBias; +} + +float EnvironmentOptions::GetPanGestureTwoPointAccelerationBias() const +{ + return mPanGestureTwoPointAccelerationBias; +} + +int EnvironmentOptions::GetPanGestureMultitapSmoothingRange() const +{ + return mPanGestureMultitapSmoothingRange; +} + int EnvironmentOptions::GetMinimumPanDistance() const { return mPanMinimumDistance; @@ -329,6 +377,68 @@ void EnvironmentOptions::ParseEnvironmentOptions() mPanGestureSmoothingAmount = smoothingAmount; } + int useActualTimes( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_USE_ACTUAL_TIMES, useActualTimes ) ) + { + mPanGestureUseActualTimes = useActualTimes == 0 ? 0 : 1; + } + + int interpolationTimeRange( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_INTERPOLATION_TIME_RANGE, interpolationTimeRange ) ) + { + if( interpolationTimeRange < 0 ) + { + interpolationTimeRange = 0; + } + mPanGestureInterpolationTimeRange = interpolationTimeRange; + } + + int scalarOnlyPredictionEnabled( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_SCALAR_ONLY_PREDICTION_ENABLED, scalarOnlyPredictionEnabled ) ) + { + mPanGestureScalarOnlyPredictionEnabled = scalarOnlyPredictionEnabled == 0 ? 0 : 1; + } + + int twoPointPredictionEnabled( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_PREDICTION_ENABLED, twoPointPredictionEnabled ) ) + { + mPanGestureTwoPointPredictionEnabled = twoPointPredictionEnabled == 0 ? 0 : 1; + } + + int twoPointPastInterpolateTime( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_PAST_INTERPOLATE_TIME, twoPointPastInterpolateTime ) ) + { + if( twoPointPastInterpolateTime < 0 ) + { + twoPointPastInterpolateTime = 0; + } + mPanGestureTwoPointInterpolatePastTime = twoPointPastInterpolateTime; + } + + float twoPointVelocityBias = -1.0f; + if( GetFloatEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_VELOCITY_BIAS, twoPointVelocityBias ) ) + { + twoPointVelocityBias = Clamp( twoPointVelocityBias, 0.0f, 1.0f ); + mPanGestureTwoPointVelocityBias = twoPointVelocityBias; + } + + float twoPointAccelerationBias = -1.0f; + if( GetFloatEnvironmentVariable( DALI_ENV_PAN_TWO_POINT_ACCELERATION_BIAS, twoPointAccelerationBias ) ) + { + twoPointAccelerationBias = Clamp( twoPointAccelerationBias, 0.0f, 1.0f ); + mPanGestureTwoPointAccelerationBias = twoPointAccelerationBias; + } + + int multitapSmoothingRange( -1 ); + if( GetIntegerEnvironmentVariable( DALI_ENV_PAN_MULTITAP_SMOOTHING_RANGE, multitapSmoothingRange ) ) + { + if( multitapSmoothingRange < 0 ) + { + multitapSmoothingRange = 0; + } + mPanGestureMultitapSmoothingRange = multitapSmoothingRange; + } + int minimumDistance(-1); if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance )) { diff --git a/adaptors/base/environment-options.h b/adaptors/base/environment-options.h index 792f8ba..a677d2e 100644 --- a/adaptors/base/environment-options.h +++ b/adaptors/base/environment-options.h @@ -149,6 +149,48 @@ public: float GetPanGestureSmoothingAmount() const; /** + * @return pan-gesture use actual times is true if real gesture and frame times are to be used. + */ + int GetPanGestureUseActualTimes() const; + + /** + * @return pan-gesture interpolation time range is the time range (ms) of past points to use (with weights) when interpolating. + */ + int GetPanGestureInterpolationTimeRange() const; + + /** + * @return pan-gesture scalar only prediction, when enabled, ignores acceleration. + */ + int GetPanGestureScalarOnlyPredictionEnabled() const; + + /** + * @return pan-gesture two point prediction combines two interpolated points to get more steady acceleration and velocity values. + */ + int GetPanGestureTwoPointPredictionEnabled() const; + + /** + * @return pan-gesture two point interpolate past time is the time delta (ms) in the past to interpolate the second point. + */ + int GetPanGestureTwoPointInterpolatePastTime() const; + + /** + * @return pan-gesture two point velocity bias is the ratio of first and second points to use for velocity. + * 0.0f = 100% of first point. 1.0f = 100% of second point. + */ + float GetPanGestureTwoPointVelocityBias() const; + + /** + * @return pan-gesture two point acceleration bias is the ratio of first and second points to use for acceleration. + * 0.0f = 100% of first point. 1.0f = 100% of second point. + */ + float GetPanGestureTwoPointAccelerationBias() const; + + /** + * @return pan-gesture multitap smoothing range is the range in time (ms) of points in the history to smooth the final output against. + */ + int GetPanGestureMultitapSmoothingRange() const; + + /** * @return The minimum distance before a pan can be started (-1 means it's not set) */ int GetMinimumPanDistance() const; @@ -230,6 +272,14 @@ private: // Data int mPanGesturePredictionAmountAdjustment; ///< adjustment of prediction amount for pan gestures int mPanGestureSmoothingMode; ///< prediction mode for pan gestures float mPanGestureSmoothingAmount; ///< prediction amount for pan gestures + int mPanGestureUseActualTimes; ///< Disable to optionally override actual times if they make results worse. + int mPanGestureInterpolationTimeRange; ///< Time into past history (ms) to use points to interpolate the first point. + int mPanGestureScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration). + int mPanGestureTwoPointPredictionEnabled; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values. + int mPanGestureTwoPointInterpolatePastTime; ///< The target time in the past to generate the second interpolated point. + 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. + 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. + int mPanGestureMultitapSmoothingRange; ///< The range in time (ms) of points in the history to smooth the final output against. int mPanMinimumDistance; ///< minimum distance required before pan starts int mPanMinimumEvents; ///< minimum events required before pan starts int mGlesCallTime; ///< time in seconds between status updates diff --git a/adaptors/base/environment-variables.h b/adaptors/base/environment-variables.h index a3c2963..3ca08cb 100644 --- a/adaptors/base/environment-variables.h +++ b/adaptors/base/environment-variables.h @@ -57,25 +57,32 @@ namespace Adaptor #define DALI_ENV_OBJECT_PROFILER_INTERVAL "DALI_OBJECT_PROFILER_INTERVAL" -#define DALI_ENV_LOG_PAN_GESTURE "DALI_LOG_PAN_GESTURE" - -#define DALI_ENV_PAN_PREDICTION_MODE "DALI_PAN_PREDICTION_MODE" - -#define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT" - -#define DALI_ENV_PAN_MAX_PREDICTION_AMOUNT "DALI_PAN_MAX_PREDICTION_AMOUNT" - -#define DALI_ENV_PAN_MIN_PREDICTION_AMOUNT "DALI_PAN_MIN_PREDICTION_AMOUNT" - -#define DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT "DALI_PAN_PREDICTION_AMOUNT_ADJUSTMENT" - -#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" +// Pan-Gesture configuration: +// Prediction Modes 1 & 2: +#define DALI_ENV_PAN_PREDICTION_MODE "DALI_PAN_PREDICTION_MODE" +#define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT" +#define DALI_ENV_PAN_SMOOTHING_MODE "DALI_PAN_SMOOTHING_MODE" + +// Prediction Mode 1: +#define DALI_ENV_PAN_MAX_PREDICTION_AMOUNT "DALI_PAN_MAX_PREDICTION_AMOUNT" +#define DALI_ENV_PAN_MIN_PREDICTION_AMOUNT "DALI_PAN_MIN_PREDICTION_AMOUNT" +#define DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT "DALI_PAN_PREDICTION_AMOUNT_ADJUSTMENT" +#define DALI_ENV_PAN_SMOOTHING_AMOUNT "DALI_PAN_SMOOTHING_AMOUNT" + +// Prediction Mode 2: +#define DALI_ENV_PAN_USE_ACTUAL_TIMES "DALI_PAN_USE_ACTUAL_TIMES" +#define DALI_ENV_PAN_INTERPOLATION_TIME_RANGE "DALI_PAN_INTERPOLATION_TIME_RANGE" +#define DALI_ENV_PAN_SCALAR_ONLY_PREDICTION_ENABLED "DALI_PAN_SCALAR_ONLY_PREDICTION_ENABLED" +#define DALI_ENV_PAN_TWO_POINT_PREDICTION_ENABLED "DALI_PAN_TWO_POINT_PREDICTION_ENABLED" +#define DALI_ENV_PAN_TWO_POINT_PAST_INTERPOLATE_TIME "DALI_PAN_TWO_POINT_PAST_INTERPOLATE_TIME" +#define DALI_ENV_PAN_TWO_POINT_VELOCITY_BIAS "DALI_PAN_TWO_POINT_VELOCITY_BIAS" +#define DALI_ENV_PAN_TWO_POINT_ACCELERATION_BIAS "DALI_PAN_TWO_POINT_ACCELERATION_BIAS" +#define DALI_ENV_PAN_MULTITAP_SMOOTHING_RANGE "DALI_PAN_MULTITAP_SMOOTHING_RANGE" + +// Pan-Gesture miscellaneous: +#define DALI_ENV_LOG_PAN_GESTURE "DALI_LOG_PAN_GESTURE" +#define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE" +#define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS" #define DALI_GLES_CALL_TIME "DALI_GLES_CALL_TIME" diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index ab2ecac..3b214fe 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -183,6 +183,38 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) { Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount()); } + if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 ) + { + Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false ); + } + if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 ) + { + Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() ); + } + if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 ) + { + Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false ); + } + if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 ) + { + Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false ); + } + if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 ) + { + Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() ); + } + if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f ) + { + Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() ); + } + if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f ) + { + Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() ); + } + if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 ) + { + Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() ); + } } Adaptor::~Adaptor() -- 2.7.4