Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_layers_AndroidAPZ_h_
8
#define mozilla_layers_AndroidAPZ_h_
9
10
#include "AsyncPanZoomAnimation.h"
11
#include "AsyncPanZoomController.h"
12
#include "GeneratedJNIWrappers.h"
13
14
namespace mozilla {
15
namespace layers {
16
17
class AndroidSpecificState : public PlatformSpecificStateBase {
18
public:
19
AndroidSpecificState();
20
21
virtual AndroidSpecificState* AsAndroidSpecificState() override {
22
return this;
23
}
24
25
virtual AsyncPanZoomAnimation* CreateFlingAnimation(
26
AsyncPanZoomController& aApzc, const FlingHandoffState& aHandoffState,
27
float aPLPPI) override;
28
virtual UniquePtr<VelocityTracker> CreateVelocityTracker(
29
Axis* aAxis) override;
30
31
static void InitializeGlobalState();
32
33
java::StackScroller::GlobalRef mOverScroller;
34
TimeStamp mLastFling;
35
};
36
37
class StackScrollerFlingAnimation : public AsyncPanZoomAnimation {
38
public:
39
StackScrollerFlingAnimation(
40
AsyncPanZoomController& aApzc,
41
PlatformSpecificStateBase* aPlatformSpecificState,
42
const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
43
bool aFlingIsHandoff /* ignored */,
44
const RefPtr<const AsyncPanZoomController>& aScrolledApzc);
45
virtual bool DoSample(FrameMetrics& aFrameMetrics,
46
const TimeDuration& aDelta) override;
47
48
private:
49
void DeferHandleFlingOverscroll(ParentLayerPoint& aVelocity);
50
// Returns true if value is on or outside of axis bounds.
51
bool CheckBounds(Axis& aAxis, float aValue, float aDirection,
52
float* aClamped);
53
54
AsyncPanZoomController& mApzc;
55
java::StackScroller::GlobalRef mOverScroller;
56
RefPtr<const OverscrollHandoffChain> mOverscrollHandoffChain;
57
RefPtr<const AsyncPanZoomController> mScrolledApzc;
58
bool mSentBounceX;
59
bool mSentBounceY;
60
long mFlingDuration;
61
ParentLayerPoint mStartOffset;
62
ParentLayerPoint mPreviousOffset;
63
// Unit vector in the direction of the fling.
64
ParentLayerPoint mFlingDirection;
65
ParentLayerPoint mPreviousVelocity;
66
};
67
68
} // namespace layers
69
} // namespace mozilla
70
71
#endif // mozilla_layers_AndroidAPZ_h_