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 20 matching lines...) Expand all Loading... |
31 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {} | 31 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {} |
32 virtual void OnAbort() OVERRIDE {} | 32 virtual void OnAbort() OVERRIDE {} |
33 | 33 |
34 DISALLOW_COPY_AND_ASSIGN(Pause); | 34 DISALLOW_COPY_AND_ASSIGN(Pause); |
35 }; | 35 }; |
36 | 36 |
37 // TransformTransition --------------------------------------------------------- | 37 // TransformTransition --------------------------------------------------------- |
38 | 38 |
39 class TransformTransition : public LayerAnimationElement { | 39 class TransformTransition : public LayerAnimationElement { |
40 public: | 40 public: |
41 TransformTransition(const Transform& target, base::TimeDelta duration) | 41 TransformTransition(const gfx::Transform& target, base::TimeDelta duration) |
42 : LayerAnimationElement(GetProperties(), duration), | 42 : LayerAnimationElement(GetProperties(), duration), |
43 target_(target) { | 43 target_(target) { |
44 } | 44 } |
45 virtual ~TransformTransition() {} | 45 virtual ~TransformTransition() {} |
46 | 46 |
47 protected: | 47 protected: |
48 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 48 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { |
49 start_ = delegate->GetTransformForAnimation(); | 49 start_ = delegate->GetTransformForAnimation(); |
50 } | 50 } |
51 | 51 |
52 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 52 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { |
53 delegate->SetTransformFromAnimation( | 53 delegate->SetTransformFromAnimation( |
54 Tween::ValueBetween(t, start_, target_)); | 54 Tween::ValueBetween(t, start_, target_)); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 58 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { |
59 target->transform = target_; | 59 target->transform = target_; |
60 } | 60 } |
61 | 61 |
62 virtual void OnAbort() OVERRIDE {} | 62 virtual void OnAbort() OVERRIDE {} |
63 | 63 |
64 private: | 64 private: |
65 static AnimatableProperties GetProperties() { | 65 static AnimatableProperties GetProperties() { |
66 AnimatableProperties properties; | 66 AnimatableProperties properties; |
67 properties.insert(LayerAnimationElement::TRANSFORM); | 67 properties.insert(LayerAnimationElement::TRANSFORM); |
68 return properties; | 68 return properties; |
69 } | 69 } |
70 | 70 |
71 Transform start_; | 71 gfx::Transform start_; |
72 const Transform target_; | 72 const gfx::Transform target_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(TransformTransition); | 74 DISALLOW_COPY_AND_ASSIGN(TransformTransition); |
75 }; | 75 }; |
76 | 76 |
77 // InterpolatedTransformTransition --------------------------------------------- | 77 // InterpolatedTransformTransition --------------------------------------------- |
78 | 78 |
79 class InterpolatedTransformTransition : public LayerAnimationElement { | 79 class InterpolatedTransformTransition : public LayerAnimationElement { |
80 public: | 80 public: |
81 InterpolatedTransformTransition(InterpolatedTransform* interpolated_transform, | 81 InterpolatedTransformTransition(InterpolatedTransform* interpolated_transform, |
82 base::TimeDelta duration) | 82 base::TimeDelta duration) |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 : opacity(0.0f), | 375 : opacity(0.0f), |
376 visibility(false), | 376 visibility(false), |
377 brightness(0.0f), | 377 brightness(0.0f), |
378 grayscale(0.0f), | 378 grayscale(0.0f), |
379 color(SK_ColorBLACK) { | 379 color(SK_ColorBLACK) { |
380 } | 380 } |
381 | 381 |
382 LayerAnimationElement::TargetValue::TargetValue( | 382 LayerAnimationElement::TargetValue::TargetValue( |
383 const LayerAnimationDelegate* delegate) | 383 const LayerAnimationDelegate* delegate) |
384 : bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()), | 384 : bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()), |
385 transform(delegate ? delegate->GetTransformForAnimation() : Transform()), | 385 transform(delegate ? delegate->GetTransformForAnimation() : gfx::Transform
()), |
386 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f), | 386 opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f), |
387 visibility(delegate ? delegate->GetVisibilityForAnimation() : false), | 387 visibility(delegate ? delegate->GetVisibilityForAnimation() : false), |
388 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), | 388 brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f), |
389 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), | 389 grayscale(delegate ? delegate->GetGrayscaleForAnimation() : 0.0f), |
390 color(delegate ? delegate->GetColorForAnimation() : 0.0f) { | 390 color(delegate ? delegate->GetColorForAnimation() : 0.0f) { |
391 } | 391 } |
392 | 392 |
393 // LayerAnimationElement ------------------------------------------------------- | 393 // LayerAnimationElement ------------------------------------------------------- |
394 | 394 |
395 LayerAnimationElement::LayerAnimationElement( | 395 LayerAnimationElement::LayerAnimationElement( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 return base::TimeDelta(); | 429 return base::TimeDelta(); |
430 | 430 |
431 if (LayerAnimator::slow_animation_mode()) | 431 if (LayerAnimator::slow_animation_mode()) |
432 return duration * LayerAnimator::slow_animation_scale_factor(); | 432 return duration * LayerAnimator::slow_animation_scale_factor(); |
433 | 433 |
434 return duration; | 434 return duration; |
435 } | 435 } |
436 | 436 |
437 // static | 437 // static |
438 LayerAnimationElement* LayerAnimationElement::CreateTransformElement( | 438 LayerAnimationElement* LayerAnimationElement::CreateTransformElement( |
439 const Transform& transform, | 439 const gfx::Transform& transform, |
440 base::TimeDelta duration) { | 440 base::TimeDelta duration) { |
441 return new TransformTransition(transform, duration); | 441 return new TransformTransition(transform, duration); |
442 } | 442 } |
443 | 443 |
444 // static | 444 // static |
445 LayerAnimationElement* | 445 LayerAnimationElement* |
446 LayerAnimationElement::CreateInterpolatedTransformElement( | 446 LayerAnimationElement::CreateInterpolatedTransformElement( |
447 InterpolatedTransform* interpolated_transform, | 447 InterpolatedTransform* interpolated_transform, |
448 base::TimeDelta duration) { | 448 base::TimeDelta duration) { |
449 return new InterpolatedTransformTransition(interpolated_transform, duration); | 449 return new InterpolatedTransformTransition(interpolated_transform, duration); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 } | 492 } |
493 | 493 |
494 // static | 494 // static |
495 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 495 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
496 SkColor color, | 496 SkColor color, |
497 base::TimeDelta duration) { | 497 base::TimeDelta duration) { |
498 return new ColorTransition(color, duration); | 498 return new ColorTransition(color, duration); |
499 } | 499 } |
500 | 500 |
501 } // namespace ui | 501 } // namespace ui |
OLD | NEW |