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_animator.h" | 5 #include "ui/compositor/layer_animator.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "cc/animation/animation_id_provider.h" | 10 #include "cc/animation/animation_id_provider.h" |
11 #include "ui/base/animation/animation_container.h" | |
12 #include "ui/compositor/compositor.h" | 11 #include "ui/compositor/compositor.h" |
13 #include "ui/compositor/layer.h" | 12 #include "ui/compositor/layer.h" |
14 #include "ui/compositor/layer_animation_delegate.h" | 13 #include "ui/compositor/layer_animation_delegate.h" |
15 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/compositor/layer_animation_sequence.h" | 15 #include "ui/compositor/layer_animation_sequence.h" |
| 16 #include "ui/gfx/animation/animation_container.h" |
17 | 17 |
18 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ | 18 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ |
19 if (running_anim.is_sequence_alive()) \ | 19 if (running_anim.is_sequence_alive()) \ |
20 function(running_anim.sequence(), ##__VA_ARGS__) | 20 function(running_anim.sequence(), ##__VA_ARGS__) |
21 #define SAFE_INVOKE_BOOL(function, running_anim) \ | 21 #define SAFE_INVOKE_BOOL(function, running_anim) \ |
22 ((running_anim.is_sequence_alive()) \ | 22 ((running_anim.is_sequence_alive()) \ |
23 ? function(running_anim.sequence()) \ | 23 ? function(running_anim.sequence()) \ |
24 : false) | 24 : false) |
25 #define SAFE_INVOKE_PTR(function, running_anim) \ | 25 #define SAFE_INVOKE_PTR(function, running_anim) \ |
26 ((running_anim.is_sequence_alive()) \ | 26 ((running_anim.is_sequence_alive()) \ |
27 ? function(running_anim.sequence()) \ | 27 ? function(running_anim.sequence()) \ |
28 : NULL) | 28 : NULL) |
29 | 29 |
30 namespace ui { | 30 namespace ui { |
31 | 31 |
32 class LayerAnimator; | 32 class LayerAnimator; |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 const int kDefaultTransitionDurationMs = 120; | 36 const int kDefaultTransitionDurationMs = 120; |
37 const int kTimerIntervalMs = 10; | 37 const int kTimerIntervalMs = 10; |
38 | 38 |
39 // Returns the AnimationContainer we're added to. | 39 // Returns the AnimationContainer we're added to. |
40 ui::AnimationContainer* GetAnimationContainer() { | 40 gfx::AnimationContainer* GetAnimationContainer() { |
41 static ui::AnimationContainer* container = NULL; | 41 static gfx::AnimationContainer* container = NULL; |
42 if (!container) { | 42 if (!container) { |
43 container = new AnimationContainer(); | 43 container = new gfx::AnimationContainer(); |
44 container->AddRef(); | 44 container->AddRef(); |
45 } | 45 } |
46 return container; | 46 return container; |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 // LayerAnimator public -------------------------------------------------------- | 51 // LayerAnimator public -------------------------------------------------------- |
52 | 52 |
53 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) | 53 LayerAnimator::LayerAnimator(base::TimeDelta transition_duration) |
54 : delegate_(NULL), | 54 : delegate_(NULL), |
55 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), | 55 preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET), |
56 transition_duration_(transition_duration), | 56 transition_duration_(transition_duration), |
57 tween_type_(Tween::LINEAR), | 57 tween_type_(gfx::Tween::LINEAR), |
58 is_started_(false), | 58 is_started_(false), |
59 disable_timer_for_test_(false), | 59 disable_timer_for_test_(false), |
60 adding_animations_(false) { | 60 adding_animations_(false) { |
61 } | 61 } |
62 | 62 |
63 LayerAnimator::~LayerAnimator() { | 63 LayerAnimator::~LayerAnimator() { |
64 for (size_t i = 0; i < running_animations_.size(); ++i) { | 64 for (size_t i = 0; i < running_animations_.size(); ++i) { |
65 if (running_animations_[i].is_sequence_alive()) | 65 if (running_animations_[i].is_sequence_alive()) |
66 running_animations_[i].sequence()->OnAnimatorDestroyed(); | 66 running_animations_[i].sequence()->OnAnimatorDestroyed(); |
67 } | 67 } |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 } | 844 } |
845 | 845 |
846 LayerAnimator::RunningAnimation::RunningAnimation( | 846 LayerAnimator::RunningAnimation::RunningAnimation( |
847 const base::WeakPtr<LayerAnimationSequence>& sequence) | 847 const base::WeakPtr<LayerAnimationSequence>& sequence) |
848 : sequence_(sequence) { | 848 : sequence_(sequence) { |
849 } | 849 } |
850 | 850 |
851 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 851 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
852 | 852 |
853 } // namespace ui | 853 } // namespace ui |
OLD | NEW |