tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AndroidVelocityTracker.h (1304B)


      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 
     12 #include "Axis.h"
     13 #include "mozilla/Maybe.h"
     14 #include "nsTArray.h"
     15 
     16 namespace mozilla {
     17 namespace layers {
     18 
     19 class AndroidVelocityTracker : public VelocityTracker {
     20 public:
     21  explicit AndroidVelocityTracker();
     22  void StartTracking(ParentLayerCoord aPos, TimeStamp aTimestamp) override;
     23  Maybe<float> AddPosition(ParentLayerCoord aPos,
     24                           TimeStamp aTimestamp) override;
     25  Maybe<float> ComputeVelocity(TimeStamp aTimestamp) override;
     26  void Clear() override;
     27 
     28 private:
     29  // A queue of (timestamp, position) pairs; these are the historical
     30  // positions at the given timestamps.
     31  nsTArray<std::pair<TimeStamp, ParentLayerCoord>> mHistory;
     32  // The last time an event was added to the tracker, or the null moment if no
     33  // events have been added.
     34  TimeStamp mLastEventTime;
     35 };
     36 
     37 }  // namespace layers
     38 }  // namespace mozilla
     39 
     40 #endif