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

Side by Side Diff: cc/input/top_controls_manager.cc

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK Created 7 years, 1 month 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 | « no previous file | cc/input/top_controls_manager_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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/input/top_controls_manager.h" 5 #include "cc/input/top_controls_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h"
11 #include "cc/animation/keyframed_animation_curve.h" 10 #include "cc/animation/keyframed_animation_curve.h"
12 #include "cc/animation/timing_function.h" 11 #include "cc/animation/timing_function.h"
13 #include "cc/input/top_controls_manager_client.h" 12 #include "cc/input/top_controls_manager_client.h"
13 #include "cc/output/begin_frame_args.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 #include "ui/gfx/frame_time.h"
15 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
16 #include "ui/gfx/vector2d_f.h" 17 #include "ui/gfx/vector2d_f.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
20 // These constants were chosen empirically for their visually pleasant behavior. 21 // These constants were chosen empirically for their visually pleasant behavior.
21 // Contact tedchoc@chromium.org for questions about changing these values. 22 // Contact tedchoc@chromium.org for questions about changing these values.
22 const int64 kShowHideMaxDurationMs = 200; 23 const int64 kShowHideMaxDurationMs = 200;
23 } 24 }
24 25
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (direction == HIDING_CONTROLS && 168 if (direction == HIDING_CONTROLS &&
168 controls_top_offset_ == -top_controls_height_) { 169 controls_top_offset_ == -top_controls_height_) {
169 return; 170 return;
170 } 171 }
171 172
172 if (top_controls_animation_ && animation_direction_ == direction) 173 if (top_controls_animation_ && animation_direction_ == direction)
173 return; 174 return;
174 175
175 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); 176 top_controls_animation_ = KeyframedFloatAnimationCurve::Create();
176 double start_time = 177 double start_time =
177 (base::TimeTicks::Now() - base::TimeTicks()).InMillisecondsF(); 178 (gfx::FrameTime::Now() - base::TimeTicks()).InMillisecondsF();
178 top_controls_animation_->AddKeyframe( 179 top_controls_animation_->AddKeyframe(
179 FloatKeyframe::Create(start_time, controls_top_offset_, 180 FloatKeyframe::Create(start_time, controls_top_offset_,
180 scoped_ptr<TimingFunction>())); 181 scoped_ptr<TimingFunction>()));
181 float max_ending_offset = 182 float max_ending_offset =
182 (direction == SHOWING_CONTROLS ? 1 : -1) * top_controls_height_; 183 (direction == SHOWING_CONTROLS ? 1 : -1) * top_controls_height_;
183 top_controls_animation_->AddKeyframe( 184 top_controls_animation_->AddKeyframe(
184 FloatKeyframe::Create(start_time + kShowHideMaxDurationMs, 185 FloatKeyframe::Create(start_time + kShowHideMaxDurationMs,
185 controls_top_offset_ + max_ending_offset, 186 controls_top_offset_ + max_ending_offset,
186 EaseTimingFunction::Create())); 187 EaseTimingFunction::Create()));
187 animation_direction_ = direction; 188 animation_direction_ = direction;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) || 223 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) ||
223 (animation_direction_ == HIDING_CONTROLS 224 (animation_direction_ == HIDING_CONTROLS
224 && new_offset <= -top_controls_height_)) { 225 && new_offset <= -top_controls_height_)) {
225 return true; 226 return true;
226 } 227 }
227 return false; 228 return false;
228 } 229 }
229 230
230 } // namespace cc 231 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/input/top_controls_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698