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

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

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP 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 | « cc/input/top_controls_manager.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('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 "cc/animation/keyframed_animation_curve.h" 10 #include "cc/animation/keyframed_animation_curve.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 controls_top_offset = std::min(controls_top_offset, 0.f); 129 controls_top_offset = std::min(controls_top_offset, 0.f);
130 130
131 if (controls_top_offset_ == controls_top_offset) 131 if (controls_top_offset_ == controls_top_offset)
132 return; 132 return;
133 133
134 controls_top_offset_ = controls_top_offset; 134 controls_top_offset_ = controls_top_offset;
135 135
136 client_->DidChangeTopControlsPosition(); 136 client_->DidChangeTopControlsPosition();
137 } 137 }
138 138
139 gfx::Vector2dF TopControlsManager::Animate(base::TimeTicks monotonic_time) { 139 gfx::Vector2dF TopControlsManager::Animate(gfx::FrameTime monotonic_time) {
140 if (!top_controls_animation_ || !client_->HaveRootScrollLayer()) 140 if (!top_controls_animation_ || !client_->HaveRootScrollLayer())
141 return gfx::Vector2dF(); 141 return gfx::Vector2dF();
142 142
143 double time = (monotonic_time - base::TimeTicks()).InMillisecondsF(); 143 double time = monotonic_time.Unsafe_InMillisecondsF();
144 144
145 float old_offset = controls_top_offset_; 145 float old_offset = controls_top_offset_;
146 SetControlsTopOffset(top_controls_animation_->GetValue(time)); 146 SetControlsTopOffset(top_controls_animation_->GetValue(time));
147 147
148 if (IsAnimationCompleteAtTime(monotonic_time)) 148 if (IsAnimationCompleteAtTime(monotonic_time))
149 ResetAnimations(); 149 ResetAnimations();
150 150
151 gfx::Vector2dF scroll_delta(0.f, controls_top_offset_ - old_offset); 151 gfx::Vector2dF scroll_delta(0.f, controls_top_offset_ - old_offset);
152 return scroll_delta; 152 return scroll_delta;
153 } 153 }
(...skipping 14 matching lines...) Expand all
168 if (direction == HIDING_CONTROLS && 168 if (direction == HIDING_CONTROLS &&
169 controls_top_offset_ == -top_controls_height_) { 169 controls_top_offset_ == -top_controls_height_) {
170 return; 170 return;
171 } 171 }
172 172
173 if (top_controls_animation_ && animation_direction_ == direction) 173 if (top_controls_animation_ && animation_direction_ == direction)
174 return; 174 return;
175 175
176 top_controls_animation_ = KeyframedFloatAnimationCurve::Create(); 176 top_controls_animation_ = KeyframedFloatAnimationCurve::Create();
177 double start_time = 177 double start_time =
178 (gfx::FrameTime::Now() - base::TimeTicks()).InMillisecondsF(); 178 gfx::FrameTime::Now().Unsafe_InMillisecondsF();
179 top_controls_animation_->AddKeyframe( 179 top_controls_animation_->AddKeyframe(
180 FloatKeyframe::Create(start_time, controls_top_offset_, 180 FloatKeyframe::Create(start_time, controls_top_offset_,
181 scoped_ptr<TimingFunction>())); 181 scoped_ptr<TimingFunction>()));
182 float max_ending_offset = 182 float max_ending_offset =
183 (direction == SHOWING_CONTROLS ? 1 : -1) * top_controls_height_; 183 (direction == SHOWING_CONTROLS ? 1 : -1) * top_controls_height_;
184 top_controls_animation_->AddKeyframe( 184 top_controls_animation_->AddKeyframe(
185 FloatKeyframe::Create(start_time + kShowHideMaxDurationMs, 185 FloatKeyframe::Create(start_time + kShowHideMaxDurationMs,
186 controls_top_offset_ + max_ending_offset, 186 controls_top_offset_ + max_ending_offset,
187 EaseTimingFunction::Create())); 187 EaseTimingFunction::Create()));
188 animation_direction_ = direction; 188 animation_direction_ = direction;
(...skipping 17 matching lines...) Expand all
206 // down. 206 // down.
207 show_controls = current_scroll_delta_ <= 0.f ? 207 show_controls = current_scroll_delta_ <= 0.f ?
208 SHOWING_CONTROLS : HIDING_CONTROLS; 208 SHOWING_CONTROLS : HIDING_CONTROLS;
209 } 209 }
210 210
211 if (show_controls != NO_ANIMATION) 211 if (show_controls != NO_ANIMATION)
212 SetupAnimation(show_controls); 212 SetupAnimation(show_controls);
213 } 213 }
214 } 214 }
215 215
216 bool TopControlsManager::IsAnimationCompleteAtTime(base::TimeTicks time) { 216 bool TopControlsManager::IsAnimationCompleteAtTime(
217 gfx::FrameTime time) {
217 if (!top_controls_animation_) 218 if (!top_controls_animation_)
218 return true; 219 return true;
219 220
220 double time_ms = (time - base::TimeTicks()).InMillisecondsF(); 221 double time_ms = time.Unsafe_InMillisecondsF();
221 float new_offset = top_controls_animation_->GetValue(time_ms); 222 float new_offset = top_controls_animation_->GetValue(time_ms);
222 223
223 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) || 224 if ((animation_direction_ == SHOWING_CONTROLS && new_offset >= 0) ||
224 (animation_direction_ == HIDING_CONTROLS 225 (animation_direction_ == HIDING_CONTROLS
225 && new_offset <= -top_controls_height_)) { 226 && new_offset <= -top_controls_height_)) {
226 return true; 227 return true;
227 } 228 }
228 return false; 229 return false;
229 } 230 }
230 231
231 } // namespace cc 232 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/top_controls_manager.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698