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

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

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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_unittest.cc ('k') | cc/proto/BUILD.gn » ('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 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"
11 #include "cc/test/animation_test_common.h" 11 #include "cc/test/animation_test_common.h"
12 #include "cc/test/fake_impl_task_runner_provider.h" 12 #include "cc/test/fake_impl_task_runner_provider.h"
13 #include "cc/test/fake_layer_tree_host_impl.h" 13 #include "cc/test/fake_layer_tree_host_impl.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 14 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_task_graph_runner.h" 15 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/trees/layer_tree_host_common.h"
16 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gfx/geometry/box_f.h" 19 #include "ui/gfx/geometry/box_f.h"
19 #include "ui/gfx/test/gfx_util.h" 20 #include "ui/gfx/test/gfx_util.h"
20 21
21 namespace cc { 22 namespace cc {
22 namespace { 23 namespace {
23 24
24 float diagonal(float width, float height) { 25 float diagonal(float width, float height) {
25 return std::sqrt(width * width + height * height); 26 return std::sqrt(width * width + height * height);
26 } 27 }
27 28
28 class LayerUtilsGetAnimationBoundsTest : public testing::Test { 29 class LayerUtilsGetAnimationBoundsTest : public testing::Test {
29 public: 30 public:
30 LayerUtilsGetAnimationBoundsTest() 31 LayerUtilsGetAnimationBoundsTest()
31 : host_impl_(&task_runner_provider_, 32 : host_impl_(&task_runner_provider_,
32 &shared_bitmap_manager_, 33 &shared_bitmap_manager_,
33 &task_graph_runner_), 34 &task_graph_runner_),
34 root_(CreateTwoForkTree(&host_impl_)), 35 root_(CreateTwoForkTree(&host_impl_)),
35 parent1_(root_->test_properties()->children[0]), 36 parent1_(root_->test_properties()->children[0]),
36 parent2_(root_->test_properties()->children[1]), 37 parent2_(root_->test_properties()->children[1]),
37 child1_(parent1_->test_properties()->children[0]), 38 child1_(parent1_->test_properties()->children[0]),
38 child2_(parent2_->test_properties()->children[0]), 39 child2_(parent2_->test_properties()->children[0]),
39 grand_child_(child2_->test_properties()->children[0]), 40 grand_child_(child2_->test_properties()->children[0]),
40 great_grand_child_(grand_child_->test_properties()->children[0]) { 41 great_grand_child_(grand_child_->test_properties()->children[0]) {
41 timeline_ = 42 timeline_ =
42 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); 43 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
43 host_impl_.animation_host()->AddAnimationTimeline(timeline_); 44 host_impl_.animation_host()->AddAnimationTimeline(timeline_);
45 host_impl_.active_tree()->SetElementIdsForTesting();
44 } 46 }
45 47
46 LayerImpl* root() { return root_; } 48 LayerImpl* root() { return root_; }
47 LayerImpl* parent1() { return parent1_; } 49 LayerImpl* parent1() { return parent1_; }
48 LayerImpl* child1() { return child1_; } 50 LayerImpl* child1() { return child1_; }
49 LayerImpl* parent2() { return parent2_; } 51 LayerImpl* parent2() { return parent2_; }
50 LayerImpl* child2() { return child2_; } 52 LayerImpl* child2() { return child2_; }
51 LayerImpl* grand_child() { return grand_child_; } 53 LayerImpl* grand_child() { return grand_child_; }
52 LayerImpl* great_grand_child() { return great_grand_child_; } 54 LayerImpl* great_grand_child() { return great_grand_child_; }
53 55
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 scoped_refptr<AnimationTimeline> timeline_; 101 scoped_refptr<AnimationTimeline> timeline_;
100 }; 102 };
101 103
102 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { 104 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) {
103 double duration = 1.0; 105 double duration = 1.0;
104 106
105 TransformOperations start; 107 TransformOperations start;
106 start.AppendScale(1.f, 1.f, 1.f); 108 start.AppendScale(1.f, 1.f, 1.f);
107 TransformOperations end; 109 TransformOperations end;
108 end.AppendScale(2.f, 2.f, 1.f); 110 end.AppendScale(2.f, 2.f, 1.f);
109 AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, 111 AddAnimatedTransformToElementWithPlayer(root()->element_id(), timeline(),
110 start, end); 112 duration, start, end);
111 113
112 root()->SetPosition(gfx::PointF()); 114 root()->SetPosition(gfx::PointF());
113 parent1()->SetPosition(gfx::PointF()); 115 parent1()->SetPosition(gfx::PointF());
114 parent1()->SetBounds(gfx::Size(350, 200)); 116 parent1()->SetBounds(gfx::Size(350, 200));
115 117
116 child1()->SetDrawsContent(true); 118 child1()->SetDrawsContent(true);
117 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 119 child1()->SetPosition(gfx::PointF(150.f, 50.f));
118 child1()->SetBounds(gfx::Size(100, 200)); 120 child1()->SetBounds(gfx::Size(100, 200));
119 121
120 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 122 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
121 123
122 gfx::BoxF box; 124 gfx::BoxF box;
123 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 125 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
124 EXPECT_TRUE(success); 126 EXPECT_TRUE(success);
125 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f); 127 gfx::BoxF expected(150.f, 50.f, 0.f, 350.f, 450.f, 0.f);
126 EXPECT_BOXF_EQ(expected, box); 128 EXPECT_BOXF_EQ(expected, box);
127 } 129 }
128 130
129 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { 131 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) {
130 double duration = 1.0; 132 double duration = 1.0;
131 133
132 TransformOperations start; 134 TransformOperations start;
133 start.AppendTranslate(0.f, 0.f, 0.f); 135 start.AppendTranslate(0.f, 0.f, 0.f);
134 TransformOperations end; 136 TransformOperations end;
135 end.AppendTranslate(50.f, 50.f, 0.f); 137 end.AppendTranslate(50.f, 50.f, 0.f);
136 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 138 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
137 start, end); 139 duration, start, end);
138 140
139 parent1()->SetBounds(gfx::Size(350, 200)); 141 parent1()->SetBounds(gfx::Size(350, 200));
140 142
141 child1()->SetDrawsContent(true); 143 child1()->SetDrawsContent(true);
142 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 144 child1()->SetPosition(gfx::PointF(150.f, 50.f));
143 child1()->SetBounds(gfx::Size(100, 200)); 145 child1()->SetBounds(gfx::Size(100, 200));
144 146
145 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 147 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
146 148
147 gfx::BoxF box; 149 gfx::BoxF box;
148 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 150 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
149 EXPECT_TRUE(success); 151 EXPECT_TRUE(success);
150 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 152 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
151 EXPECT_BOXF_EQ(expected, box); 153 EXPECT_BOXF_EQ(expected, box);
152 } 154 }
153 155
154 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { 156 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) {
155 double duration = 1.0; 157 double duration = 1.0;
156 158
157 TransformOperations start; 159 TransformOperations start;
158 start.AppendTranslate(0.f, 0.f, 0.f); 160 start.AppendTranslate(0.f, 0.f, 0.f);
159 TransformOperations end; 161 TransformOperations end;
160 end.AppendTranslate(50.f, 50.f, 0.f); 162 end.AppendTranslate(50.f, 50.f, 0.f);
161 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 163 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
162 start, end); 164 duration, start, end);
163 parent1()->SetBounds(gfx::Size(350, 200)); 165 parent1()->SetBounds(gfx::Size(350, 200));
164 166
165 child1()->SetDrawsContent(true); 167 child1()->SetDrawsContent(true);
166 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 168 child1()->SetPosition(gfx::PointF(150.f, 50.f));
167 child1()->SetBounds(gfx::Size(100, 200)); 169 child1()->SetBounds(gfx::Size(100, 200));
168 170
169 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 171 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
170 172
171 gfx::BoxF box; 173 gfx::BoxF box;
172 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 174 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
173 EXPECT_TRUE(success); 175 EXPECT_TRUE(success);
174 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 176 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
175 EXPECT_BOXF_EQ(expected, box); 177 EXPECT_BOXF_EQ(expected, box);
176 } 178 }
177 179
178 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { 180 TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) {
179 double duration = 1.0; 181 double duration = 1.0;
180 182
181 TransformOperations start; 183 TransformOperations start;
182 start.AppendTranslate(0.f, 0.f, 0.f); 184 start.AppendTranslate(0.f, 0.f, 0.f);
183 TransformOperations child_end; 185 TransformOperations child_end;
184 child_end.AppendTranslate(50.f, 0.f, 0.f); 186 child_end.AppendTranslate(50.f, 0.f, 0.f);
185 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 187 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
186 start, child_end); 188 duration, start, child_end);
187 189
188 TransformOperations grand_child_end; 190 TransformOperations grand_child_end;
189 grand_child_end.AppendTranslate(0.f, 50.f, 0.f); 191 grand_child_end.AppendTranslate(0.f, 50.f, 0.f);
190 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 192 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
191 start, grand_child_end); 193 duration, start, grand_child_end);
192 194
193 parent1()->SetBounds(gfx::Size(350, 200)); 195 parent1()->SetBounds(gfx::Size(350, 200));
194 196
195 child1()->SetDrawsContent(true); 197 child1()->SetDrawsContent(true);
196 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 198 child1()->SetPosition(gfx::PointF(150.f, 50.f));
197 child1()->SetBounds(gfx::Size(100, 200)); 199 child1()->SetBounds(gfx::Size(100, 200));
198 200
199 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 201 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
200 202
201 gfx::BoxF box; 203 gfx::BoxF box;
202 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 204 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
203 EXPECT_TRUE(success); 205 EXPECT_TRUE(success);
204 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f); 206 gfx::BoxF expected(150.f, 50.f, 0.f, 150.f, 250.f, 0.f);
205 EXPECT_BOXF_EQ(expected, box); 207 EXPECT_BOXF_EQ(expected, box);
206 } 208 }
207 209
208 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { 210 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) {
209 double duration = 1.0; 211 double duration = 1.0;
210 212
211 TransformOperations start; 213 TransformOperations start;
212 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 214 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
213 TransformOperations end; 215 TransformOperations end;
214 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 216 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
215 217
216 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 218 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
217 start, end); 219 duration, start, end);
218 220
219 parent1()->SetBounds(gfx::Size(350, 200)); 221 parent1()->SetBounds(gfx::Size(350, 200));
220 222
221 gfx::Size bounds(100, 100); 223 gfx::Size bounds(100, 100);
222 child1()->SetDrawsContent(true); 224 child1()->SetDrawsContent(true);
223 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 225 child1()->SetPosition(gfx::PointF(150.f, 50.f));
224 child1()->SetBounds(bounds); 226 child1()->SetBounds(bounds);
225 child1()->test_properties()->transform_origin = 227 child1()->test_properties()->transform_origin =
226 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); 228 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0);
227 229
228 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 230 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
229 231
230 gfx::BoxF box; 232 gfx::BoxF box;
231 bool success = LayerUtils::GetAnimationBounds(*child1(), &box); 233 bool success = LayerUtils::GetAnimationBounds(*child1(), &box);
232 EXPECT_TRUE(success); 234 EXPECT_TRUE(success);
233 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f); 235 gfx::BoxF expected(150.f, 50.f, -50.f, 100.f, 100.f, 100.f);
234 EXPECT_BOXF_EQ(expected, box); 236 EXPECT_BOXF_EQ(expected, box);
235 } 237 }
236 238
237 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { 239 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) {
238 double duration = 1.0; 240 double duration = 1.0;
239 241
240 TransformOperations start; 242 TransformOperations start;
241 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 243 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
242 TransformOperations end; 244 TransformOperations end;
243 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 245 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
244 246
245 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 247 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
246 start, end); 248 duration, start, end);
247 249
248 // Make the anchor point not the default 0.5 value and line up with the 250 // Make the anchor point not the default 0.5 value and line up with the
249 // child center to make the math easier. 251 // child center to make the math easier.
250 parent1()->test_properties()->transform_origin = 252 parent1()->test_properties()->transform_origin =
251 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); 253 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f);
252 parent1()->SetBounds(gfx::Size(400, 400)); 254 parent1()->SetBounds(gfx::Size(400, 400));
253 255
254 gfx::Transform perspective; 256 gfx::Transform perspective;
255 perspective.ApplyPerspectiveDepth(100.f); 257 perspective.ApplyPerspectiveDepth(100.f);
256 parent1()->SetTransform(perspective); 258 parent1()->SetTransform(perspective);
(...skipping 19 matching lines...) Expand all
276 // local transform when there is an animation applied to the layer / node. 278 // local transform when there is an animation applied to the layer / node.
277 // The intended behavior is that the animation should overwrite the transform. 279 // The intended behavior is that the animation should overwrite the transform.
278 280
279 double duration = 1.0; 281 double duration = 1.0;
280 282
281 TransformOperations start; 283 TransformOperations start;
282 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 284 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
283 TransformOperations end; 285 TransformOperations end;
284 end.AppendRotate(1.f, 0.f, 0.f, 90.f); 286 end.AppendRotate(1.f, 0.f, 0.f, 90.f);
285 287
286 AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, 288 AddAnimatedTransformToElementWithPlayer(parent1()->element_id(), timeline(),
287 start, end); 289 duration, start, end);
288 290
289 // Make the anchor point not the default 0.5 value and line up 291 // Make the anchor point not the default 0.5 value and line up
290 // with the child center to make the math easier. 292 // with the child center to make the math easier.
291 parent1()->test_properties()->transform_origin = 293 parent1()->test_properties()->transform_origin =
292 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f); 294 gfx::Point3F(0.375f * 400.f, 0.375f * 400.f, 0.f);
293 parent1()->SetBounds(gfx::Size(400, 400)); 295 parent1()->SetBounds(gfx::Size(400, 400));
294 296
295 gfx::Transform perspective; 297 gfx::Transform perspective;
296 perspective.ApplyPerspectiveDepth(100.f); 298 perspective.ApplyPerspectiveDepth(100.f);
297 parent1()->SetTransform(perspective); 299 parent1()->SetTransform(perspective);
(...skipping 14 matching lines...) Expand all
312 EXPECT_BOXF_EQ(expected, box); 314 EXPECT_BOXF_EQ(expected, box);
313 } 315 }
314 316
315 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { 317 TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) {
316 double duration = 1.0; 318 double duration = 1.0;
317 319
318 TransformOperations start; 320 TransformOperations start;
319 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 321 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
320 TransformOperations end; 322 TransformOperations end;
321 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 323 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
322 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 324 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
323 start, end); 325 duration, start, end);
324 326
325 parent1()->SetBounds(gfx::Size(350, 200)); 327 parent1()->SetBounds(gfx::Size(350, 200));
326 328
327 gfx::Size bounds(100, 100); 329 gfx::Size bounds(100, 100);
328 child1()->SetDrawsContent(true); 330 child1()->SetDrawsContent(true);
329 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 331 child1()->SetPosition(gfx::PointF(150.f, 50.f));
330 child1()->SetBounds(bounds); 332 child1()->SetBounds(bounds);
331 child1()->test_properties()->transform_origin = 333 child1()->test_properties()->transform_origin =
332 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0); 334 gfx::Point3F(bounds.width() * 0.5f, bounds.height() * 0.5f, 0);
333 335
(...skipping 12 matching lines...) Expand all
346 EXPECT_BOXF_EQ(expected, box); 348 EXPECT_BOXF_EQ(expected, box);
347 } 349 }
348 350
349 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { 351 TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) {
350 double duration = 1.0; 352 double duration = 1.0;
351 353
352 TransformOperations start; 354 TransformOperations start;
353 start.AppendTranslate(5, 6, 7); 355 start.AppendTranslate(5, 6, 7);
354 TransformOperations end; 356 TransformOperations end;
355 end.AppendRotate(0.f, 0.f, 1.f, 90.f); 357 end.AppendRotate(0.f, 0.f, 1.f, 90.f);
356 AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, 358 AddAnimatedTransformToElementWithPlayer(child1()->element_id(), timeline(),
357 start, end); 359 duration, start, end);
358 360
359 parent1()->SetBounds(gfx::Size(350, 200)); 361 parent1()->SetBounds(gfx::Size(350, 200));
360 362
361 gfx::Size bounds(100, 100); 363 gfx::Size bounds(100, 100);
362 child1()->SetDrawsContent(true); 364 child1()->SetDrawsContent(true);
363 child1()->SetPosition(gfx::PointF(150.f, 50.f)); 365 child1()->SetPosition(gfx::PointF(150.f, 50.f));
364 child1()->SetBounds(bounds); 366 child1()->SetBounds(bounds);
365 367
366 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 368 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
367 369
(...skipping 13 matching lines...) Expand all
381 // This test is used to check if GetAnimationBounds correctly skips layers and 383 // This test is used to check if GetAnimationBounds correctly skips layers and
382 // take layers which do not own a transform_node into consideration. 384 // take layers which do not own a transform_node into consideration.
383 // Under this topology, only root and grand_child own transform_nodes. 385 // Under this topology, only root and grand_child own transform_nodes.
384 386
385 double duration = 1.0; 387 double duration = 1.0;
386 388
387 TransformOperations start; 389 TransformOperations start;
388 start.AppendTranslate(0.f, 0.f, 0.f); 390 start.AppendTranslate(0.f, 0.f, 0.f);
389 TransformOperations great_grand_child_end; 391 TransformOperations great_grand_child_end;
390 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); 392 great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f);
391 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 393 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(),
392 duration, start, great_grand_child_end); 394 timeline(), duration, start,
395 great_grand_child_end);
393 396
394 gfx::Transform translate_2d_transform; 397 gfx::Transform translate_2d_transform;
395 translate_2d_transform.Translate(80.f, 60.f); 398 translate_2d_transform.Translate(80.f, 60.f);
396 root()->SetBounds(gfx::Size(350, 200)); 399 root()->SetBounds(gfx::Size(350, 200));
397 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 400 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
398 child2()->SetTransform(translate_2d_transform); 401 child2()->SetTransform(translate_2d_transform);
399 great_grand_child()->SetDrawsContent(true); 402 great_grand_child()->SetDrawsContent(true);
400 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 403 great_grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
401 great_grand_child()->SetBounds(gfx::Size(100, 200)); 404 great_grand_child()->SetBounds(gfx::Size(100, 200));
402 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting(); 405 host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
403 406
404 gfx::BoxF box; 407 gfx::BoxF box;
405 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box); 408 bool success = LayerUtils::GetAnimationBounds(*great_grand_child(), &box);
406 EXPECT_TRUE(success); 409 EXPECT_TRUE(success);
407 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f); 410 gfx::BoxF expected(270.f, 155.f, 0.f, 150.f, 200.f, 0.f);
408 EXPECT_BOXF_EQ(expected, box); 411 EXPECT_BOXF_EQ(expected, box);
409 } 412 }
410 413
411 TEST_F(LayerUtilsGetAnimationBoundsTest, 414 TEST_F(LayerUtilsGetAnimationBoundsTest,
412 RotateZUnderAncestorsWithPositionOr2DTransform) { 415 RotateZUnderAncestorsWithPositionOr2DTransform) {
413 double duration = 1.0; 416 double duration = 1.0;
414 417
415 TransformOperations start; 418 TransformOperations start;
416 start.AppendRotate(0.f, 0.f, 1.f, 0.f); 419 start.AppendRotate(0.f, 0.f, 1.f, 0.f);
417 TransformOperations great_grand_child_end; 420 TransformOperations great_grand_child_end;
418 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); 421 great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f);
419 AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), 422 AddAnimatedTransformToElementWithPlayer(grand_child()->element_id(),
420 duration, start, great_grand_child_end); 423 timeline(), duration, start,
424 great_grand_child_end);
421 425
422 gfx::Transform translate_2d_transform; 426 gfx::Transform translate_2d_transform;
423 translate_2d_transform.Translate(80.f, 60.f); 427 translate_2d_transform.Translate(80.f, 60.f);
424 root()->SetBounds(gfx::Size(350, 200)); 428 root()->SetBounds(gfx::Size(350, 200));
425 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 429 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
426 child2()->SetTransform(translate_2d_transform); 430 child2()->SetTransform(translate_2d_transform);
427 431
428 gfx::Size bounds(100, 100); 432 gfx::Size bounds(100, 100);
429 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 433 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
430 grand_child()->SetBounds(bounds); 434 grand_child()->SetBounds(bounds);
(...skipping 25 matching lines...) Expand all
456 // +------grand_child (Perspective) 460 // +------grand_child (Perspective)
457 // +--------great_grand_child (RotateX, DrawsContent) 461 // +--------great_grand_child (RotateX, DrawsContent)
458 // Due to the RotateX animation, great_grand_child also owns a transform_node 462 // Due to the RotateX animation, great_grand_child also owns a transform_node
459 463
460 double duration = 1.0; 464 double duration = 1.0;
461 465
462 TransformOperations start; 466 TransformOperations start;
463 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 467 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
464 TransformOperations great_grand_child_end; 468 TransformOperations great_grand_child_end;
465 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 469 great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
466 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 470 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(),
467 duration, start, great_grand_child_end); 471 timeline(), duration, start,
472 great_grand_child_end);
468 473
469 gfx::Transform translate_2d_transform; 474 gfx::Transform translate_2d_transform;
470 translate_2d_transform.Translate(80.f, 60.f); 475 translate_2d_transform.Translate(80.f, 60.f);
471 476
472 root()->SetBounds(gfx::Size(350, 200)); 477 root()->SetBounds(gfx::Size(350, 200));
473 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 478 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
474 child2()->SetTransform(translate_2d_transform); 479 child2()->SetTransform(translate_2d_transform);
475 480
476 gfx::Transform perspective; 481 gfx::Transform perspective;
477 perspective.ApplyPerspectiveDepth(100.f); 482 perspective.ApplyPerspectiveDepth(100.f);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 542 }
538 543
539 TEST_F(LayerUtilsGetAnimationBoundsTest, 544 TEST_F(LayerUtilsGetAnimationBoundsTest,
540 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) { 545 RotateXNoPerspectiveUnderAncestorsWithPositionOr2DTransform) {
541 double duration = 1.0; 546 double duration = 1.0;
542 547
543 TransformOperations start; 548 TransformOperations start;
544 start.AppendRotate(1.f, 0.f, 0.f, 0.f); 549 start.AppendRotate(1.f, 0.f, 0.f, 0.f);
545 TransformOperations rotate_x_end; 550 TransformOperations rotate_x_end;
546 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); 551 rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f);
547 AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), 552 AddAnimatedTransformToElementWithPlayer(great_grand_child()->element_id(),
548 duration, start, rotate_x_end); 553 timeline(), duration, start,
554 rotate_x_end);
549 555
550 gfx::Transform translate_2d_transform; 556 gfx::Transform translate_2d_transform;
551 translate_2d_transform.Translate(80.f, 60.f); 557 translate_2d_transform.Translate(80.f, 60.f);
552 558
553 root()->SetBounds(gfx::Size(350, 200)); 559 root()->SetBounds(gfx::Size(350, 200));
554 parent2()->SetPosition(gfx::PointF(40.f, 45.f)); 560 parent2()->SetPosition(gfx::PointF(40.f, 45.f));
555 child2()->SetTransform(translate_2d_transform); 561 child2()->SetTransform(translate_2d_transform);
556 562
557 gfx::Size bounds(100.f, 100.f); 563 gfx::Size bounds(100.f, 100.f);
558 grand_child()->SetPosition(gfx::PointF(150.f, 50.f)); 564 grand_child()->SetPosition(gfx::PointF(150.f, 50.f));
(...skipping 15 matching lines...) Expand all
574 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test, 580 // Same as RotateXWithPerspectiveUnderAncestorsWithPositionOr2DTransform test,
575 // except for the perspective calculations. 581 // except for the perspective calculations.
576 582
577 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f); 583 gfx::BoxF expected(295.f, 180.f, -25.f, 50.f, 50.f, 50.f);
578 EXPECT_BOXF_EQ(expected, box); 584 EXPECT_BOXF_EQ(expected, box);
579 } 585 }
580 586
581 } // namespace 587 } // namespace
582 588
583 } // namespace cc 589 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_unittest.cc ('k') | cc/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698