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_AndroidVelocityTracker_h
8
#define mozilla_layers_AndroidVelocityTracker_h
9
10
#include <utility>
11
#include <cstdint>
12
13
#include "Axis.h"
14
#include "mozilla/Attributes.h"
15
#include "mozilla/Maybe.h"
16
#include "nsTArray.h"
17
18
namespace mozilla {
19
namespace layers {
20
21
class AndroidVelocityTracker : public VelocityTracker {
22
public:
23
explicit AndroidVelocityTracker();
24
void StartTracking(ParentLayerCoord aPos, uint32_t aTimestamp) override;
25
Maybe<float> AddPosition(ParentLayerCoord aPos,
26
uint32_t aTimestampMs) override;
27
float HandleDynamicToolbarMovement(uint32_t aStartTimestampMs,
28
uint32_t aEndTimestampMs,
29
ParentLayerCoord aDelta) override;
30
Maybe<float> ComputeVelocity(uint32_t aTimestampMs) override;
31
void Clear() override;
32
33
private:
34
// A queue of (timestamp, position) pairs; these are the historical
35
// positions at the given timestamps. Timestamps are in milliseconds.
36
nsTArray<std::pair<uint32_t, ParentLayerCoord>> mHistory;
37
// The last time an event was added to the tracker (in milliseconds),
38
// or zero if no events have been added.
39
uint32_t mLastEventTime;
40
// The amount by which the page has moved relative to the screen (caused
41
// by dynamic toolbar movement) since we have started tracking velocity.
42
ParentLayerCoord mAdditionalDelta;
43
};
44
45
} // namespace layers
46
} // namespace mozilla
47
48
#endif