OLD | NEW |
| (Empty) |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_ | |
6 #define CC_TEST_ANIMATION_TEST_COMMON_H_ | |
7 | |
8 #include "cc/animation/animation.h" | |
9 #include "cc/animation/animation_curve.h" | |
10 #include "cc/animation/layer_animation_controller.h" | |
11 #include "cc/animation/layer_animation_value_observer.h" | |
12 #include "cc/animation/layer_animation_value_provider.h" | |
13 #include "cc/output/filter_operations.h" | |
14 #include "cc/test/geometry_test_utils.h" | |
15 | |
16 namespace cc { | |
17 class LayerImpl; | |
18 class Layer; | |
19 } | |
20 | |
21 namespace cc { | |
22 | |
23 class FakeFloatAnimationCurve : public FloatAnimationCurve { | |
24 public: | |
25 FakeFloatAnimationCurve(); | |
26 explicit FakeFloatAnimationCurve(double duration); | |
27 ~FakeFloatAnimationCurve() override; | |
28 | |
29 base::TimeDelta Duration() const override; | |
30 float GetValue(base::TimeDelta now) const override; | |
31 scoped_ptr<AnimationCurve> Clone() const override; | |
32 | |
33 private: | |
34 base::TimeDelta duration_; | |
35 }; | |
36 | |
37 class FakeTransformTransition : public TransformAnimationCurve { | |
38 public: | |
39 explicit FakeTransformTransition(double duration); | |
40 ~FakeTransformTransition() override; | |
41 | |
42 base::TimeDelta Duration() const override; | |
43 gfx::Transform GetValue(base::TimeDelta time) const override; | |
44 bool AnimatedBoundsForBox(const gfx::BoxF& box, | |
45 gfx::BoxF* bounds) const override; | |
46 bool AffectsScale() const override; | |
47 bool IsTranslation() const override; | |
48 bool PreservesAxisAlignment() const override; | |
49 bool MaximumTargetScale(bool forward_direction, | |
50 float* max_scale) const override; | |
51 | |
52 scoped_ptr<AnimationCurve> Clone() const override; | |
53 | |
54 private: | |
55 base::TimeDelta duration_; | |
56 }; | |
57 | |
58 class FakeFloatTransition : public FloatAnimationCurve { | |
59 public: | |
60 FakeFloatTransition(double duration, float from, float to); | |
61 ~FakeFloatTransition() override; | |
62 | |
63 base::TimeDelta Duration() const override; | |
64 float GetValue(base::TimeDelta time) const override; | |
65 | |
66 scoped_ptr<AnimationCurve> Clone() const override; | |
67 | |
68 private: | |
69 base::TimeDelta duration_; | |
70 float from_; | |
71 float to_; | |
72 }; | |
73 | |
74 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver { | |
75 public: | |
76 FakeLayerAnimationValueObserver(); | |
77 ~FakeLayerAnimationValueObserver() override; | |
78 | |
79 // LayerAnimationValueObserver implementation | |
80 void OnFilterAnimated(const FilterOperations& filters) override; | |
81 void OnOpacityAnimated(float opacity) override; | |
82 void OnTransformAnimated(const gfx::Transform& transform) override; | |
83 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; | |
84 void OnAnimationWaitingForDeletion() override; | |
85 bool IsActive() const override; | |
86 | |
87 const FilterOperations& filters() const { return filters_; } | |
88 float opacity() const { return opacity_; } | |
89 const gfx::Transform& transform() const { return transform_; } | |
90 gfx::ScrollOffset scroll_offset() { return scroll_offset_; } | |
91 | |
92 bool animation_waiting_for_deletion() { | |
93 return animation_waiting_for_deletion_; | |
94 } | |
95 | |
96 private: | |
97 FilterOperations filters_; | |
98 float opacity_; | |
99 gfx::Transform transform_; | |
100 gfx::ScrollOffset scroll_offset_; | |
101 bool animation_waiting_for_deletion_; | |
102 }; | |
103 | |
104 class FakeInactiveLayerAnimationValueObserver | |
105 : public FakeLayerAnimationValueObserver { | |
106 public: | |
107 bool IsActive() const override; | |
108 }; | |
109 | |
110 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider { | |
111 public: | |
112 gfx::ScrollOffset ScrollOffsetForAnimation() const override; | |
113 | |
114 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { | |
115 scroll_offset_ = scroll_offset; | |
116 } | |
117 | |
118 private: | |
119 gfx::ScrollOffset scroll_offset_; | |
120 }; | |
121 | |
122 int AddOpacityTransitionToController(LayerAnimationController* controller, | |
123 double duration, | |
124 float start_opacity, | |
125 float end_opacity, | |
126 bool use_timing_function); | |
127 | |
128 int AddAnimatedTransformToController(LayerAnimationController* controller, | |
129 double duration, | |
130 int delta_x, | |
131 int delta_y); | |
132 | |
133 int AddAnimatedFilterToController(LayerAnimationController* controller, | |
134 double duration, | |
135 float start_brightness, | |
136 float end_brightness); | |
137 | |
138 int AddOpacityTransitionToLayer(Layer* layer, | |
139 double duration, | |
140 float start_opacity, | |
141 float end_opacity, | |
142 bool use_timing_function); | |
143 | |
144 int AddOpacityTransitionToLayer(LayerImpl* layer, | |
145 double duration, | |
146 float start_opacity, | |
147 float end_opacity, | |
148 bool use_timing_function); | |
149 | |
150 int AddAnimatedTransformToLayer(Layer* layer, | |
151 double duration, | |
152 int delta_x, | |
153 int delta_y); | |
154 | |
155 int AddAnimatedTransformToLayer(LayerImpl* layer, | |
156 double duration, | |
157 int delta_x, | |
158 int delta_y); | |
159 | |
160 int AddAnimatedTransformToLayer(Layer* layer, | |
161 double duration, | |
162 TransformOperations start_operations, | |
163 TransformOperations operations); | |
164 | |
165 int AddAnimatedTransformToLayer(LayerImpl* layer, | |
166 double duration, | |
167 TransformOperations start_operations, | |
168 TransformOperations operations); | |
169 | |
170 int AddAnimatedFilterToLayer(Layer* layer, | |
171 double duration, | |
172 float start_brightness, | |
173 float end_brightness); | |
174 | |
175 int AddAnimatedFilterToLayer(LayerImpl* layer, | |
176 double duration, | |
177 float start_brightness, | |
178 float end_brightness); | |
179 | |
180 } // namespace cc | |
181 | |
182 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_ | |
OLD | NEW |