| 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 "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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |