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

Side by Side Diff: cc/layers/layer_utils_unittest.cc

Issue 1944623002: CC Animation: Use ElementId to attach CC animation players. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasedomids
Patch Set: Let CC clients generate their own ElementIds locally. Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "cc/layers/layer_utils.h" 5 #include "cc/layers/layer_utils.h"
6 6
7 #include "cc/animation/animation_host.h" 7 #include "cc/animation/animation_host.h"
8 #include "cc/animation/animation_id_provider.h" 8 #include "cc/animation/animation_id_provider.h"
9 #include "cc/animation/transform_operations.h" 9 #include "cc/animation/transform_operations.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 LayerImpl* parent1() { return parent1_; } 47 LayerImpl* parent1() { return parent1_; }
48 LayerImpl* child1() { return child1_; } 48 LayerImpl* child1() { return child1_; }
49 LayerImpl* parent2() { return parent2_; } 49 LayerImpl* parent2() { return parent2_; }
50 LayerImpl* child2() { return child2_; } 50 LayerImpl* child2() { return child2_; }
51 LayerImpl* grand_child() { return grand_child_; } 51 LayerImpl* grand_child() { return grand_child_; }
52 LayerImpl* great_grand_child() { return great_grand_child_; } 52 LayerImpl* great_grand_child() { return great_grand_child_; }
53 53
54 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } 54 scoped_refptr<AnimationTimeline> timeline() { return timeline_; }
55 FakeLayerTreeHostImpl& host_impl() { return host_impl_; } 55 FakeLayerTreeHostImpl& host_impl() { return host_impl_; }
56 56
57 std::unique_ptr<LayerImpl> CreateTestLayerImpl(LayerTreeImpl* tree_impl,
58 int id) {
59 auto layer = LayerImpl::Create(tree_impl, id);
60 layer->SetElementId(NextTestElementId());
61 return layer;
62 }
63
57 private: 64 private:
58 static LayerImpl* CreateTwoForkTree(LayerTreeHostImpl* host_impl) { 65 LayerImpl* CreateTwoForkTree(LayerTreeHostImpl* host_impl) {
59 std::unique_ptr<LayerImpl> root = 66 std::unique_ptr<LayerImpl> root =
60 LayerImpl::Create(host_impl->active_tree(), 1); 67 CreateTestLayerImpl(host_impl->active_tree(), 1);
61 LayerImpl* root_ptr = root.get(); 68 LayerImpl* root_ptr = root.get();
62 root->AddChild(LayerImpl::Create(host_impl->active_tree(), 2)); 69 root->AddChild(CreateTestLayerImpl(host_impl->active_tree(), 2));
63 root->children()[0]->AddChild( 70 root->children()[0]->AddChild(
64 LayerImpl::Create(host_impl->active_tree(), 3)); 71 CreateTestLayerImpl(host_impl->active_tree(), 3));
65 root->AddChild(LayerImpl::Create(host_impl->active_tree(), 4)); 72 root->AddChild(CreateTestLayerImpl(host_impl->active_tree(), 4));
66 root->children()[1]->AddChild( 73 root->children()[1]->AddChild(
67 LayerImpl::Create(host_impl->active_tree(), 5)); 74 CreateTestLayerImpl(host_impl->active_tree(), 5));
68 root->children()[1]->children()[0]->AddChild( 75 root->children()[1]->children()[0]->AddChild(
69 LayerImpl::Create(host_impl->active_tree(), 6)); 76 CreateTestLayerImpl(host_impl->active_tree(), 6));
70 root->children()[1]->children()[0]->children()[0]->AddChild( 77 root->children()[1]->children()[0]->children()[0]->AddChild(
71 LayerImpl::Create(host_impl->active_tree(), 7)); 78 CreateTestLayerImpl(host_impl->active_tree(), 7));
72 host_impl->active_tree()->SetRootLayer(std::move(root)); 79 host_impl->active_tree()->SetRootLayer(std::move(root));
73 return root_ptr; 80 return root_ptr;
74 } 81 }
75 82
76 FakeImplTaskRunnerProvider task_runner_provider_; 83 FakeImplTaskRunnerProvider task_runner_provider_;
77 TestSharedBitmapManager shared_bitmap_manager_; 84 TestSharedBitmapManager shared_bitmap_manager_;
78 TestTaskGraphRunner task_graph_runner_; 85 TestTaskGraphRunner task_graph_runner_;
79 FakeLayerTreeHostImpl host_impl_; 86 FakeLayerTreeHostImpl host_impl_;
80 LayerImpl* root_; 87 LayerImpl* root_;
81 LayerImpl* parent1_; 88 LayerImpl* parent1_;
82 LayerImpl* parent2_; 89 LayerImpl* parent2_;
83 LayerImpl* child1_; 90 LayerImpl* child1_;
84 LayerImpl* child2_; 91 LayerImpl* child2_;
85 LayerImpl* grand_child_; 92 LayerImpl* grand_child_;
86 LayerImpl* great_grand_child_; 93 LayerImpl* great_grand_child_;
87 scoped_refptr<AnimationTimeline> timeline_; 94 scoped_refptr<AnimationTimeline> timeline_;
88 }; 95 };
89 96
90 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { 97 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) {
91 double duration = 1.0; 98 double duration = 1.0;
92 99
93 TransformOperations start; 100 TransformOperations start;
94 start.AppendScale(1.f, 1.f, 1.f); 101 start.AppendScale(1.f, 1.f, 1.f);
95 TransformOperations end; 102 TransformOperations end;
96 end.AppendScale(2.f, 2.f, 1.f); 103 end.AppendScale(2.f, 2.f, 1.f);
97 AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, 104 AddAnimatedTransformToElementWithPlayer(root()->element_id(), timeline(),
98 start, end); 105 duration, start, end);
99 106
100 root()->SetPosition(gfx::PointF()); 107 root()->SetPosition(gfx::PointF());
101 parent1()->SetPosition(gfx::PointF()); 108 parent1()->SetPosition(gfx::PointF());
102 parent1()->SetBounds(gfx::Size(350, 200)); 109 parent1()->SetBounds(gfx::Size(350, 200));
103 110
104 child1()->SetDrawsContent(true); 111 child1()->SetDrawsContent(true);
105 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 112 child1()->SetPosition(gfx::PointF(150.f, 50.f));
106 child1()->SetBounds(gfx::Size(100, 200)); 113 child1()->SetBounds(gfx::Size(100, 200));
107 114
108 host_impl().active_tree()->BuildPropertyTreesForTesting(); 115 host_impl().active_tree()->BuildPropertyTreesForTesting();
109 116
110 gfx::BoxF box; 117 gfx::BoxF box;
111 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 118 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
112 EXPECT_TRUE(success); 119 EXPECT_TRUE(success);
113 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f); 120 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f);
114 EXPECT_BOXF_EQ(expected, box); 121 EXPECT_BOXF_EQ(expected, box);
115 } 122 }
116 123
117 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { 124 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) {
118 double duration = 1.0; 125 double duration = 1.0;
119 126
120 TransformOperations start; 127 TransformOperations start;
121 start.AppendTranslate(0.f, 0.f, 0.f); 128 start.AppendTranslate(0.f, 0.f, 0.f);
122 TransformOperations end; 129 TransformOperations end;
123 end.AppendTranslate(50.f, 50.f, 0.f); 130 end.AppendTranslate(50.f, 50.f, 0.f);
124 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 131 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
125 start, end); 132 duration, start, end);
126 133
127 parent1()->SetBounds(gfx::Size(350, 200)); 134 parent1()->SetBounds(gfx::Size(350, 200));
128 135
129 child1()->SetDrawsContent(true); 136 child1()->SetDrawsContent(true);
130 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 137 child1()->SetPosition(gfx::PointF(150.f, 50.f));
131 child1()->SetBounds(gfx::Size(100, 200)); 138 child1()->SetBounds(gfx::Size(100, 200));
132 139
133 host_impl().active_tree()->BuildPropertyTreesForTesting(); 140 host_impl().active_tree()->BuildPropertyTreesForTesting();
134 141
135 gfx::BoxF box; 142 gfx::BoxF box;
136 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 143 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
137 EXPECT_TRUE(success); 144 EXPECT_TRUE(success);
138 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 145 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
139 EXPECT_BOXF_EQ(expected, box); 146 EXPECT_BOXF_EQ(expected, box);
140 } 147 }
141 148
142 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { 149 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) {
143 double duration = 1.0; 150 double duration = 1.0;
144 151
145 TransformOperations start; 152 TransformOperations start;
146 start.AppendTranslate(0.f, 0.f, 0.f); 153 start.AppendTranslate(0.f, 0.f, 0.f);
147 TransformOperations end; 154 TransformOperations end;
148 end.AppendTranslate(50.f, 50.f, 0.f); 155 end.AppendTranslate(50.f, 50.f, 0.f);
149 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 156 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
150 start, end); 157 duration, start, end);
151 parent1()->SetBounds(gfx::Size(350, 200)); 158 parent1()->SetBounds(gfx::Size(350, 200));
152 159
153 child1()->SetDrawsContent(true); 160 child1()->SetDrawsContent(true);
154 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 161 child1()->SetPosition(gfx::PointF(150.f, 50.f));
155 child1()->SetBounds(gfx::Size(100, 200)); 162 child1()->SetBounds(gfx::Size(100, 200));
156 163
157 host_impl().active_tree()->BuildPropertyTreesForTesting(); 164 host_impl().active_tree()->BuildPropertyTreesForTesting();
158 165
159 gfx::BoxF box; 166 gfx::BoxF box;
160 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 167 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
161 EXPECT_TRUE(success); 168 EXPECT_TRUE(success);
162 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 169 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
163 EXPECT_BOXF_EQ(expected, box); 170 EXPECT_BOXF_EQ(expected, box);
164 } 171 }
165 172
166 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { 173 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) {
167 double duration = 1.0; 174 double duration = 1.0;
168 175
169 TransformOperations start; 176 TransformOperations start;
170 start.AppendTranslate(0.f, 0.f, 0.f); 177 start.AppendTranslate(0.f, 0.f, 0.f);
171 TransformOperations child_end; 178 TransformOperations child_end;
172 child_end.AppendTranslate(50.f, 0.f, 0.f); 179 child_end.AppendTranslate(50.f, 0.f, 0.f);
173 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 180 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
174 start, child_end); 181 duration, start, child_end);
175 182
176 TransformOperations grand_child_end; 183 TransformOperations grand_child_end;
177 grand_child_end.AppendTranslate(0.f, 50.f, 0.f); 184 grand_child_end.AppendTranslate(0.f, 50.f, 0.f);
178 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 185 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
179 start, grand_child_end); 186 duration, start, grand_child_end);
180 187
181 parent1()->SetBounds(gfx::Size(350, 200)); 188 parent1()->SetBounds(gfx::Size(350, 200));
182 189
183 child1()->SetDrawsContent(true); 190 child1()->SetDrawsContent(true);
184 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 191 child1()->SetPosition(gfx::PointF(150.f, 50.f));
185 child1()->SetBounds(gfx::Size(100, 200)); 192 child1()->SetBounds(gfx::Size(100, 200));
186 193
187 host_impl().active_tree()->BuildPropertyTreesForTesting(); 194 host_impl().active_tree()->BuildPropertyTreesForTesting();
188 195
189 gfx::BoxF box; 196 gfx::BoxF box;
190 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 197 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
191 EXPECT_TRUE(success); 198 EXPECT_TRUE(success);
192 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 199 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
193 EXPECT_BOXF_EQ(expected, box); 200 EXPECT_BOXF_EQ(expected, box);
194 } 201 }
195 202
196 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { 203 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) {
197 double duration = 1.0; 204 double duration = 1.0;
198 205
199 TransformOperations start; 206 TransformOperations start;
200 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 207 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
201 TransformOperations end; 208 TransformOperations end;
202 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 209 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
203 210
204 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 211 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
205 start, end); 212 duration, start, end);
206 213
207 parent1()->SetBounds(gfx::Size(350, 200)); 214 parent1()->SetBounds(gfx::Size(350, 200));
208 215
209 gfx::Size bounds(100, 100); 216 gfx::Size bounds(100, 100);
210 child1()->SetDrawsContent(true); 217 child1()->SetDrawsContent(true);
211 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 218 child1()->SetPosition(gfx::PointF(150.f, 50.f));
212 child1()->SetBounds(bounds); 219 child1()->SetBounds(bounds);
213 child1()->test_properties()->transform_origin = 220 child1()->test_properties()->transform_origin =
214 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); 221 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0);
215 222
216 host_impl().active_tree()->BuildPropertyTreesForTesting(); 223 host_impl().active_tree()->BuildPropertyTreesForTesting();
217 224
218 gfx::BoxF box; 225 gfx::BoxF box;
219 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 226 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
220 EXPECT_TRUE(success); 227 EXPECT_TRUE(success);
221 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f); 228 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f);
222 EXPECT_BOXF_EQ(expected, box); 229 EXPECT_BOXF_EQ(expected, box);
223 } 230 }
224 231
225 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { 232 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) {
226 double duration = 1.0; 233 double duration = 1.0;
227 234
228 TransformOperations start; 235 TransformOperations start;
229 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 236 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
230 TransformOperations end; 237 TransformOperations end;
231 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 238 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
232 239
233 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 240 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
234 start, end); 241 duration, start, end);
235 242
236 // Make the anchor point not the default 0.5 value and line up with the 243 // Make the anchor point not the default 0.5 value and line up with the
237 // child center to make the math easier. 244 // child center to make the math easier.
238 parent1()->test_properties()->transform_origin = 245 parent1()->test_properties()->transform_origin =
239 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); 246 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f);
240 parent1()->SetBounds(gfx::Size(400, 400)); 247 parent1()->SetBounds(gfx::Size(400, 400));
241 248
242 gfx::Transform perspective; 249 gfx::Transform perspective;
243 perspective.ApplyPerspectiveDepth(100.f); 250 perspective.ApplyPerspectiveDepth(100.f);
244 parent1()->SetTransform(perspective); 251 parent1()->SetTransform(perspective);
(...skipping 19 matching lines...) Expand all
264 // local transform when there is an animation applied to the layer / node. 271 // local transform when there is an animation applied to the layer / node.
265 // The intended behavior is that the animation should overwrite the transform. 272 // The intended behavior is that the animation should overwrite the transform.
266 273
267 double duration = 1.0; 274 double duration = 1.0;
268 275
269 TransformOperations start; 276 TransformOperations start;
270 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 277 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
271 TransformOperations end; 278 TransformOperations end;
272 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 279 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
273 280
274 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 281 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
275 start, end); 282 duration, start, end);
276 283
277 // Make the anchor point not the default 0.5 value and line up 284 // Make the anchor point not the default 0.5 value and line up
278 // with the child center to make the math easier. 285 // with the child center to make the math easier.
279 parent1()->test_properties()->transform_origin = 286 parent1()->test_properties()->transform_origin =
280 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); 287 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f);
281 parent1()->SetBounds(gfx::Size(400, 400)); 288 parent1()->SetBounds(gfx::Size(400, 400));
282 289
283 gfx::Transform perspective; 290 gfx::Transform perspective;
284 perspective.ApplyPerspectiveDepth(100.f); 291 perspective.ApplyPerspectiveDepth(100.f);
285 parent1()->SetTransform(perspective); 292 parent1()->SetTransform(perspective);
(...skipping 14 matching lines...) Expand all
300 EXPECT_BOXF_EQ(expected, box); 307 EXPECT_BOXF_EQ(expected, box);
301 } 308 }
302 309
303 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { 310 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) {
304 double duration = 1.0; 311 double duration = 1.0;
305 312
306 TransformOperations start; 313 TransformOperations start;
307 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 314 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
308 TransformOperations end; 315 TransformOperations end;
309 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 316 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
310 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 317 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
311 start, end); 318 duration, start, end);
312 319
313 parent1()->SetBounds(gfx::Size(350, 200)); 320 parent1()->SetBounds(gfx::Size(350, 200));
314 321
315 gfx::Size bounds(100, 100); 322 gfx::Size bounds(100, 100);
316 child1()->SetDrawsContent(true); 323 child1()->SetDrawsContent(true);
317 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 324 child1()->SetPosition(gfx::PointF(150.f, 50.f));
318 child1()->SetBounds(bounds); 325 child1()->SetBounds(bounds);
319 child1()->test_properties()->transform_origin = 326 child1()->test_properties()->transform_origin =
320 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); 327 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0);
321 328
(...skipping 12 matching lines...) Expand all
334 EXPECT_BOXF_EQ(expected, box); 341 EXPECT_BOXF_EQ(expected, box);
335 } 342 }
336 343
337 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { 344 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) {
338 double duration = 1.0; 345 double duration = 1.0;
339 346
340 TransformOperations start; 347 TransformOperations start;
341 start.AppendTranslate(5, 6, 7); 348 start.AppendTranslate(5, 6, 7);
342 TransformOperations end; 349 TransformOperations end;
343 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 350 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
344 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 351 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
345 start, end); 352 duration, start, end);
346 353
347 parent1()->SetBounds(gfx::Size(350, 200)); 354 parent1()->SetBounds(gfx::Size(350, 200));
348 355
349 gfx::Size bounds(100, 100); 356 gfx::Size bounds(100, 100);
350 child1()->SetDrawsContent(true); 357 child1()->SetDrawsContent(true);
351 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 358 child1()->SetPosition(gfx::PointF(150.f, 50.f));
352 child1()->SetBounds(bounds); 359 child1()->SetBounds(bounds);
353 360
354 host_impl().active_tree()->BuildPropertyTreesForTesting(); 361 host_impl().active_tree()->BuildPropertyTreesForTesting();
355 362
(...skipping 13 matching lines...) Expand all
369 // This test is used to check if GetAnimationBounds correctly skips layers and 376 // This test is used to check if GetAnimationBounds correctly skips layers and
370 // take layers which do not own a transform_node into consideration. 377 // take layers which do not own a transform_node into consideration.
371 // Under this topology, only root and grand_child own transform_nodes. 378 // Under this topology, only root and grand_child own transform_nodes.
372 379
373 double duration = 1.0; 380 double duration = 1.0;
374 381
375 TransformOperations start; 382 TransformOperations start;
376 start.AppendTranslate(0.f, 0.f, 0.f); 383 start.AppendTranslate(0.f, 0.f, 0.f);
377 TransformOperations great_grand_child_end; 384 TransformOperations great_grand_child_end;
378 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); 385 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f);
379 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 386 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(),
380 duration, start, great_grand_child_end); 387 timeline(), duration, start,
388 great_grand_child_end);
381 389
382 gfx::Transform translate_2d_transform; 390 gfx::Transform translate_2d_transform;
383 translate_2d_transform.Translate(80.f, 60.f); 391 translate_2d_transform.Translate(80.f, 60.f);
384 root()->SetBounds(gfx::Size(350, 200)); 392 root()->SetBounds(gfx::Size(350, 200));
385 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 393 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
386 child2()->SetTransform(translate_2d_transform); 394 child2()->SetTransform(translate_2d_transform);
387 great_grand_child()->SetDrawsContent(true); 395 great_grand_child()->SetDrawsContent(true);
388 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 396 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
389 great_grand_child()->SetBounds(gfx::Size(100, 200)); 397 great_grand_child()->SetBounds(gfx::Size(100, 200));
390 host_impl().active_tree()->BuildPropertyTreesForTesting(); 398 host_impl().active_tree()->BuildPropertyTreesForTesting();
391 399
392 gfx::BoxF box; 400 gfx::BoxF box;
393 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); 401 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box);
394 EXPECT_TRUE(success); 402 EXPECT_TRUE(success);
395 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); 403 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f);
396 EXPECT_BOXF_EQ(expected, box); 404 EXPECT_BOXF_EQ(expected, box);
397 } 405 }
398 406
399 TEST_F(LayerUtilsGetAnimationBoundsTest, 407 TEST_F(LayerUtilsGetAnimationBoundsTest,
400 RotateZUnderAncestorsWithPositionOr2DTransform) { 408 RotateZUnderAncestorsWithPositionOr2DTransform) {
401 double duration = 1.0; 409 double duration = 1.0;
402 410
403 TransformOperations start; 411 TransformOperations start;
404 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 412 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
405 TransformOperations great_grand_child_end; 413 TransformOperations great_grand_child_end;
406 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); 414 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f);
407 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 415 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(),
408 duration, start, great_grand_child_end); 416 timeline(), duration, start,
417 great_grand_child_end);
409 418
410 gfx::Transform translate_2d_transform; 419 gfx::Transform translate_2d_transform;
411 translate_2d_transform.Translate(80.f, 60.f); 420 translate_2d_transform.Translate(80.f, 60.f);
412 root()->SetBounds(gfx::Size(350, 200)); 421 root()->SetBounds(gfx::Size(350, 200));
413 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 422 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
414 child2()->SetTransform(translate_2d_transform); 423 child2()->SetTransform(translate_2d_transform);
415 424
416 gfx::Size bounds(100, 100); 425 gfx::Size bounds(100, 100);
417 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 426 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
418 grand_child()->SetBounds(bounds); 427 grand_child()->SetBounds(bounds);
(...skipping 25 matching lines...) Expand all
444 // +------grand_child (Perspective) 453 // +------grand_child (Perspective)
445 // +--------great_grand_child (RotateX, DrawsContent) 454 // +--------great_grand_child (RotateX, DrawsContent)
446 // Due to the RotateX animation, great_grand_child also owns a transform_node 455 // Due to the RotateX animation, great_grand_child also owns a transform_node
447 456
448 double duration = 1.0; 457 double duration = 1.0;
449 458
450 TransformOperations start; 459 TransformOperations start;
451 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 460 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
452 TransformOperations great_grand_child_end; 461 TransformOperations great_grand_child_end;
453 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 462 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
454 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 463 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(),
455 duration, start, great_grand_child_end); 464 timeline(), duration, start,
465 great_grand_child_end);
456 466
457 gfx::Transform translate_2d_transform; 467 gfx::Transform translate_2d_transform;
458 translate_2d_transform.Translate(80.f, 60.f); 468 translate_2d_transform.Translate(80.f, 60.f);
459 469
460 root()->SetBounds(gfx::Size(350, 200)); 470 root()->SetBounds(gfx::Size(350, 200));
461 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 471 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
462 child2()->SetTransform(translate_2d_transform); 472 child2()->SetTransform(translate_2d_transform);
463 473
464 gfx::Transform perspective; 474 gfx::Transform perspective;
465 perspective.ApplyPerspectiveDepth(100.f); 475 perspective.ApplyPerspectiveDepth(100.f);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 535 }
526 536
527 TEST_F(LayerUtilsGetAnimationBoundsTest, 537 TEST_F(LayerUtilsGetAnimationBoundsTest,
528 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) { 538 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) {
529 double duration = 1.0; 539 double duration = 1.0;
530 540
531 TransformOperations start; 541 TransformOperations start;
532 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 542 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
533 TransformOperations rotate_x_end; 543 TransformOperations rotate_x_end;
534 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 544 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
535 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 545 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(),
536 duration, start, rotate_x_end); 546 timeline(), duration, start,
547 rotate_x_end);
537 548
538 gfx::Transform translate_2d_transform; 549 gfx::Transform translate_2d_transform;
539 translate_2d_transform.Translate(80.f, 60.f); 550 translate_2d_transform.Translate(80.f, 60.f);
540 551
541 root()->SetBounds(gfx::Size(350, 200)); 552 root()->SetBounds(gfx::Size(350, 200));
542 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 553 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
543 child2()->SetTransform(translate_2d_transform); 554 child2()->SetTransform(translate_2d_transform);
544 555
545 gfx::Size bounds(100.f, 100.f); 556 gfx::Size bounds(100.f, 100.f);
546 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 557 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
(...skipping 15 matching lines...) Expand all
562 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, 573 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test,
563 // except for the perspective calculations. 574 // except for the perspective calculations.
564 575
565 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); 576 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f);
566 EXPECT_BOXF_EQ(expected, box); 577 EXPECT_BOXF_EQ(expected, box);
567 } 578 }
568 579
569 } // namespace 580 } // namespace
570 581
571 } // namespace cc 582 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698