Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: cc/test/animation_test_common.h

Issue 1904653002: CC Animation: Merge LayerAnimationController into ElementAnimations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor optimization: Don't init value observations if same host. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/animation_timeline.h" 10 #include "cc/animation/animation_timeline.h"
11 #include "cc/animation/layer_animation_controller.h"
12 #include "cc/animation/layer_animation_value_observer.h"
13 #include "cc/animation/layer_animation_value_provider.h"
14 #include "cc/animation/transform_operations.h" 11 #include "cc/animation/transform_operations.h"
15 #include "cc/output/filter_operations.h" 12 #include "cc/output/filter_operations.h"
16 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
17 14
18 namespace cc { 15 namespace cc {
19 class AnimationPlayer; 16 class AnimationPlayer;
17 class ElementAnimations;
20 class LayerImpl; 18 class LayerImpl;
21 class Layer; 19 class Layer;
22 } 20 }
23 21
24 namespace cc { 22 namespace cc {
25 23
26 class FakeFloatAnimationCurve : public FloatAnimationCurve { 24 class FakeFloatAnimationCurve : public FloatAnimationCurve {
27 public: 25 public:
28 FakeFloatAnimationCurve(); 26 FakeFloatAnimationCurve();
29 explicit FakeFloatAnimationCurve(double duration); 27 explicit FakeFloatAnimationCurve(double duration);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 float GetValue(base::TimeDelta time) const override; 67 float GetValue(base::TimeDelta time) const override;
70 68
71 std::unique_ptr<AnimationCurve> Clone() const override; 69 std::unique_ptr<AnimationCurve> Clone() const override;
72 70
73 private: 71 private:
74 base::TimeDelta duration_; 72 base::TimeDelta duration_;
75 float from_; 73 float from_;
76 float to_; 74 float to_;
77 }; 75 };
78 76
79 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver { 77 int AddOpacityTransitionToElementAnimations(ElementAnimations* target,
80 public: 78 double duration,
81 FakeLayerAnimationValueObserver(); 79 float start_opacity,
82 ~FakeLayerAnimationValueObserver() override; 80 float end_opacity,
81 bool use_timing_function);
83 82
84 // LayerAnimationValueObserver implementation. 83 int AddAnimatedTransformToElementAnimations(ElementAnimations* target,
85 void OnFilterAnimated(LayerTreeType tree_type, 84 double duration,
86 const FilterOperations& filters) override; 85 int delta_x,
87 void OnOpacityAnimated(LayerTreeType tree_type, float opacity) override; 86 int delta_y);
88 void OnTransformAnimated(LayerTreeType tree_type,
89 const gfx::Transform& transform) override;
90 void OnScrollOffsetAnimated(LayerTreeType tree_type,
91 const gfx::ScrollOffset& scroll_offset) override;
92 void OnAnimationWaitingForDeletion() override;
93 void OnTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type,
94 bool is_animating) override;
95 87
96 const FilterOperations& filters(LayerTreeType tree_type) const { 88 int AddAnimatedFilterToElementAnimations(ElementAnimations* target,
97 return filters_[ToIndex(tree_type)]; 89 double duration,
98 } 90 float start_brightness,
99 float opacity(LayerTreeType tree_type) const { 91 float end_brightness);
100 return opacity_[ToIndex(tree_type)];
101 }
102 const gfx::Transform& transform(LayerTreeType tree_type) const {
103 return transform_[ToIndex(tree_type)];
104 }
105 gfx::ScrollOffset scroll_offset(LayerTreeType tree_type) {
106 return scroll_offset_[ToIndex(tree_type)];
107 }
108
109 bool animation_waiting_for_deletion() {
110 return animation_waiting_for_deletion_;
111 }
112
113 bool transform_is_animating(LayerTreeType tree_type) {
114 return transform_is_animating_[ToIndex(tree_type)];
115 }
116
117 private:
118 static int ToIndex(LayerTreeType tree_type);
119
120 FilterOperations filters_[2];
121 float opacity_[2];
122 gfx::Transform transform_[2];
123 gfx::ScrollOffset scroll_offset_[2];
124 bool animation_waiting_for_deletion_;
125 bool transform_is_animating_[2];
126 };
127
128 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider {
129 public:
130 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
131
132 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) {
133 scroll_offset_ = scroll_offset;
134 }
135
136 private:
137 gfx::ScrollOffset scroll_offset_;
138 };
139
140 int AddOpacityTransitionToController(LayerAnimationController* controller,
141 double duration,
142 float start_opacity,
143 float end_opacity,
144 bool use_timing_function);
145
146 int AddAnimatedTransformToController(LayerAnimationController* controller,
147 double duration,
148 int delta_x,
149 int delta_y);
150
151 int AddAnimatedFilterToController(LayerAnimationController* controller,
152 double duration,
153 float start_brightness,
154 float end_brightness);
155 92
156 int AddAnimatedTransformToPlayer(AnimationPlayer* player, 93 int AddAnimatedTransformToPlayer(AnimationPlayer* player,
157 double duration, 94 double duration,
158 int delta_x, 95 int delta_x,
159 int delta_y); 96 int delta_y);
160 97
161 int AddAnimatedTransformToPlayer(AnimationPlayer* player, 98 int AddAnimatedTransformToPlayer(AnimationPlayer* player,
162 double duration, 99 double duration,
163 TransformOperations start_operations, 100 TransformOperations start_operations,
164 TransformOperations operations); 101 TransformOperations operations);
165 102
166 int AddOpacityTransitionToPlayer(AnimationPlayer* player, 103 int AddOpacityTransitionToPlayer(AnimationPlayer* player,
167 double duration, 104 double duration,
168 float start_opacity, 105 float start_opacity,
169 float end_opacity, 106 float end_opacity,
170 bool use_timing_function); 107 bool use_timing_function);
171 108
172 int AddAnimatedFilterToPlayer(AnimationPlayer* player, 109 int AddAnimatedFilterToPlayer(AnimationPlayer* player,
173 double duration, 110 double duration,
174 float start_brightness, 111 float start_brightness,
175 float end_brightness); 112 float end_brightness);
176 113
177 int AddOpacityStepsToController(LayerAnimationController* target, 114 int AddOpacityStepsToElementAnimations(ElementAnimations* target,
178 double duration, 115 double duration,
179 float start_opacity, 116 float start_opacity,
180 float end_opacity, 117 float end_opacity,
181 int num_steps); 118 int num_steps);
182 119
183 void AddAnimationToLayerWithPlayer(int layer_id, 120 void AddAnimationToLayerWithPlayer(int layer_id,
184 scoped_refptr<AnimationTimeline> timeline, 121 scoped_refptr<AnimationTimeline> timeline,
185 std::unique_ptr<Animation> animation); 122 std::unique_ptr<Animation> animation);
186 void AddAnimationToLayerWithExistingPlayer( 123 void AddAnimationToLayerWithExistingPlayer(
187 int layer_id, 124 int layer_id,
188 scoped_refptr<AnimationTimeline> timeline, 125 scoped_refptr<AnimationTimeline> timeline,
189 std::unique_ptr<Animation> animation); 126 std::unique_ptr<Animation> animation);
190 127
191 void RemoveAnimationFromLayerWithExistingPlayer( 128 void RemoveAnimationFromLayerWithExistingPlayer(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 float end_opacity, 164 float end_opacity,
228 bool use_timing_function); 165 bool use_timing_function);
229 166
230 void AbortAnimationsOnLayerWithPlayer(int layer_id, 167 void AbortAnimationsOnLayerWithPlayer(int layer_id,
231 scoped_refptr<AnimationTimeline> timeline, 168 scoped_refptr<AnimationTimeline> timeline,
232 TargetProperty::Type target_property); 169 TargetProperty::Type target_property);
233 170
234 } // namespace cc 171 } // namespace cc
235 172
236 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_ 173 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698