/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
delete mProfiling;
}
-void PanGesture::AddGesture( const Dali::PanGesture& gesture )
+void PanGesture::AddGesture( const Internal::PanGesture& gesture )
{
Dali::Mutex::ScopedLock lock( mMutex );
mGestures[ mWritePosition ] = gesture;
++iter;
continue;
}
- float previousValueWeight = ( static_cast< float >( MAX_GESTURE_AGE ) - (lastVSyncTime - lastTime) ) / static_cast< float >( MAX_GESTURE_AGE );
+ float previousValueWeight = ( static_cast<float>( MAX_GESTURE_AGE ) - static_cast<float>(lastVSyncTime - lastTime) ) / static_cast<float>( MAX_GESTURE_AGE );
float velMag = currentGesture.screen.velocity.Length();
float velDiff = velMag - screenVelocity.Length();
float acceleration = 0.0f;
}
else
{
- newVelMag = velMag + (((acceleration * (1.0f - previousValueWeight)) + (previousAccel * previousValueWeight)) * currentInterpolation);
+ newVelMag = velMag + (((acceleration * (1.0f - previousValueWeight)) + (previousAccel * previousValueWeight)) * static_cast<float>( currentInterpolation ) );
}
float velMod = 1.0f;
if( velMag > Math::MACHINE_EPSILON_1 )
}
gestureOut.screen.velocity = currentGesture.screen.velocity * velMod;
gestureOut.local.velocity = currentGesture.local.velocity * velMod;
- screenDisplacement = gestureOut.screen.displacement + (gestureOut.screen.velocity * interpolationTime);
- localDisplacement = gestureOut.local.displacement + (gestureOut.local.velocity * interpolationTime);
+ screenDisplacement = gestureOut.screen.displacement + (gestureOut.screen.velocity * static_cast<float>( interpolationTime ) );
+ localDisplacement = gestureOut.local.displacement + (gestureOut.local.velocity * static_cast<float>( interpolationTime ) );
screenVelocity = currentGesture.screen.velocity;
localVelocity = currentGesture.local.velocity;
previousAccel = acceleration;
gesture.screen.displacement = gesture.screen.position - lastGesture.screen.position;
gesture.local.displacement = gesture.local.position - lastGesture.local.position;
// Calculate velocity relative to previous update-frame
- float timeDifference( gesture.time - lastGesture.time );
+ float timeDifference = static_cast<float>( gesture.time - lastGesture.time );
gesture.screen.velocity = gesture.screen.displacement / timeDifference;
gesture.local.velocity = gesture.local.displacement / timeDifference;
}
// add event to history
mPanHistory.push_back( currentGesture );
- if( currentGesture.state == Gesture::Started )
+ if( currentGesture.state == Dali::Gesture::Started )
{
info.justStarted = true;
// clear just finished as we have started new pan
info.justFinished = false;
}
- info.justFinished |= ( currentGesture.state == Gesture::Finished || currentGesture.state == Gesture::Cancelled );
+ info.justFinished |= ( currentGesture.state == Dali::Gesture::Finished || currentGesture.state == Dali::Gesture::Cancelled );
// Update our read position.
previousReadPosition = mReadPosition;
info.frameGesture.screen.velocity += lastReadGesture.screen.velocity;
info.frameGesture.local.velocity += lastReadGesture.local.velocity;
- if( lastReadGesture.state == Gesture::Started )
+ if( lastReadGesture.state == Dali::Gesture::Started )
{
// Clear just finished as we have started new pan.
info.justFinished = false;
}
else
{
- info.justFinished |= ( lastReadGesture.state == Gesture::Finished || lastReadGesture.state == Gesture::Cancelled );
+ info.justFinished |= ( lastReadGesture.state == Dali::Gesture::Finished || lastReadGesture.state == Dali::Gesture::Cancelled );
}
// Add event to history
if( info.eventsThisFrame > 1 )
{
- info.frameGesture.screen.position /= info.eventsThisFrame;
- info.frameGesture.local.position /= info.eventsThisFrame;
- info.frameGesture.screen.velocity /= info.eventsThisFrame;
- info.frameGesture.local.velocity /= info.eventsThisFrame;
+ const float eventsThisFrame = static_cast<float>( info.eventsThisFrame );
+ info.frameGesture.screen.position /= eventsThisFrame;
+ info.frameGesture.local.position /= eventsThisFrame;
+ info.frameGesture.screen.velocity /= eventsThisFrame;
+ info.frameGesture.local.velocity /= eventsThisFrame;
info.frameGesture.screen.displacement = info.frameGesture.screen.position - mLastGesture.screen.position;
info.frameGesture.local.displacement = info.frameGesture.local.position - mLastGesture.local.position;
// Ignore tiny velocity fluctuation to avoid unnecessary prediction amount change
if( fabsf( frameInfo.acceleration ) > ACCELERATION_THRESHOLD )
{
- mCurrentPredictionAmount += mPredictionAmountAdjustment * ( frameInfo.acceleration > Math::MACHINE_EPSILON_0 ? 1.0f : -1.0f );
+ mCurrentPredictionAmount += static_cast<unsigned int>( static_cast<float>( mPredictionAmountAdjustment ) * ( frameInfo.acceleration > Math::MACHINE_EPSILON_0 ? 1.0f : -1.0f ) );
if( mCurrentPredictionAmount > mMaxPredictionAmount + mPredictionAmountAdjustment ) // Guard against unsigned int overflow
{
mCurrentPredictionAmount = 0;
mLastGesture = frameGesture;
mLastUnmodifiedGesture = unmodifiedGesture;
- mInGesture &= ~frameInfo.justFinished;
+ mInGesture = mInGesture && !frameInfo.justFinished;
if( mProfiling && frameInfo.justFinished )
{
mProfiling->PrintData();
readGesture.screen.displacement, readGesture.screen.velocity, readGesture.state ) );
}
- if( readGesture.state == Gesture::Started )
+ if( readGesture.state == Dali::Gesture::Started )
{
// Clear pan data.
mPanHistory.clear();
}
else
{
- justFinished |= ( readGesture.state == Gesture::Finished || readGesture.state == Gesture::Cancelled );
+ justFinished |= ( readGesture.state == Dali::Gesture::Finished || readGesture.state == Dali::Gesture::Cancelled );
}
rateConvertedGesture.screen.position += readGesture.screen.position;
// Some events were read this frame.
if( eventsKeptThisFrame > 1 )
{
- float eventDivisor( eventsKeptThisFrame );
+ const float eventDivisor = static_cast<float>( eventsKeptThisFrame );
rateConvertedGesture.screen.position /= eventDivisor;
rateConvertedGesture.local.position /= eventDivisor;
rateConvertedGesture.screen.velocity /= eventDivisor;
else
{
// If we just started, last velocity was 0. So difference of zero to current velocity over time gives acceleration of the first point.
- newAcceleration.local = outPoint.local.velocity / outputTimeGranularity;
- newAcceleration.screen = outPoint.screen.velocity / outputTimeGranularity;
+ newAcceleration.local = outPoint.local.velocity / static_cast<float>( outputTimeGranularity );
+ newAcceleration.screen = outPoint.screen.velocity / static_cast<float>( outputTimeGranularity );
}
pointGenerated = true;
}
else
{
// We are doing integration based prediction.
- float predictionDelta( mCurrentPredictionAmount );
+ float predictionDelta = static_cast<float>( mCurrentPredictionAmount );
predictedPoint.local.position = startPoint.local.position + ( startPoint.local.velocity * predictionDelta ) +
( accelerationToUse.local * ( predictionDelta * predictionDelta * 0.5f ) );
PanInfo targetPoint;
float outputTimeGranularity( GetDivisibleTimeDifference( nextVSyncTime, lastVSyncTime, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
bool pointGenerated = InterpolatePoint( mPanHistory, nextVSyncTime, nextVSyncTime, mInterpolationTimeRange,
- targetPoint, currentAcceleration, outputTimeGranularity, true );
+ targetPoint, currentAcceleration, static_cast<int>( outputTimeGranularity ), true ); // truncated
if( pointGenerated )
{
mLastInitialAcceleration.local = currentAcceleration.local;
interpolatedAcceleration.local = mLastInterpolatedAcceleration.local;
interpolatedAcceleration.screen = mLastInterpolatedAcceleration.screen;
if( !InterpolatePoint( mPanHistory, nextVSyncTime, pastInterpolateTime, mTwoPointPastInterpolateTime,
- outPoint, interpolatedAcceleration, outputTimeGranularity, false ) )
+ outPoint, interpolatedAcceleration, static_cast<int>( outputTimeGranularity ), false ) ) // truncated
{
if( justStarted )
{
// Perform Multi-tap Smoothing.
RelativeVectors blank;
InterpolatePoint( mPredictionHistory, nextVSyncTime, nextVSyncTime, mMultiTapSmoothingRange,
- targetPoint, blank, outputTimeGranularity, true );
+ targetPoint, blank, static_cast<int>( outputTimeGranularity ), true ); // truncated
}
else
{
}
}
- mInGesture &= ~justFinished;
+ mInGesture = mInGesture && !justFinished;
return performUpdate;
}