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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/client/fling_animation.h"
6
7 #include "base/time/default_tick_clock.h"
8
9 namespace remoting {
10
11 FlingAnimation::FlingAnimation(float time_constant,
12 const FlingCallback& fling_callback)
13 : fling_tracker_(time_constant),
14 fling_callback_(fling_callback),
15 clock_(new base::DefaultTickClock()) {}
16
17 FlingAnimation::~FlingAnimation() {}
18
19 void FlingAnimation::SetVelocity(float velocity_x, float velocity_y) {
20 fling_tracker_.StartFling(velocity_x, velocity_y);
21 fling_start_time_ = clock_->NowTicks();
22 }
23
24 bool FlingAnimation::IsAnimationInProgress() const {
25 return fling_tracker_.IsFlingInProgress();
26 }
27
28 void FlingAnimation::Tick() {
29 float dx, dy;
30 bool in_progress = fling_tracker_.TrackMovement(
31 clock_->NowTicks() - fling_start_time_, &dx, &dy);
32 if (in_progress) {
33 fling_callback_.Run(dx, dy);
34 }
35 }
36
37 void FlingAnimation::Abort() {
38 fling_tracker_.StopFling();
39 }
40
41 void FlingAnimation::SetTickClockForTest(
42 std::unique_ptr<base::TickClock> clock) {
43 clock_ = std::move(clock);
44 }
45
46 } // namespace remoting
OLDNEW
« 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