OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TIMELINES_TEST_COMMON_H_ | 5 #ifndef CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
6 #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ | 6 #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 | 10 |
11 #include "cc/animation/animation.h" | 11 #include "cc/animation/animation.h" |
12 #include "cc/animation/animation_delegate.h" | 12 #include "cc/animation/animation_delegate.h" |
13 #include "cc/animation/animation_host.h" | 13 #include "cc/animation/animation_host.h" |
14 #include "cc/trees/mutator_host_client.h" | 14 #include "cc/trees/mutator_host_client.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/geometry/scroll_offset.h" | 16 #include "ui/gfx/geometry/scroll_offset.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
20 class TestLayer { | 20 class TestLayer { |
21 public: | 21 public: |
22 static std::unique_ptr<TestLayer> Create(); | 22 static std::unique_ptr<TestLayer> Create(); |
| 23 ~TestLayer(); |
23 | 24 |
24 void ClearMutatedProperties(); | 25 void ClearMutatedProperties(); |
25 | 26 |
26 int transform_x() const; | 27 int transform_x() const; |
27 int transform_y() const; | 28 int transform_y() const; |
28 float brightness() const; | 29 float brightness() const; |
29 | 30 |
30 const gfx::Transform& transform() const { return transform_; } | 31 const gfx::Transform& transform() const { return transform_; } |
31 void set_transform(const gfx::Transform& transform) { | 32 void set_transform(const gfx::Transform& transform) { |
32 transform_ = transform; | 33 transform_ = transform; |
(...skipping 11 matching lines...) Expand all Loading... |
44 filters_ = filters; | 45 filters_ = filters; |
45 mutated_properties_[TargetProperty::FILTER] = true; | 46 mutated_properties_[TargetProperty::FILTER] = true; |
46 } | 47 } |
47 | 48 |
48 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } | 49 gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } |
49 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { | 50 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) { |
50 scroll_offset_ = scroll_offset; | 51 scroll_offset_ = scroll_offset; |
51 mutated_properties_[TargetProperty::SCROLL_OFFSET] = true; | 52 mutated_properties_[TargetProperty::SCROLL_OFFSET] = true; |
52 } | 53 } |
53 | 54 |
54 bool transform_is_currently_animating() const { | 55 bool is_currently_animating(TargetProperty::Type property) const { |
55 return transform_is_currently_animating_; | 56 return is_currently_animating_[property]; |
56 } | 57 } |
57 void set_transform_is_currently_animating(bool is_animating) { | 58 void set_is_currently_animating(TargetProperty::Type property, |
58 transform_is_currently_animating_ = is_animating; | 59 bool is_animating) { |
| 60 is_currently_animating_[property] = is_animating; |
59 } | 61 } |
60 | 62 |
61 bool has_potential_transform_animation() const { | 63 bool has_potential_animation(TargetProperty::Type property) const { |
62 return has_potential_transform_animation_; | 64 return has_potential_animation_[property]; |
63 } | 65 } |
64 void set_has_potential_transform_animation(bool is_animating) { | 66 void set_has_potential_animation(TargetProperty::Type property, |
65 has_potential_transform_animation_ = is_animating; | 67 bool is_animating) { |
66 } | 68 has_potential_animation_[property] = is_animating; |
67 | |
68 bool opacity_is_currently_animating() const { | |
69 return opacity_is_currently_animating_; | |
70 } | |
71 void set_opacity_is_currently_animating(bool is_animating) { | |
72 opacity_is_currently_animating_ = is_animating; | |
73 } | |
74 | |
75 bool has_potential_opacity_animation() const { | |
76 return has_potential_opacity_animation_; | |
77 } | |
78 void set_has_potential_opacity_animation(bool is_animating) { | |
79 has_potential_opacity_animation_ = is_animating; | |
80 } | |
81 | |
82 bool filter_is_currently_animating() const { | |
83 return filter_is_currently_animating_; | |
84 } | |
85 void set_filter_is_currently_animating(bool is_animating) { | |
86 filter_is_currently_animating_ = is_animating; | |
87 } | |
88 | |
89 bool has_potential_filter_animation() const { | |
90 return has_potential_filter_animation_; | |
91 } | |
92 void set_has_potential_filter_animation(bool is_animating) { | |
93 has_potential_filter_animation_ = is_animating; | |
94 } | 69 } |
95 | 70 |
96 bool is_property_mutated(TargetProperty::Type property) const { | 71 bool is_property_mutated(TargetProperty::Type property) const { |
97 return mutated_properties_[property]; | 72 return mutated_properties_[property]; |
98 } | 73 } |
99 | 74 |
100 private: | 75 private: |
101 TestLayer(); | 76 TestLayer(); |
102 | 77 |
103 gfx::Transform transform_; | 78 gfx::Transform transform_; |
104 float opacity_; | 79 float opacity_; |
105 FilterOperations filters_; | 80 FilterOperations filters_; |
106 gfx::ScrollOffset scroll_offset_; | 81 gfx::ScrollOffset scroll_offset_; |
107 bool has_potential_transform_animation_; | |
108 bool transform_is_currently_animating_; | |
109 bool has_potential_opacity_animation_; | |
110 bool opacity_is_currently_animating_; | |
111 bool has_potential_filter_animation_; | |
112 bool filter_is_currently_animating_; | |
113 | 82 |
114 bool mutated_properties_[TargetProperty::LAST_TARGET_PROPERTY + 1]; | 83 TargetProperties has_potential_animation_; |
| 84 TargetProperties is_currently_animating_; |
| 85 TargetProperties mutated_properties_; |
115 }; | 86 }; |
116 | 87 |
117 class TestHostClient : public MutatorHostClient { | 88 class TestHostClient : public MutatorHostClient { |
118 public: | 89 public: |
119 explicit TestHostClient(ThreadInstance thread_instance); | 90 explicit TestHostClient(ThreadInstance thread_instance); |
120 ~TestHostClient(); | 91 ~TestHostClient(); |
121 | 92 |
122 void ClearMutatedProperties(); | 93 void ClearMutatedProperties(); |
123 | 94 |
124 bool IsElementInList(ElementId element_id, | 95 bool IsElementInList(ElementId element_id, |
(...skipping 12 matching lines...) Expand all Loading... |
137 | 108 |
138 void SetElementTransformMutated(ElementId element_id, | 109 void SetElementTransformMutated(ElementId element_id, |
139 ElementListType list_type, | 110 ElementListType list_type, |
140 const gfx::Transform& transform) override; | 111 const gfx::Transform& transform) override; |
141 | 112 |
142 void SetElementScrollOffsetMutated( | 113 void SetElementScrollOffsetMutated( |
143 ElementId element_id, | 114 ElementId element_id, |
144 ElementListType list_type, | 115 ElementListType list_type, |
145 const gfx::ScrollOffset& scroll_offset) override; | 116 const gfx::ScrollOffset& scroll_offset) override; |
146 | 117 |
147 void ElementTransformIsAnimatingChanged(ElementId element_id, | 118 void ElementIsAnimatingChanged(ElementId element_id, |
148 ElementListType list_type, | 119 ElementListType list_type, |
149 AnimationChangeType change_type, | 120 const PropertyAnimationState& mask, |
150 bool is_animating) override; | 121 const PropertyAnimationState& state) override; |
151 | |
152 void ElementOpacityIsAnimatingChanged(ElementId element_id, | |
153 ElementListType list_type, | |
154 AnimationChangeType change_type, | |
155 bool is_animating) override; | |
156 | |
157 void ElementFilterIsAnimatingChanged(ElementId element_id, | |
158 ElementListType list_type, | |
159 AnimationChangeType change_type, | |
160 bool is_animating) override; | |
161 | 122 |
162 void ScrollOffsetAnimationFinished() override {} | 123 void ScrollOffsetAnimationFinished() override {} |
163 | 124 |
164 void SetScrollOffsetForAnimation(const gfx::ScrollOffset& scroll_offset); | 125 void SetScrollOffsetForAnimation(const gfx::ScrollOffset& scroll_offset); |
165 gfx::ScrollOffset GetScrollOffsetForAnimation( | 126 gfx::ScrollOffset GetScrollOffsetForAnimation( |
166 ElementId element_id) const override; | 127 ElementId element_id) const override; |
167 | 128 |
168 bool mutators_need_commit() const { return mutators_need_commit_; } | 129 bool mutators_need_commit() const { return mutators_need_commit_; } |
169 void set_mutators_need_commit(bool need) { mutators_need_commit_ = need; } | 130 void set_mutators_need_commit(bool need) { mutators_need_commit_ = need; } |
170 | 131 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 scoped_refptr<AnimationTimeline> timeline_; | 274 scoped_refptr<AnimationTimeline> timeline_; |
314 scoped_refptr<AnimationPlayer> player_; | 275 scoped_refptr<AnimationPlayer> player_; |
315 | 276 |
316 scoped_refptr<AnimationTimeline> timeline_impl_; | 277 scoped_refptr<AnimationTimeline> timeline_impl_; |
317 scoped_refptr<AnimationPlayer> player_impl_; | 278 scoped_refptr<AnimationPlayer> player_impl_; |
318 }; | 279 }; |
319 | 280 |
320 } // namespace cc | 281 } // namespace cc |
321 | 282 |
322 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ | 283 #endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ |
OLD | NEW |