Title: [111395] trunk/Source
Revision
111395
Author
wjmacl...@chromium.org
Date
2012-03-20 07:51:58 -0700 (Tue, 20 Mar 2012)

Log Message

[chromium] Tune fling physics curve. [Not for review yet]
https://bugs.webkit.org/show_bug.cgi?id=81398

Reviewed by James Robinson.

Source/WebCore:

Existing tests updated.

Tune physics of curve for better feel.

* platform/TouchFlingPlatformGestureCurve.cpp:
(WebCore::TouchFlingPlatformGestureCurve::apply):

Source/WebKit/chromium:

* tests/PlatformGestureCurveTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111394 => 111395)


--- trunk/Source/WebCore/ChangeLog	2012-03-20 14:46:27 UTC (rev 111394)
+++ trunk/Source/WebCore/ChangeLog	2012-03-20 14:51:58 UTC (rev 111395)
@@ -1,3 +1,17 @@
+2012-03-20  W. James MacLean  <wjmacl...@chromium.org>
+
+        [chromium] Tune fling physics curve. [Not for review yet]
+        https://bugs.webkit.org/show_bug.cgi?id=81398
+
+        Reviewed by James Robinson.
+
+        Existing tests updated.
+
+        Tune physics of curve for better feel.
+
+        * platform/TouchFlingPlatformGestureCurve.cpp:
+        (WebCore::TouchFlingPlatformGestureCurve::apply):
+
 2012-03-20  Alexis Menard  <alexis.men...@openbossa.org>
 
         Implement a fast path when setting CSS properties with keywords from JS.

Modified: trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp (111394 => 111395)


--- trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp	2012-03-20 14:46:27 UTC (rev 111394)
+++ trunk/Source/WebCore/platform/TouchFlingPlatformGestureCurve.cpp	2012-03-20 14:51:58 UTC (rev 111395)
@@ -51,32 +51,33 @@
 
 bool TouchFlingPlatformGestureCurve::apply(double time, PlatformGestureCurveTarget* target)
 {
-    // Here we implement a cubic bezier curve with parameters [1 1 0 0] which gives
-    // v(0) = 1, a(0) = 0, v(1) = 0, a(1) = 0. The curve is scaled by the initial
+    // Here we implement a cubic bezier curve with parameters [p0 p1 p2 p3] = [1 (3 + 1/tau) 0 0] which gives
+    // v(0) = 1, a(0) = v(0)/tau, v(1) = 0, a(1) = 0. The curve is scaled by the initial
     // velocity, and the time parameter is re-scaled so that larger initial velocities
     // lead to longer initial animations. This should allow the animation to smoothly
     // continue the velocity at the end of the GestureScroll, and smoothly come to a rest
     // at the end. Finally, we have integrated the curve so we can deal with displacement
     // as a function of time, and not velocity.
-    // Finally, we place a constant velocity from ts = 0 .. 0.5, and run the Bezier curve
-    // from ts = 0.5 .. 1.5 to give a longer run-out.
     time *= m_timeScaleFactor;
 
+    static double tau = 0.25;
+    static double p1 =  3.0 + 1 / tau;
+    // Note: "displacement" below is the integral of the cubic bezier curve defined by [p0 p1 p2 p3].
+
     float displacement;
-    if (time <= 0.5)
-        displacement = time;
-    else if (time <= 1.5) {
-        double t = time - 0.5;
-        displacement = t * (1 + t * t * (0.5 * t - 1)) + 0.5;
-    } else
-        displacement = 1.0;
+    if (time < 0)
+        displacement = 0;
+    else if (time < 1)
+        displacement = time * (time * (time * (time * 0.25 * (3 * p1 - 1.0) + (1 - 2 * p1)) + 1.5 * (p1 - 1)) + 1) / m_timeScaleFactor;
+    else
+        displacement = (1 + (p1 - 1) * 1.5 + (1 - 2 * p1) + (3 * p1 - 1) * 0.25) / m_timeScaleFactor;
 
     // Keep track of integer portion of scroll thus far, and prepare increment.
     IntPoint scroll(displacement * m_velocity.x(), displacement * m_velocity.y());
     IntPoint scrollIncrement(scroll - m_cumulativeScroll);
     m_cumulativeScroll = scroll;
 
-    if (time < 1.5 || scrollIncrement != IntPoint::zero()) {
+    if (time < 1 || scrollIncrement != IntPoint::zero()) {
         target->scrollBy(scrollIncrement);
         return true;
     }

Modified: trunk/Source/WebKit/chromium/ChangeLog (111394 => 111395)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-20 14:46:27 UTC (rev 111394)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-20 14:51:58 UTC (rev 111395)
@@ -1,3 +1,12 @@
+2012-03-20  W. James MacLean  <wjmacl...@chromium.org>
+
+        [chromium] Tune fling physics curve. [Not for review yet]
+        https://bugs.webkit.org/show_bug.cgi?id=81398
+
+        Reviewed by James Robinson.
+
+        * tests/PlatformGestureCurveTest.cpp:
+
 2012-03-20  Ian Vollick  <voll...@chromium.org>
 
         [chromium] Infrastructure to allow animating layers to be only partially updated

Modified: trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp (111394 => 111395)


--- trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp	2012-03-20 14:46:27 UTC (rev 111394)
+++ trunk/Source/WebKit/chromium/tests/PlatformGestureCurveTest.cpp	2012-03-20 14:51:58 UTC (rev 111395)
@@ -99,8 +99,10 @@
 
 TEST(PlatformGestureCurve, flingCurveTouch)
 {
+    double initialVelocity = 1000;
+    const double touchFlingCurveAreaFactor = 2; // Depends on value of tau in TouchFlingPlatformGestureCurve.
     MockPlatformGestureCurveTarget target;
-    OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::create(FloatPoint(1000, 0)), &target);
+    OwnPtr<ActivePlatformGestureAnimation> animation = ActivePlatformGestureAnimation::create(TouchFlingPlatformGestureCurve::create(FloatPoint(initialVelocity, 0)), &target);
 
     // Note: the expectations below are dependent on the value of sigma hard-coded in the Rayleigh
     //       curve. If sigma changes, these test expectations will also change.
@@ -111,7 +113,7 @@
     EXPECT_TRUE(animation->animate(0.9));
     EXPECT_TRUE(animation->animate(1000));
     EXPECT_FALSE(animation->animate(1001));
-    EXPECT_NEAR(target.cumulativeDelta().x(), 1000, 1);
+    EXPECT_NEAR(target.cumulativeDelta().x(), initialVelocity * touchFlingCurveAreaFactor, 1);
     EXPECT_EQ(target.cumulativeDelta().y(), 0);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to