Update V8 to version 4.7.21.
[chromium-blink-merge.git] / cc / test / animation_test_common.h
blob29d66b77830385f8f76c9e4f90eca11cae4d11c9
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.
5 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_
6 #define CC_TEST_ANIMATION_TEST_COMMON_H_
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"
16 namespace cc {
17 class AnimationPlayer;
18 class LayerImpl;
19 class Layer;
22 namespace cc {
24 class FakeFloatAnimationCurve : public FloatAnimationCurve {
25 public:
26 FakeFloatAnimationCurve();
27 explicit FakeFloatAnimationCurve(double duration);
28 ~FakeFloatAnimationCurve() override;
30 base::TimeDelta Duration() const override;
31 float GetValue(base::TimeDelta now) const override;
32 scoped_ptr<AnimationCurve> Clone() const override;
34 private:
35 base::TimeDelta duration_;
38 class FakeTransformTransition : public TransformAnimationCurve {
39 public:
40 explicit FakeTransformTransition(double duration);
41 ~FakeTransformTransition() override;
43 base::TimeDelta Duration() const override;
44 gfx::Transform GetValue(base::TimeDelta time) const override;
45 bool AnimatedBoundsForBox(const gfx::BoxF& box,
46 gfx::BoxF* bounds) const override;
47 bool AffectsScale() const override;
48 bool IsTranslation() const override;
49 bool PreservesAxisAlignment() const override;
50 bool AnimationStartScale(bool forward_direction,
51 float* start_scale) const override;
52 bool MaximumTargetScale(bool forward_direction,
53 float* max_scale) const override;
55 scoped_ptr<AnimationCurve> Clone() const override;
57 private:
58 base::TimeDelta duration_;
61 class FakeFloatTransition : public FloatAnimationCurve {
62 public:
63 FakeFloatTransition(double duration, float from, float to);
64 ~FakeFloatTransition() override;
66 base::TimeDelta Duration() const override;
67 float GetValue(base::TimeDelta time) const override;
69 scoped_ptr<AnimationCurve> Clone() const override;
71 private:
72 base::TimeDelta duration_;
73 float from_;
74 float to_;
77 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver {
78 public:
79 FakeLayerAnimationValueObserver();
80 ~FakeLayerAnimationValueObserver() override;
82 // LayerAnimationValueObserver implementation
83 void OnFilterAnimated(const FilterOperations& filters) override;
84 void OnOpacityAnimated(float opacity) override;
85 void OnTransformAnimated(const gfx::Transform& transform) override;
86 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
87 void OnAnimationWaitingForDeletion() override;
88 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override;
89 bool IsActive() const override;
91 const FilterOperations& filters() const { return filters_; }
92 float opacity() const { return opacity_; }
93 const gfx::Transform& transform() const { return transform_; }
94 gfx::ScrollOffset scroll_offset() { return scroll_offset_; }
96 bool animation_waiting_for_deletion() {
97 return animation_waiting_for_deletion_;
100 bool transform_is_animating() { return transform_is_animating_; }
102 private:
103 FilterOperations filters_;
104 float opacity_;
105 gfx::Transform transform_;
106 gfx::ScrollOffset scroll_offset_;
107 bool animation_waiting_for_deletion_;
108 bool transform_is_animating_;
111 class FakeInactiveLayerAnimationValueObserver
112 : public FakeLayerAnimationValueObserver {
113 public:
114 bool IsActive() const override;
117 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider {
118 public:
119 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
121 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) {
122 scroll_offset_ = scroll_offset;
125 private:
126 gfx::ScrollOffset scroll_offset_;
129 int AddOpacityTransitionToController(LayerAnimationController* controller,
130 double duration,
131 float start_opacity,
132 float end_opacity,
133 bool use_timing_function);
135 int AddAnimatedTransformToController(LayerAnimationController* controller,
136 double duration,
137 int delta_x,
138 int delta_y);
140 int AddAnimatedFilterToController(LayerAnimationController* controller,
141 double duration,
142 float start_brightness,
143 float end_brightness);
145 int AddOpacityTransitionToLayer(Layer* layer,
146 double duration,
147 float start_opacity,
148 float end_opacity,
149 bool use_timing_function);
151 int AddOpacityTransitionToLayer(LayerImpl* layer,
152 double duration,
153 float start_opacity,
154 float end_opacity,
155 bool use_timing_function);
157 int AddAnimatedTransformToLayer(Layer* layer,
158 double duration,
159 int delta_x,
160 int delta_y);
162 int AddAnimatedTransformToLayer(LayerImpl* layer,
163 double duration,
164 int delta_x,
165 int delta_y);
167 int AddAnimatedTransformToLayer(Layer* layer,
168 double duration,
169 TransformOperations start_operations,
170 TransformOperations operations);
172 int AddAnimatedTransformToLayer(LayerImpl* layer,
173 double duration,
174 TransformOperations start_operations,
175 TransformOperations operations);
177 int AddAnimatedFilterToLayer(Layer* layer,
178 double duration,
179 float start_brightness,
180 float end_brightness);
182 int AddAnimatedFilterToLayer(LayerImpl* layer,
183 double duration,
184 float start_brightness,
185 float end_brightness);
187 int AddAnimatedTransformToPlayer(AnimationPlayer* player,
188 double duration,
189 int delta_x,
190 int delta_y);
192 int AddOpacityTransitionToPlayer(AnimationPlayer* player,
193 double duration,
194 float start_opacity,
195 float end_opacity,
196 bool use_timing_function);
198 int AddAnimatedFilterToPlayer(AnimationPlayer* player,
199 double duration,
200 float start_brightness,
201 float end_brightness);
203 int AddOpacityStepsToController(LayerAnimationController* target,
204 double duration,
205 float start_opacity,
206 float end_opacity,
207 int num_steps);
209 } // namespace cc
211 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_