Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: remoting/client/fling_tracker.h

Issue 2869723007: [CRD iOS] Viewport fling animation (Closed)
Patch Set: Merge branch 'master' into feat-fling-animation Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/fling_animation_unittest.cc ('k') | remoting/client/fling_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/fling_tracker.h
diff --git a/remoting/client/fling_tracker.h b/remoting/client/fling_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb8a50aac4809346bf934c680c4e1fdd9a38c568
--- /dev/null
+++ b/remoting/client/fling_tracker.h
@@ -0,0 +1,52 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_CLIENT_FLING_TRACKER_H_
+#define REMOTING_CLIENT_FLING_TRACKER_H_
+
+#include "base/time/time.h"
+
+namespace remoting {
+
+// A class for tracking the positions of an object moving through a viscous
+// liquid.
+class FlingTracker {
+ public:
+ // time_constant: The larger the number the longer it takes to fling.
+ explicit FlingTracker(float time_constant);
+
+ ~FlingTracker();
+
+ // Sets the position of the object and start fling. This will reset the
+ // existing fling.
+ void StartFling(float velocity_x, float velocity_y);
+
+ void StopFling();
+
+ bool IsFlingInProgress() const;
+
+ // time_elapsed: The time elapsed since the animation has started.
+ // Moves forward the object to catch up with |time_elapsed|. The change in
+ // positions will be written to |dx| and |dy|.
+ // Returns true if the fling is still in progress at |time_elapsed|, false
+ // otherwise, in which case |dx| and |dy| will not be touched.
+ bool TrackMovement(base::TimeDelta time_elapsed, float* dx, float* dy);
+
+ private:
+ float time_constant_;
+ float initial_speed_rate_ = 0.f;
+ float velocity_ratio_x_ = 0.f;
+ float velocity_ratio_y_ = 0.f;
+ float previous_position_x_ = 0.f;
+ float previous_position_y_ = 0.f;
+
+ base::TimeTicks start_time_;
+
+ // FlingTracker is neither copyable nor movable.
+ FlingTracker(const FlingTracker&) = delete;
+ FlingTracker& operator=(const FlingTracker&) = delete;
+};
+
+} // namespace remoting
+#endif // REMOTING_CLIENT_FLING_TRACKER_H_
« no previous file with comments | « remoting/client/fling_animation_unittest.cc ('k') | remoting/client/fling_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698