OLD | NEW |
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 "cc/animation/keyframed_animation_curve.h" | 10 #include "cc/animation/keyframed_animation_curve.h" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #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" | 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 |
16 #include "ui/gfx/geometry/vector2d_f.h" | 16 #include "ui/gfx/geometry/vector2d_f.h" |
17 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 namespace { | 20 namespace { |
21 // These constants were chosen empirically for their visually pleasant behavior. | 21 // These constants were chosen empirically for their visually pleasant behavior. |
22 // Contact tedchoc@chromium.org for questions about changing these values. | 22 // Contact tedchoc@chromium.org for questions about changing these values. |
23 const int64 kShowHideMaxDurationMs = 200; | 23 const int64 kShowHideMaxDurationMs = 200; |
24 } | 24 } |
25 | 25 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (top_controls_animation_ && animation_direction_ == direction) | 183 if (top_controls_animation_ && animation_direction_ == direction) |
184 return; | 184 return; |
185 | 185 |
186 if (!TopControlsHeight()) { | 186 if (!TopControlsHeight()) { |
187 client_->SetCurrentTopControlsShownRatio( | 187 client_->SetCurrentTopControlsShownRatio( |
188 direction == HIDING_CONTROLS ? 0.f : 1.f); | 188 direction == HIDING_CONTROLS ? 0.f : 1.f); |
189 return; | 189 return; |
190 } | 190 } |
191 | 191 |
192 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); | 192 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); |
193 base::TimeDelta start_time = gfx::FrameTime::Now() - base::TimeTicks(); | 193 base::TimeDelta start_time = base::TimeTicks::Now() - base::TimeTicks(); |
194 top_controls_animation_->AddKeyframe( | 194 top_controls_animation_->AddKeyframe( |
195 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr)); | 195 FloatKeyframe::Create(start_time, TopControlsShownRatio(), nullptr)); |
196 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1); | 196 float max_ending_ratio = (direction == SHOWING_CONTROLS ? 1 : -1); |
197 top_controls_animation_->AddKeyframe(FloatKeyframe::Create( | 197 top_controls_animation_->AddKeyframe(FloatKeyframe::Create( |
198 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs), | 198 start_time + base::TimeDelta::FromMilliseconds(kShowHideMaxDurationMs), |
199 TopControlsShownRatio() + max_ending_ratio, | 199 TopControlsShownRatio() + max_ending_ratio, |
200 EaseTimingFunction::Create())); | 200 EaseTimingFunction::Create())); |
201 animation_direction_ = direction; | 201 animation_direction_ = direction; |
202 client_->DidChangeTopControlsPosition(); | 202 client_->DidChangeTopControlsPosition(); |
203 } | 203 } |
(...skipping 30 matching lines...) Expand all Loading... |
234 } | 234 } |
235 return false; | 235 return false; |
236 } | 236 } |
237 | 237 |
238 void TopControlsManager::ResetBaseline() { | 238 void TopControlsManager::ResetBaseline() { |
239 accumulated_scroll_delta_ = 0.f; | 239 accumulated_scroll_delta_ = 0.f; |
240 baseline_content_offset_ = ContentTopOffset(); | 240 baseline_content_offset_ = ContentTopOffset(); |
241 } | 241 } |
242 | 242 |
243 } // namespace cc | 243 } // namespace cc |
OLD | NEW |