Increase how far pan gestures try to predict position 1.0f is 1 frame further ahead. Can use decimals like 0.6 or 1.3.
Change-Id: Id5ac2e6c7273e25f51d41aa16ad113ec6632256d
Signed-off-by: Julien Heanley <j.heanley@partner.samsung.com>
eventProcessor.SetPanGesturePredictionMode(mode);
}
+void SetPanGesturePredictionAmount(float amount)
+{
+ GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor();
+ eventProcessor.SetPanGesturePredictionAmount(amount);
+}
+
namespace Profiling
{
*/
DALI_IMPORT_API void SetPanGesturePredictionMode( int mode );
+/**
+ * @brief Called by adaptor to set the prediction amount of the pan gesture from an environment variable
+ *
+ * @param[in] amount The prediction amount, 0.0f being next vsync and each 1.0f on top is another vsync ahead, can be divisions of (0.5f)
+ */
+DALI_IMPORT_API void SetPanGesturePredictionAmount(float amount);
+
namespace Profiling
{
mPanGestureProcessor.SetPredictionMode(mode);
}
+void GestureEventProcessor::SetPanGesturePredictionAmount( float amount )
+{
+ mPanGestureProcessor.SetPredictionAmount(amount);
+}
+
} // namespace Internal
} // namespace Dali
*/
void SetPanGesturePredictionMode( int mode );
+ /**
+ * @brief Sets the prediction amount of the pan gesture
+ *
+ * @param[in] amount The prediction amount, 0.0f being next vsync and each 1.0f on top is another vsync ahead, can be divisions of (0.5f)
+ */
+ void SetPanGesturePredictionAmount( float amount );
+
private:
// Undefined
mSceneObject->SetPredictionMode(modeEnum);
}
+void PanGestureProcessor::SetPredictionAmount(float amount)
+{
+ mSceneObject->SetPredictionAmount(amount);
+}
+
void PanGestureProcessor::UpdateDetection()
{
DALI_ASSERT_DEBUG(!mGestureDetectors.empty());
*/
void SetPredictionMode(int mode);
+ /**
+ * @brief Sets the prediction amount of the pan gesture
+ *
+ * @param[in] amount The prediction amount, 0.0f being next vsync and each 1.0f on top is another vsync ahead, can be divisions of (0.5f)
+ */
+ void SetPredictionAmount(float amount);
+
private:
// Undefined
namespace
{
const int MAX_GESTURE_AGE = 50; ///< maximum age of a gesture before disallowing its use in algorithm
+const float DEFAULT_PREDICTION_INTERPOLATION = 0.0f; ///< how much to interpolate pan position and displacement from last vsync time
} // unnamed namespace
-const PanGesture::PredictionMode PanGesture::DEFAULT_PREDICTION_MODE = PanGesture::AVERAGE;
+const PanGesture::PredictionMode PanGesture::DEFAULT_PREDICTION_MODE = PanGesture::PREDICTION_2;
const int PanGesture::NUM_PREDICTION_MODES = PanGesture::PREDICTION_2 + 1;
PanGesture* PanGesture::New()
}
// gestureOut's position is currently equal to the last event's position and its displacement is equal to last frame's total displacement
// add interpolated distance and position to current
- float interpolationTime = (float)((int)lastVSyncTime - (int)gestureOut.time);
+ unsigned int timeAdvance = ((nextVSyncTime - lastVSyncTime) * mPredictionAmount);
+ unsigned int interpolationTime = (lastVSyncTime + timeAdvance) - gestureOut.time;
// work out interpolated velocity
gestureOut.screen.displacement = (gestureOut.screen.velocity * interpolationTime);
gestureOut.local.displacement = (gestureOut.local.velocity * interpolationTime);
gestureOut.screen.position += gestureOut.screen.displacement;
gestureOut.local.position += gestureOut.local.displacement;
- gestureOut.time += (lastVSyncTime - gestureOut.time);
+ gestureOut.time += interpolationTime;
}
bool PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
return mLocalDisplacement;
}
+void PanGesture::SetPredictionMode(PredictionMode mode)
+{
+ mPredictionMode = mode;
+}
+
+void PanGesture::SetPredictionAmount(float amount)
+{
+ mPredictionAmount = amount;
+}
+
void PanGesture::EnableProfiling()
{
if( !mProfiling )
mReadPosition( 0 ),
mInGesture( false ),
mPredictionMode(DEFAULT_PREDICTION_MODE),
+ mPredictionAmount(DEFAULT_PREDICTION_INTERPOLATION),
mProfiling( NULL )
{
}
*
* @param[in] mode The prediction mode
*/
- void SetPredictionMode(PredictionMode mode) { mPredictionMode = mode; }
+ void SetPredictionMode(PredictionMode mode);
+
+ /**
+ * @brief Sets the prediction amount of the pan gesture
+ *
+ * @param[in] amount The prediction amount, 0.0f being next vsync and each 1.0f on top is another vsync ahead, can be divisions of (0.5f)
+ */
+ void SetPredictionAmount(float amount);
/**
* Called to provide pan-gesture profiling information.
bool mInGesture; ///< True if the gesture is currently being handled i.e. between Started <-> Finished/Cancelled
PredictionMode mPredictionMode; ///< The pan gesture prediction mode
+ float mPredictionAmount; ///< how far into future to predict. 0.0f is next vsync since no point being less than that, adding 1.0f will predict another vsync in advance
PanGestureProfiling* mProfiling; ///< NULL unless pan-gesture profiling information is required.
};