OLD | NEW |
---|---|
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/trees/property_tree.h" | 5 #include "cc/trees/property_tree.h" |
6 | 6 |
7 #include "cc/test/geometry_test_utils.h" | 7 #include "cc/test/geometry_test_utils.h" |
8 #include "cc/trees/draw_property_utils.h" | 8 #include "cc/trees/draw_property_utils.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_dest_sublayer_scale, | 309 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_dest_sublayer_scale, |
310 transform); | 310 transform); |
311 | 311 |
312 success = tree.ComputeTransformWithSourceSublayerScale( | 312 success = tree.ComputeTransformWithSourceSublayerScale( |
313 grand_child_id, grand_parent_id, &transform); | 313 grand_child_id, grand_parent_id, &transform); |
314 EXPECT_TRUE(success); | 314 EXPECT_TRUE(success); |
315 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_source_sublayer_scale, | 315 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform_with_source_sublayer_scale, |
316 transform); | 316 transform); |
317 } | 317 } |
318 | 318 |
319 TEST (PropertyTreeTest, FlatteningWhenDestinationHasOnlyFlatAncestors) { | |
320 // This tests that flattening is performed correctly when | |
321 // destination and its ancestors are flat, but there are 3d transforms | |
322 // and flattening between between the source and destination. | |
ajuma
2015/04/16 18:10:08
Nit: repeated "between"
| |
323 TransformTree tree; | |
324 | |
325 int parent = tree.Insert(TransformNode(), 0); | |
326 tree.Node(parent)->data.content_target_id = parent; | |
327 tree.Node(parent)->data.target_id = parent; | |
328 tree.Node(parent)->data.local.Translate(2, 2); | |
329 | |
330 gfx::Transform rotation_about_x; | |
331 rotation_about_x.RotateAboutXAxis(15); | |
332 | |
333 int child = tree.Insert(TransformNode(), parent); | |
334 tree.Node(child)->data.content_target_id = child; | |
335 tree.Node(child)->data.target_id = child; | |
336 tree.Node(child)->data.local = rotation_about_x; | |
337 | |
338 | |
339 int grand_child = tree.Insert(TransformNode(), child); | |
340 tree.Node(grand_child)->data.content_target_id = grand_child; | |
341 tree.Node(grand_child)->data.target_id = grand_child; | |
342 tree.Node(grand_child)->data.flattens_inherited_transform = true; | |
343 | |
344 ComputeTransforms(&tree); | |
345 | |
346 gfx::Transform flattened_rotation_about_x = rotation_about_x; | |
347 flattened_rotation_about_x.FlattenTo2d(); | |
348 | |
349 gfx::Transform grand_child_to_parent; | |
350 bool success = | |
351 tree.ComputeTransform(grand_child, parent, &grand_child_to_parent); | |
352 EXPECT_TRUE(success); | |
353 EXPECT_TRANSFORMATION_MATRIX_EQ(flattened_rotation_about_x, | |
354 grand_child_to_parent); | |
355 } | |
356 | |
319 } // namespace cc | 357 } // namespace cc |
OLD | NEW |