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