[4.0] pan-gesture code refactor and environment variables 51/160751/1
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 28 Feb 2017 06:24:04 +0000 (15:24 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 20 Nov 2017 02:24:34 +0000 (11:24 +0900)
Change-Id: Idc6902b3f9a3d0e4b847940851aa851af60dc98e

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

index 792b2ab..743de40 100644 (file)
@@ -88,7 +88,6 @@ EnvironmentOptions::EnvironmentOptions()
 : mLogFunction( NULL ),
   mWindowName(),
   mWindowClassName(),
-  mPanGestureSmoothingAmount( -1.0f ),
   mNetworkControl( 0 ),
   mFpsFrequency( 0 ),
   mUpdateStatusFrequency( 0 ),
@@ -108,6 +107,15 @@ EnvironmentOptions::EnvironmentOptions()
   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 ),
@@ -212,6 +220,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;
@@ -368,6 +416,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 ))
   {
index 987006d..fe05453 100644 (file)
@@ -148,6 +148,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;
@@ -260,7 +302,6 @@ private: // Data
 
   std::string mWindowName;                        ///< name of the window
   std::string mWindowClassName;                   ///< name of the class the window belongs to
-  float mPanGestureSmoothingAmount;               ///< prediction amount for pan gestures
   unsigned int mNetworkControl;                   ///< whether network control is enabled
   unsigned int mFpsFrequency;                     ///< how often fps is logged out in seconds
   unsigned int mUpdateStatusFrequency;            ///< how often update status is logged out in frames
@@ -280,6 +321,15 @@ private: // Data
   int mPanGestureMinPredictionAmount;             ///< minimum prediction amount for pan gestures
   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
index 5d02f79..2833f6b 100644 (file)
@@ -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"
 
index 0656c18..b757d9f 100644 (file)
@@ -202,6 +202,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() );
+  }
 
   // Set max texture size
   if( mEnvironmentOptions->GetMaxTextureSize() > 0 )