tor-browser

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

AndroidFlingPhysics.h (1601B)


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