Bug 1457586 - Allow PlatformSpecificState to choose the VelocityTracker implementation. r=kats
MozReview-Commit-ID: LyW9N2H7fv7
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -23,16 +23,17 @@
#include "GenericFlingAnimation.h" // for GenericFlingAnimation
#include "GestureEventListener.h" // for GestureEventListener
#include "HitTestingTreeNode.h" // for HitTestingTreeNode
#include "InputData.h" // for MultiTouchInput, etc
#include "InputBlockState.h" // for InputBlockState, TouchBlockState
#include "InputQueue.h" // for InputQueue
#include "Overscroll.h" // for OverscrollAnimation
#include "OverscrollHandoffState.h" // for OverscrollHandoffState
+#include "SimpleVelocityTracker.h" // for SimpleVelocityTracker
#include "Units.h" // for CSSRect, CSSPoint, etc
#include "UnitTransforms.h" // for TransformTo
#include "base/message_loop.h" // for MessageLoop
#include "base/task.h" // for NewRunnableMethod, etc
#include "gfxPrefs.h" // for gfxPrefs
#include "gfxTypes.h" // for gfxFloat
#include "LayersLogging.h" // for print_stderr
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
@@ -544,16 +545,22 @@ PlatformSpecificStateBase::CreateFlingAn
{
return new GenericFlingAnimation<DesktopFlingPhysics>(aApzc,
aHandoffState.mChain,
aHandoffState.mIsHandoff,
aHandoffState.mScrolledApzc,
aPLPPI);
}
+UniquePtr<VelocityTracker>
+PlatformSpecificStateBase::CreateVelocityTracker(Axis* aAxis)
+{
+ return MakeUnique<SimpleVelocityTracker>(aAxis);
+}
+
TimeStamp
AsyncPanZoomController::GetFrameTime() const
{
APZCTreeManager* treeManagerLocal = GetApzcTreeManager();
return treeManagerLocal ? treeManagerLocal->GetFrameTime() : TimeStamp::Now();
}
class MOZ_STACK_CLASS StateChangeNotificationBlocker {
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -70,16 +70,17 @@ struct KeyboardScrollAction;
class PlatformSpecificStateBase {
public:
virtual ~PlatformSpecificStateBase() = default;
virtual AndroidSpecificState* AsAndroidSpecificState() { return nullptr; }
// PLPPI = "ParentLayer pixels per (Screen) inch"
virtual AsyncPanZoomAnimation* CreateFlingAnimation(AsyncPanZoomController& aApzc,
const FlingHandoffState& aHandoffState,
float aPLPPI);
+ virtual UniquePtr<VelocityTracker> CreateVelocityTracker(Axis* aAxis);
static void InitializeGlobalState() {}
};
/*
* Represents a transform from the ParentLayer coordinate space of an APZC
* to the ParentLayer coordinate space of its parent APZC.
* Each layer along the way contributes to the transform. We track
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -39,17 +39,17 @@ bool FuzzyEqualsCoordinate(float aValue1
Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
: mPos(0),
mVelocity(0.0f),
mAxisLocked(false),
mAsyncPanZoomController(aAsyncPanZoomController),
mOverscroll(0),
mMSDModel(0.0, 0.0, 0.0, 400.0, 1.2),
- mVelocityTracker(MakeUnique<SimpleVelocityTracker>(this))
+ mVelocityTracker(mAsyncPanZoomController->GetPlatformSpecificState()->CreateVelocityTracker(this))
{
}
float Axis::ToLocalVelocity(float aVelocityInchesPerMs) const {
ScreenPoint velocity = MakePoint(aVelocityInchesPerMs * mAsyncPanZoomController->GetDPI());
// Use ToScreenCoordinates() to convert a point rather than a vector by
// treating the point as a vector, and using (0, 0) as the anchor.
ScreenPoint panStart = mAsyncPanZoomController->ToScreenCoordinates(