OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_ | 5 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_ |
6 #define CC_TEST_ANIMATION_TEST_COMMON_H_ | 6 #define CC_TEST_ANIMATION_TEST_COMMON_H_ |
7 | 7 |
8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_curve.h" | 9 #include "cc/animation/animation_curve.h" |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
11 #include "cc/animation/layer_animation_value_observer.h" | 11 #include "cc/animation/layer_animation_value_observer.h" |
12 #include "cc/animation/layer_animation_value_provider.h" | 12 #include "cc/animation/layer_animation_value_provider.h" |
13 #include "cc/output/filter_operations.h" | 13 #include "cc/output/filter_operations.h" |
14 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class LayerImpl; | 17 class LayerImpl; |
18 class Layer; | 18 class Layer; |
19 } | 19 } |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 | 22 |
23 class FakeFloatAnimationCurve : public FloatAnimationCurve { | 23 class FakeFloatAnimationCurve : public FloatAnimationCurve { |
24 public: | 24 public: |
25 FakeFloatAnimationCurve(); | 25 FakeFloatAnimationCurve(); |
26 explicit FakeFloatAnimationCurve(double duration); | 26 explicit FakeFloatAnimationCurve(double duration); |
27 virtual ~FakeFloatAnimationCurve(); | 27 ~FakeFloatAnimationCurve() override; |
28 | 28 |
29 virtual double Duration() const override; | 29 double Duration() const override; |
30 virtual float GetValue(double now) const override; | 30 float GetValue(double now) const override; |
31 virtual scoped_ptr<AnimationCurve> Clone() const override; | 31 scoped_ptr<AnimationCurve> Clone() const override; |
32 | 32 |
33 private: | 33 private: |
34 double duration_; | 34 double duration_; |
35 }; | 35 }; |
36 | 36 |
37 class FakeTransformTransition : public TransformAnimationCurve { | 37 class FakeTransformTransition : public TransformAnimationCurve { |
38 public: | 38 public: |
39 explicit FakeTransformTransition(double duration); | 39 explicit FakeTransformTransition(double duration); |
40 virtual ~FakeTransformTransition(); | 40 ~FakeTransformTransition() override; |
41 | 41 |
42 virtual double Duration() const override; | 42 double Duration() const override; |
43 virtual gfx::Transform GetValue(double time) const override; | 43 gfx::Transform GetValue(double time) const override; |
44 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box, | 44 bool AnimatedBoundsForBox(const gfx::BoxF& box, |
45 gfx::BoxF* bounds) const override; | 45 gfx::BoxF* bounds) const override; |
46 virtual bool AffectsScale() const override; | 46 bool AffectsScale() const override; |
47 virtual bool IsTranslation() const override; | 47 bool IsTranslation() const override; |
48 virtual bool MaximumTargetScale(bool forward_direction, | 48 bool MaximumTargetScale(bool forward_direction, |
49 float* max_scale) const override; | 49 float* max_scale) const override; |
50 | 50 |
51 virtual scoped_ptr<AnimationCurve> Clone() const override; | 51 scoped_ptr<AnimationCurve> Clone() const override; |
52 | 52 |
53 private: | 53 private: |
54 double duration_; | 54 double duration_; |
55 }; | 55 }; |
56 | 56 |
57 class FakeFloatTransition : public FloatAnimationCurve { | 57 class FakeFloatTransition : public FloatAnimationCurve { |
58 public: | 58 public: |
59 FakeFloatTransition(double duration, float from, float to); | 59 FakeFloatTransition(double duration, float from, float to); |
60 virtual ~FakeFloatTransition(); | 60 ~FakeFloatTransition() override; |
61 | 61 |
62 virtual double Duration() const override; | 62 double Duration() const override; |
63 virtual float GetValue(double time) const override; | 63 float GetValue(double time) const override; |
64 | 64 |
65 virtual scoped_ptr<AnimationCurve> Clone() const override; | 65 scoped_ptr<AnimationCurve> Clone() const override; |
66 | 66 |
67 private: | 67 private: |
68 double duration_; | 68 double duration_; |
69 float from_; | 69 float from_; |
70 float to_; | 70 float to_; |
71 }; | 71 }; |
72 | 72 |
73 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver { | 73 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver { |
74 public: | 74 public: |
75 FakeLayerAnimationValueObserver(); | 75 FakeLayerAnimationValueObserver(); |
76 virtual ~FakeLayerAnimationValueObserver(); | 76 ~FakeLayerAnimationValueObserver() override; |
77 | 77 |
78 // LayerAnimationValueObserver implementation | 78 // LayerAnimationValueObserver implementation |
79 virtual void OnFilterAnimated(const FilterOperations& filters) override; | 79 void OnFilterAnimated(const FilterOperations& filters) override; |
80 virtual void OnOpacityAnimated(float opacity) override; | 80 void OnOpacityAnimated(float opacity) override; |
81 virtual void OnTransformAnimated(const gfx::Transform& transform) override; | 81 void OnTransformAnimated(const gfx::Transform& transform) override; |
82 virtual void OnScrollOffsetAnimated( | 82 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; |
83 const gfx::ScrollOffset& scroll_offset) override; | 83 void OnAnimationWaitingForDeletion() override; |
84 virtual void OnAnimationWaitingForDeletion() override; | 84 bool IsActive() const override; |
85 virtual bool IsActive() const override; | |
86 | 85 |
87 const FilterOperations& filters() const { return filters_; } | 86 const FilterOperations& filters() const { return filters_; } |
88 float opacity() const { return opacity_; } | 87 float opacity() const { return opacity_; } |
89 const gfx::Transform& transform() const { return transform_; } | 88 const gfx::Transform& transform() const { return transform_; } |
90 gfx::ScrollOffset scroll_offset() { return scroll_offset_; } | 89 gfx::ScrollOffset scroll_offset() { return scroll_offset_; } |
91 | 90 |
92 bool animation_waiting_for_deletion() { | 91 bool animation_waiting_for_deletion() { |
93 return animation_waiting_for_deletion_; | 92 return animation_waiting_for_deletion_; |
94 } | 93 } |
95 | 94 |
96 private: | 95 private: |
97 FilterOperations filters_; | 96 FilterOperations filters_; |
98 float opacity_; | 97 float opacity_; |
99 gfx::Transform transform_; | 98 gfx::Transform transform_; |
100 gfx::ScrollOffset scroll_offset_; | 99 gfx::ScrollOffset scroll_offset_; |
101 bool animation_waiting_for_deletion_; | 100 bool animation_waiting_for_deletion_; |
102 }; | 101 }; |
103 | 102 |
104 class FakeInactiveLayerAnimationValueObserver | 103 class FakeInactiveLayerAnimationValueObserver |
105 : public FakeLayerAnimationValueObserver { | 104 : public FakeLayerAnimationValueObserver { |
106 public: | 105 public: |
107 virtual bool IsActive() const override; | 106 bool IsActive() const override; |
108 }; | 107 }; |
109 | 108 |
110 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider { | 109 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider { |
111 public: | 110 public: |
112 virtual gfx::ScrollOffset ScrollOffsetForAnimation() const override; | 111 gfx::ScrollOffset ScrollOffsetForAnimation() const override; |
113 | 112 |
114 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { | 113 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { |
115 scroll_offset_ = scroll_offset; | 114 scroll_offset_ = scroll_offset; |
116 } | 115 } |
117 | 116 |
118 private: | 117 private: |
119 gfx::ScrollOffset scroll_offset_; | 118 gfx::ScrollOffset scroll_offset_; |
120 }; | 119 }; |
121 | 120 |
122 int AddOpacityTransitionToController(LayerAnimationController* controller, | 121 int AddOpacityTransitionToController(LayerAnimationController* controller, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 float end_brightness); | 172 float end_brightness); |
174 | 173 |
175 int AddAnimatedFilterToLayer(LayerImpl* layer, | 174 int AddAnimatedFilterToLayer(LayerImpl* layer, |
176 double duration, | 175 double duration, |
177 float start_brightness, | 176 float start_brightness, |
178 float end_brightness); | 177 float end_brightness); |
179 | 178 |
180 } // namespace cc | 179 } // namespace cc |
181 | 180 |
182 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_ | 181 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_ |
OLD | NEW |