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_AndroidFlingPhysics_h_
8
#define mozilla_layers_AndroidFlingPhysics_h_
9
10
#include "AsyncPanZoomController.h"
11
#include "Units.h"
12
#include "mozilla/Assertions.h"
13
14
namespace mozilla {
15
namespace layers {
16
17
class AndroidFlingPhysics {
18
public:
19
void Init(const ParentLayerPoint& aVelocity, float aPLPPI);
20
void Sample(const TimeDuration& aDelta, ParentLayerPoint* aOutVelocity,
21
ParentLayerPoint* aOutOffset);
22
23
static void InitializeGlobalState();
24
25
private:
26
// Returns false if the animation should end.
27
bool SampleImpl(const TimeDuration& aDelta, float* aOutVelocity);
28
29
// Information pertaining to the current fling.
30
// This is initialized on each call to Init().
31
ParentLayerCoord mVelocity; // diagonal velocity (length of velocity vector)
32
TimeDuration mTargetDuration;
33
TimeDuration mDurationSoFar;
34
ParentLayerPoint mLastPos;
35
ParentLayerPoint mCurrentPos;
36
ParentLayerCoord mTargetDistance; // diagonal distance
37
ParentLayerPoint mTargetPos; // really a target *offset* relative to the
38
// start position, which we don't track
39
ParentLayerPoint mDeltaNorm; // mTargetPos with length normalized to 1
40
};
41
42
} // namespace layers
43
} // namespace mozilla
44
45
#endif // mozilla_layers_AndroidFlingPhysics_h_