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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "cc/animation/animation_host.h" | 13 #include "cc/animation/animation_host.h" |
14 #include "cc/animation/animation_id_provider.h" | 14 #include "cc/animation/animation_id_provider.h" |
15 #include "cc/animation/animation_player.h" | 15 #include "cc/animation/animation_player.h" |
16 #include "cc/animation/animation_timeline.h" | 16 #include "cc/animation/animation_timeline.h" |
17 #include "cc/animation/element_animations.h" | 17 #include "cc/animation/element_animations.h" |
18 #include "cc/output/begin_frame_args.h" | 18 #include "cc/output/begin_frame_args.h" |
19 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
20 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
21 #include "ui/compositor/layer_animation_delegate.h" | 21 #include "ui/compositor/layer_animation_delegate.h" |
22 #include "ui/compositor/layer_animation_observer.h" | 22 #include "ui/compositor/layer_animation_observer.h" |
23 #include "ui/compositor/layer_animation_sequence.h" | 23 #include "ui/compositor/layer_animation_sequence.h" |
24 #include "ui/compositor/layer_animator_collection.h" | 24 #include "ui/compositor/layer_animator_collection.h" |
25 | 25 |
| 26 #include "base/debug/stack_trace.h" |
26 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ | 27 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ |
27 if (running_anim.is_sequence_alive()) \ | 28 if (running_anim.is_sequence_alive()) \ |
28 function(running_anim.sequence(), ##__VA_ARGS__) | 29 function(running_anim.sequence(), ##__VA_ARGS__) |
29 #define SAFE_INVOKE_BOOL(function, running_anim) \ | 30 #define SAFE_INVOKE_BOOL(function, running_anim) \ |
30 ((running_anim.is_sequence_alive()) \ | 31 ((running_anim.is_sequence_alive()) \ |
31 ? function(running_anim.sequence()) \ | 32 ? function(running_anim.sequence()) \ |
32 : false) | 33 : false) |
33 #define SAFE_INVOKE_PTR(function, running_anim) \ | 34 #define SAFE_INVOKE_PTR(function, running_anim) \ |
34 ((running_anim.is_sequence_alive()) \ | 35 ((running_anim.is_sequence_alive()) \ |
35 ? function(running_anim.sequence()) \ | 36 ? function(running_anim.sequence()) \ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { | 73 LayerAnimator* LayerAnimator::CreateDefaultAnimator() { |
73 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); | 74 return new LayerAnimator(base::TimeDelta::FromMilliseconds(0)); |
74 } | 75 } |
75 | 76 |
76 // static | 77 // static |
77 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { | 78 LayerAnimator* LayerAnimator::CreateImplicitAnimator() { |
78 return new LayerAnimator( | 79 return new LayerAnimator( |
79 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); | 80 base::TimeDelta::FromMilliseconds(kDefaultTransitionDurationMs)); |
80 } | 81 } |
81 | 82 |
| 83 void Print(const std::string& name, const gfx::Rect& r) { |
| 84 LOG(ERROR) << name << ":" << r.ToString(); |
| 85 } |
| 86 |
| 87 void Print(const std::string& name, const gfx::Transform& t) { |
| 88 LOG(ERROR) << name << ":" << t.ToString(); |
| 89 } |
| 90 |
| 91 void Print(const std::string& name, float f) { |
| 92 LOG(ERROR) << name << ":" << f; |
| 93 } |
| 94 |
| 95 void Print(const std::string& name, int i) { |
| 96 LOG(ERROR) << name << ":" << i; |
| 97 } |
| 98 |
| 99 void Print(const std::string& name, SkColor c) { |
| 100 LOG(ERROR) << name << ":" << c; |
| 101 } |
| 102 |
82 // This macro provides the implementation for the setter and getter (well, | 103 // This macro provides the implementation for the setter and getter (well, |
83 // the getter of the target value) for an animated property. For example, | 104 // the getter of the target value) for an animated property. For example, |
84 // it is used for the implementations of SetTransform and GetTargetTransform. | 105 // it is used for the implementations of SetTransform and GetTargetTransform. |
85 // It is worth noting that SetFoo avoids invoking the usual animation machinery | 106 // It is worth noting that SetFoo avoids invoking the usual animation machinery |
86 // if the transition duration is zero -- in this case we just set the property | 107 // if the transition duration is zero -- in this case we just set the property |
87 // on the layer animation delegate immediately. | 108 // on the layer animation delegate immediately. |
88 #define ANIMATED_PROPERTY(type, property, name, member_type, member) \ | 109 #define ANIMATED_PROPERTY(type, property, name, member_type, member) \ |
89 void LayerAnimator::Set##name(type value) { \ | 110 void LayerAnimator::Set##name(type value) { \ |
90 base::TimeDelta duration = GetTransitionDuration(); \ | 111 base::TimeDelta duration = GetTransitionDuration(); \ |
91 if (duration.is_zero() && delegate() && \ | 112 if (duration.is_zero() && delegate() && \ |
92 (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \ | 113 (preemption_strategy_ != ENQUEUE_NEW_ANIMATION)) { \ |
93 StopAnimatingProperty(LayerAnimationElement::property); \ | 114 StopAnimatingProperty(LayerAnimationElement::property); \ |
94 delegate()->Set##name##FromAnimation(value); \ | 115 delegate()->Set##name##FromAnimation(value); \ |
95 return; \ | 116 return; \ |
96 } \ | 117 } \ |
97 std::unique_ptr<LayerAnimationElement> element( \ | 118 std::unique_ptr<LayerAnimationElement> element( \ |
98 LayerAnimationElement::Create##name##Element(value, duration)); \ | 119 LayerAnimationElement::Create##name##Element(value, duration)); \ |
99 element->set_tween_type(tween_type_); \ | 120 element->set_tween_type(tween_type_); \ |
100 StartAnimation(new LayerAnimationSequence(element.release())); \ | 121 StartAnimation(new LayerAnimationSequence(element.release())); \ |
101 } \ | 122 } \ |
102 \ | 123 \ |
103 member_type LayerAnimator::GetTarget##name() const { \ | 124 member_type LayerAnimator::GetTarget##name() const { \ |
104 LayerAnimationElement::TargetValue target(delegate()); \ | 125 LayerAnimationElement::TargetValue target(delegate()); \ |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 const base::WeakPtr<LayerAnimationSequence>& sequence) | 988 const base::WeakPtr<LayerAnimationSequence>& sequence) |
968 : sequence_(sequence) { | 989 : sequence_(sequence) { |
969 } | 990 } |
970 | 991 |
971 LayerAnimator::RunningAnimation::RunningAnimation( | 992 LayerAnimator::RunningAnimation::RunningAnimation( |
972 const RunningAnimation& other) = default; | 993 const RunningAnimation& other) = default; |
973 | 994 |
974 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 995 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
975 | 996 |
976 } // namespace ui | 997 } // namespace ui |
OLD | NEW |