OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer_animation_element.h" | 5 #include "ui/compositor/layer_animation_element.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "ui/base/animation/tween.h" | 8 #include "ui/base/animation/tween.h" |
9 #include "ui/compositor/layer_animation_delegate.h" | 9 #include "ui/compositor/layer_animation_delegate.h" |
10 #include "ui/compositor/layer_animator.h" | 10 #include "ui/compositor/layer_animator.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 base::TimeDelta duration) | 398 base::TimeDelta duration) |
399 : first_frame_(true), | 399 : first_frame_(true), |
400 properties_(properties), | 400 properties_(properties), |
401 duration_(GetEffectiveDuration(duration)), | 401 duration_(GetEffectiveDuration(duration)), |
402 tween_type_(Tween::LINEAR) { | 402 tween_type_(Tween::LINEAR) { |
403 } | 403 } |
404 | 404 |
405 LayerAnimationElement::~LayerAnimationElement() { | 405 LayerAnimationElement::~LayerAnimationElement() { |
406 } | 406 } |
407 | 407 |
408 bool LayerAnimationElement::Progress(double t, | 408 bool LayerAnimationElement::Progress(base::TimeDelta elapsed, |
409 LayerAnimationDelegate* delegate) { | 409 LayerAnimationDelegate* delegate) { |
410 if (first_frame_) | 410 if (first_frame_) |
411 OnStart(delegate); | 411 OnStart(delegate); |
| 412 double t = 1.0; |
| 413 if ((duration_ > base::TimeDelta()) && (elapsed < duration_)) |
| 414 t = elapsed.InMillisecondsF() / duration_.InMillisecondsF(); |
412 bool need_draw = OnProgress(Tween::CalculateValue(tween_type_, t), delegate); | 415 bool need_draw = OnProgress(Tween::CalculateValue(tween_type_, t), delegate); |
413 first_frame_ = t == 1.0; | 416 first_frame_ = t == 1.0; |
414 return need_draw; | 417 return need_draw; |
415 } | 418 } |
416 | 419 |
| 420 bool LayerAnimationElement::IsFinished(base::TimeDelta elapsed, |
| 421 base::TimeDelta* total_duration) { |
| 422 if (elapsed >= duration_) { |
| 423 *total_duration = duration_; |
| 424 return true; |
| 425 } |
| 426 return false; |
| 427 } |
| 428 |
| 429 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) { |
| 430 return Progress(duration_, delegate); |
| 431 } |
| 432 |
417 void LayerAnimationElement::GetTargetValue(TargetValue* target) const { | 433 void LayerAnimationElement::GetTargetValue(TargetValue* target) const { |
418 OnGetTarget(target); | 434 OnGetTarget(target); |
419 } | 435 } |
420 | 436 |
421 void LayerAnimationElement::Abort() { | 437 void LayerAnimationElement::Abort() { |
422 first_frame_ = true; | 438 first_frame_ = true; |
423 OnAbort(); | 439 OnAbort(); |
424 } | 440 } |
425 | 441 |
426 // static | 442 // static |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 509 } |
494 | 510 |
495 // static | 511 // static |
496 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 512 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
497 SkColor color, | 513 SkColor color, |
498 base::TimeDelta duration) { | 514 base::TimeDelta duration) { |
499 return new ColorTransition(color, duration); | 515 return new ColorTransition(color, duration); |
500 } | 516 } |
501 | 517 |
502 } // namespace ui | 518 } // namespace ui |
OLD | NEW |