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

Unified Diff: remoting/client/fling_animation.cc

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.h ('k') | remoting/client/fling_animation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/fling_animation.cc
diff --git a/remoting/client/fling_animation.cc b/remoting/client/fling_animation.cc
new file mode 100644
index 0000000000000000000000000000000000000000..109a5c4e3d0d85dce4c4f0c37f26c7cbd522c1f0
--- /dev/null
+++ b/remoting/client/fling_animation.cc
@@ -0,0 +1,46 @@
+// 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.
+
+#include "remoting/client/fling_animation.h"
+
+#include "base/time/default_tick_clock.h"
+
+namespace remoting {
+
+FlingAnimation::FlingAnimation(float time_constant,
+ const FlingCallback& fling_callback)
+ : fling_tracker_(time_constant),
+ fling_callback_(fling_callback),
+ clock_(new base::DefaultTickClock()) {}
+
+FlingAnimation::~FlingAnimation() {}
+
+void FlingAnimation::SetVelocity(float velocity_x, float velocity_y) {
+ fling_tracker_.StartFling(velocity_x, velocity_y);
+ fling_start_time_ = clock_->NowTicks();
+}
+
+bool FlingAnimation::IsAnimationInProgress() const {
+ return fling_tracker_.IsFlingInProgress();
+}
+
+void FlingAnimation::Tick() {
+ float dx, dy;
+ bool in_progress = fling_tracker_.TrackMovement(
+ clock_->NowTicks() - fling_start_time_, &dx, &dy);
+ if (in_progress) {
+ fling_callback_.Run(dx, dy);
+ }
+}
+
+void FlingAnimation::Abort() {
+ fling_tracker_.StopFling();
+}
+
+void FlingAnimation::SetTickClockForTest(
+ std::unique_ptr<base::TickClock> clock) {
+ clock_ = std::move(clock);
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/client/fling_animation.h ('k') | remoting/client/fling_animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698