Bug 1272165 - Move the logic for determining whether to accelerate a fling into FlingAnimation. r=kats
authorBotond Ballo <botond@mozilla.com>
Mon, 16 May 2016 18:23:55 -0400
changeset 298318 db4b2156f1851b43f1d71ec60577b8992365dc29
parent 298317 43fb74c6ceb4bd1145e436b3f0581bd007559f97
child 298319 b99740af9c1a838201e83823c398cf4b298058df
push id30281
push usercbook@mozilla.com
push dateTue, 24 May 2016 12:54:02 +0000
treeherderautoland@829d3be6ba64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1272165
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1272165 - Move the logic for determining whether to accelerate a fling into FlingAnimation. r=kats MozReview-Commit-ID: 41GGRtdlcAU
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/GenericFlingAnimation.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2405,17 +2405,17 @@ void AsyncPanZoomController::AcceptFling
     }
     FlingOverScrollerAnimation *fling = new FlingOverScrollerAnimation(*this,
         mOverScroller,
         aHandoffState.mChain,
         aHandoffState.mScrolledApzc);
 #else
     GenericFlingAnimation *fling = new GenericFlingAnimation(*this,
         aHandoffState.mChain,
-        !aHandoffState.mIsHandoff,  // only apply acceleration if this is an initial fling
+        aHandoffState.mIsHandoff,
         aHandoffState.mScrolledApzc);
 #endif
     StartAnimation(fling);
   }
 }
 
 bool AsyncPanZoomController::AttemptFling(FlingHandoffState& aHandoffState) {
   // If we are pannable, take over the fling ourselves.
--- a/gfx/layers/apz/src/GenericFlingAnimation.h
+++ b/gfx/layers/apz/src/GenericFlingAnimation.h
@@ -26,17 +26,17 @@
 
 namespace mozilla {
 namespace layers {
 
 class GenericFlingAnimation: public AsyncPanZoomAnimation {
 public:
   GenericFlingAnimation(AsyncPanZoomController& aApzc,
                         const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
-                        bool aApplyAcceleration,
+                        bool aFlingIsHandedOff,
                         const RefPtr<const AsyncPanZoomController>& aScrolledApzc)
     : mApzc(aApzc)
     , mOverscrollHandoffChain(aOverscrollHandoffChain)
     , mScrolledApzc(aScrolledApzc)
   {
     MOZ_ASSERT(mOverscrollHandoffChain);
     TimeStamp now = aApzc.GetFrameTime();
 
@@ -57,17 +57,20 @@ public:
 
     // If the last fling was very recent and in the same direction as this one,
     // boost the velocity to be the sum of the two. Check separate axes separately
     // because we could have two vertical flings with small horizontal components
     // on the opposite side of zero, and we still want the y-fling to get accelerated.
     // Note that the acceleration code is only applied on the APZC that initiates
     // the fling; the accelerated velocities are then handed off using the
     // normal DispatchFling codepath.
-    if (aApplyAcceleration && !mApzc.mLastFlingTime.IsNull()
+    // Acceleration is only applied in the APZC that originated the fling,
+    // not in APZCs further down the handoff chain during handoff.
+    bool applyAcceleration = !aFlingIsHandedOff;
+    if (applyAcceleration && !mApzc.mLastFlingTime.IsNull()
         && (now - mApzc.mLastFlingTime).ToMilliseconds() < gfxPrefs::APZFlingAccelInterval()) {
       if (SameDirection(velocity.x, mApzc.mLastFlingVelocity.x)) {
         velocity.x = Accelerate(velocity.x, mApzc.mLastFlingVelocity.x);
         FLING_LOG("%p Applying fling x-acceleration from %f to %f (delta %f)\n",
                   &mApzc, mApzc.mX.GetVelocity(), velocity.x, mApzc.mLastFlingVelocity.x);
         mApzc.mX.SetVelocity(velocity.x);
       }
       if (SameDirection(velocity.y, mApzc.mLastFlingVelocity.y)) {