Remove codes to process flick more using decimals.
authorEunmi Lee <eunmi15.lee@samsung.com>
Mon, 1 Apr 2013 07:19:22 +0000 (16:19 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 5 Apr 2013 05:34:58 +0000 (14:34 +0900)
[Title] Remove codes to process flick more using decimals.
[Issue#] N/A
[Problem] It seems that flick is stopped, but flick is processing slowly,
          and it caused that channel scrolling seems to work incorrectly.
[Cause] The flick is processed using decimals.
[Solution] Remove codes to process flick more using decimals.

Change-Id: Ia47a193b044a46cf2db9f4a972bfdd1fd8eada50

Source/WebKit2/UIProcess/API/efl/tizen/Flick.cpp
Source/WebKit2/UIProcess/API/efl/tizen/Flick.h

index 8db8c71..015d2cb 100755 (executable)
@@ -64,7 +64,6 @@ void Flick::start(IntPoint velocity)
     m_flickIndex = 0;
     m_flickDuration = 1 / ecore_animator_frametime_get();
     m_flickAnimator = ecore_animator_add(flickAnimatorCallback, this);
-    m_remainder = IntPoint();
 }
 
 void Flick::stop()
@@ -93,33 +92,15 @@ Eina_Bool Flick::flickAnimatorCallback(void* data)
 
 bool Flick::process()
 {
-    double valueOfEaseInOutCubic = easeInOutQuad(m_flickDuration, m_flickIndex);
-    double decimalDeltaX = -1 * m_velocity.x() / m_flickDuration * valueOfEaseInOutCubic + m_remainder.x();
-    double decimalDeltaY = -1 * m_velocity.y() / m_flickDuration * valueOfEaseInOutCubic + m_remainder.y();
-    int deltaX = static_cast<int>(decimalDeltaX);
-    int deltaY = static_cast<int>(decimalDeltaY);
-
-    m_remainder.setX(decimalDeltaX - deltaX);
-    if (m_remainder.x() >= 0.5) {
-        deltaX += 1;
-        m_remainder.setX(m_remainder.x() - 0.5);
-    } else if (m_remainder.x() <= -0.5) {
-        deltaX -= 1;
-        m_remainder.setX(m_remainder.x() + 0.5);
-    }
-
-    m_remainder.setY(decimalDeltaY - deltaY);
-    if (m_remainder.y() >= 0.5) {
-        deltaY += 1;
-        m_remainder.setY(m_remainder.y() - 0.5);
-    } else if (m_remainder.y() <= -0.5) {
-        deltaY -= 1;
-        m_remainder.setY(m_remainder.y() + 0.5);
-    }
+    double multiplier = easeInOutQuad(m_flickDuration, m_flickIndex);
+    int deltaX = -1 * m_velocity.x();
+    deltaX = (deltaX > 0) ? ceilf(deltaX * multiplier / m_flickDuration) : floorf(deltaX * multiplier / m_flickDuration);
+    int deltaY = -1 * m_velocity.y();
+    deltaY = (deltaY > 0) ? ceilf(deltaY * multiplier / m_flickDuration) : floorf(deltaY * multiplier / m_flickDuration);
 
     m_flickIndex++;
 
-    if (m_flickIndex > m_flickDuration) {
+    if (m_flickIndex > m_flickDuration || !(deltaX || deltaY)) {
         m_flickAnimator = 0;
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
         PageClientImpl* pageClientImpl = m_viewImpl->pageClient.get();
@@ -129,9 +110,6 @@ bool Flick::process()
         return false;
 
     } else {
-        if (!deltaX && !deltaY)
-            return true;
-
         PageClientImpl* pageClientImpl = m_viewImpl->pageClient.get();
         EINA_SAFETY_ON_NULL_RETURN_VAL(pageClientImpl, true);
         ewkViewSendScrollEvent(m_viewImpl->view(), deltaX, deltaY);
index db75926..a077649 100755 (executable)
@@ -56,7 +56,6 @@ private:
     int m_flickIndex;
     int m_flickDuration;
     Ecore_Animator* m_flickAnimator;
-    WebCore::FloatPoint m_remainder;
     Ecore_Animator* m_scrollAnimator;
     WebCore::IntPoint m_scrollToPosition;
     static const double s_scrollSpeedFactor; // Decide a scroll speed in scrollToAnimator()